-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add --no-verify flag to edit add resource command #5333
Add --no-verify flag to edit add resource command #5333
Conversation
This PR has multiple commits, and the default merge method is: merge. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cc @mehabhalodiya |
@stormqueen1990 Thank you for the suggestions, I have addressed them in the latest commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - except for just one comment on the name of the flag.
@@ -35,6 +36,9 @@ func newCmdAddResource(fSys filesys.FileSystem) *cobra.Command { | |||
return o.RunAddResource(fSys) | |||
}, | |||
} | |||
cmd.Flags().BoolVar(&o.skipValidation, "skip-validation", false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For parity with the flag we are adding to kustomize localize (#5276), can we likewise name this flag --no-verify
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be better. I've renamed the flag.
resources, err = GlobPatternsWithLoader(fSys, ldr, []string{invalidURL}, true) | ||
require.NoError(t, err, "unexpected load error") | ||
require.Equal(t, 1, len(resources), "incorrect resources") | ||
require.Equal(t, invalidURL, resources[0], "incorrect resources") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing up these tests and adding one for this feature.
I think it might be nice to rewrite these tests using test structs and subtests, here is an example of this for the remove tests, so that it is easier to read and distinguish each test. You don't need to do this as part of this PR, but it would be a welcome change if you'd like to submit a follow-up PR to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was also thinking about that when I refactored the tests. Let me tackle that in a separate PR.
/lgtm Thanks! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hailkomputer, natasha41575 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This PR addresses the issue #3276
Users want to be able to run
kustomize edit add resource <remote-resource>
in cases the remote is not reachable and can not be validated.--skip-validation
flag will be passed to the underlyingGlobPatternsWithLoader
function which is refactored here.Refactored behavior of
GlobPatternsWithLoader
function is as follows:It accepts a slice of glob strings and returns the set of matching file paths. If validation is skipped, then it will return the patterns as provided. Otherwise, It will try to load the files from the filesystem. If files are not found in the filesystem, it will try to load from remote. It returns an error if validation is not skipped and there are no matching files or it can't load from remote.
Other instances of the function reference is also changed with the newly introduces input parameter.