-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
cmd/openshift-install: Stricter argument parsing #1125
cmd/openshift-install: Stricter argument parsing #1125
Conversation
If we can't parse the value, wait until we've setup stderr logging before complaining about it. With this commit: $ openshift-install --log-level destroy create cluster FATAL invalid log-level: not a valid logrus Level: "destroy" $ echo $? 1 while previously: $ openshift-install --log-level destroy create cluster $ echo $? 1
I've pushed a0c48e4 to also check for invalid extra positional arguments for |
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.
Looks good.
a0c48e4
to
5133169
Compare
} | ||
cmd.PersistentFlags().StringVar(&rootOpts.dir, "dir", ".", "assets directory") | ||
cmd.PersistentFlags().StringVar(&rootOpts.logLevel, "log-level", "info", "log level (e.g. \"debug | info | warn | error\")") | ||
return cmd | ||
} | ||
|
||
func runRootCmd(cmd *cobra.Command, args []string) error { | ||
func runRootCmd(cmd *cobra.Command, args []string) { |
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.
ques: wouldn't just performing the level parsing check before setting logrus.SetOutput(ioutil.Discard)
provide resolution to problem
If we can't parse the value, wait until we've setup stderr logging
before complaining about it. With this commit:
$ openshift-install --log-level destroy create cluster
FATAL invalid log-level: not a valid logrus Level: "destroy"
$ echo $?
1
while previously:
$ openshift-install --log-level destroy create cluster
$ echo $?
1
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.
ques: wouldn't just performing the level parsing check before setting
logrus.SetOutput(ioutil.Discard)
provide resolution to problem
Sort of. It would land before our stderr hook and its &logrus.TextFormatter
config, so the output looks like:
$ openshift-install --log-level destroy create cluster
FATA[0000] invalid log-level: not a valid logrus Level: "destroy"
My weak preference is for 772b514 as it stands, but I can switch this around if you'd prefer the earlier level parser approach.
Also 5133169 looks out of place in this PR based on the title, can we update the PR desciption and title to reflect that? It is fine to get both these in, in one PR with CI flaking... :( |
/refresh |
Still lots of "Expected" for Prow. /refresh |
5133169
to
5fedd84
Compare
With this commit: $ openshift-install create install-config whatever FATA[0000] Error executing openshift-install: accepts 0 arg(s), received 1 $ echo $? 1 instead of silently ignoring "whatever" and creating the install-config. Docs in [1,2]. [1]: https://godoc.org/github.com/spf13/cobra#ExactArgs [2]: https://godoc.org/github.com/spf13/cobra#Command
5fedd84
to
a8c1aa3
Compare
I've pushed 5fedd84 -> a8c1aa3 fixing the |
/retest |
/retest |
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: crawford, wking 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 |
/retest Please review the full test history for this PR and help us cut down flakes. |
2 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
4 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Pick up openshift/origin#21867. |
If we can't parse the value, wait until we've setup stderr logging before complaining about it. With this pull-request:
while previously: