-
Notifications
You must be signed in to change notification settings - Fork 263
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
Report an error if no flag(s) set in service update #318
Report an error if no flag(s) set in service update #318
Conversation
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.
@zhanggbj: 1 warning.
In response to this:
For now if no flag(s) set, service update will still try to
do an update, it should return an error instead.Fixes #
Proposed Changes
Release Note
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.
Hi @zhanggbj. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
bb0b714
to
73c16c1
Compare
t.Errorf("Unexpected action if no flag(s) set") | ||
} | ||
|
||
if err != nil { |
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.
I think you can reduce a if-else depth by swapping the if-else block and using t.Fatal.
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.
@toVersus I addressed it, thanks!
@@ -50,6 +50,10 @@ func NewServiceUpdateCommand(p *commands.KnParams) *cobra.Command { | |||
return err | |||
} | |||
|
|||
if cmd.Flags().NFlag() == 0 { |
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.
The other option would be to do this in a PreRun
function which should allow separation of the checks to the Run
. See this comment from Cobra community.
Since this check is simple, it's likely OK here but if we start adding more such checks or other commands then PreRun
could be a nice way to write these pre-condition code. Cheers :)
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.
@maximilien As you mentioned, there may be more checks needed later, and people even mentioned about the odd error message when wrong args here #317, so I moved this part to PreRun
. Thanks!
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.
/ok-to-test
73c16c1
to
dd02b81
Compare
For now if no flag(s) set, service update will still try to do an update, it should return an error instead. [issue 286](knative#286)
dd02b81
to
d4fcd1f
Compare
The following is the coverage report on pkg/.
|
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, thanks!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: maximilien, toVersus, zhanggbj 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 |
For now if no flag(s) set, service update will still try to do an update as below, it should return an error instead.
Fixes issue 286
Proposed Changes
Release Note