Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement 'gcp wif-config update' command #667

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JakobGray
Copy link
Contributor

  1. Implement 'gcp wif-config update' command to re-apply GCP resources
  2. Filter version on 'create cluster' when using WIF
  3. Accept WIF displayName in WIF commands

Related issue: OCM-10615

Copy link
Collaborator

@renan-campos renan-campos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes pertain to code organization. The new function implementations and overall enhancements look good to me.

@@ -545,3 +545,12 @@ func (c *shim) createMemberRoleBindingForProject(
Role: roleName,
})
}

// Checks for WIF config name or id in input
func wifKeyArgCheck(args []string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helper does not belong in this file. I would put it in a helpers.go file.

@@ -545,3 +545,12 @@ func (c *shim) createMemberRoleBindingForProject(
Role: roleName,
})
}

// Checks for WIF config name or id in input
func wifKeyArgCheck(args []string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helper does not belong in this file as it does not relate to the shim. I would recommend placing it in a 'helpers.go' file.

// No implementation yet
ctx := context.Background()
log := log.Default()
key := argv[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have readability concerns with the way we are deriving the key throughout our wif commands.

We know that the first element of argv exists and will be populated because we run wifKeyArgCheck on argv within the preRunE function that is run prior to RunE; we are safe to access argv[0]. However knowing this requires the reader to be aware of this execution flow, which is defined by the cobra package.

I'm thinking it may be better for the readibility of the code to do away with the preRunE call, and do the flag validation at the start of RunE. We could then have functions that both validate that the data is there and return it:

key, err := wifKeyFromArgs(argv)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a manual mode for wif updates?

return nil
}

// findWifConfig finds the WIF configuration by ID or name
func findWifConfig(client *cmv1.Client, key string) (*cmv1.WifConfig, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function could also go in helpers.go, as it is used by multiple commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants