Report an error if no flag(s) set in service update#318
Report an error if no flag(s) set in service update#318knative-prow-robot merged 1 commit intoknative:masterfrom
Conversation
knative-prow-robot
left a comment
There was a problem hiding this comment.
@zhanggbj: 1 warning.
Details
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. DetailsInstructions 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.
I think you can reduce a if-else depth by swapping the if-else block and using t.Fatal.
| return err | ||
| } | ||
|
|
||
| if cmd.Flags().NFlag() == 0 { |
There was a problem hiding this comment.
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.
@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!
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/.
|
|
[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 DetailsNeeds 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