-
Notifications
You must be signed in to change notification settings - Fork 40k
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
kubeadm: Make sure --config can be mixed with --skip-* flags #49498
kubeadm: Make sure --config can be mixed with --skip-* flags #49498
Conversation
cc @mattmoyer |
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.
Minor comment, the code is not super friendly to read. I would prefer to output the flags that were bad.
return fmt.Errorf("can not mix '--config' with other arguments") | ||
if flag.Changed("config") { | ||
numFlagsAllowedToChange := 1 | ||
flagsAllowedToChangeWithConfig := []string{"skip-preflight-checks", "skip-token-print"} |
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.
Can't you just check to see if the flags are anything other then these two and output an error indicating the flags they specified?
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.
You probably want Flagset.Visit https://godoc.org/github.com/spf13/pflag#FlagSet.Visit
mixedFlags := []string{}
flag.Visit(func(f *pflag.Flag) {
if f.Name == "config" || strings.HasPrefix(f.Name, "skip-") {
// "skip=*" flags can be set with --config
return
}
mixedFlags = append(mixedFlags, f.Name)
})
a96b60d
to
aa46947
Compare
/retest |
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 - thx for the change, much easier to read.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: luxas, timothysc Associated issue: 352 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest |
/retest |
Automatic merge from submit-queue (batch tested with PRs 49498, 49192) |
Commit found in the "release-1.7" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked. |
What this PR does / why we need it:
fixes: kubernetes/kubeadm#352
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #Special notes for your reviewer:
Should be a cherrypick candidate
Release note:
@kubernetes/sig-cluster-lifecycle-pr-reviews @ericchiang @wojtek-t