Skip to content
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

Merged
merged 1 commit into from
Jul 31, 2019

Conversation

zhanggbj
Copy link

@zhanggbj zhanggbj commented Jul 30, 2019

For now if no flag(s) set, service update will still try to do an update as below, it should return an error instead.

$ ./kn service update hello
Waiting for service 'hello' to become ready ... OK
Service 'hello' updated in namespace 'default'.

Fixes issue 286

Proposed Changes

  • Return an error if no flag(s) set in service update

Release Note


@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 30, 2019
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a 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.

issue 286

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.

pkg/kn/commands/service/service_update.go Outdated Show resolved Hide resolved
@knative-prow-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@knative-prow-robot knative-prow-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 30, 2019
@zhanggbj zhanggbj force-pushed the service_update_input branch 2 times, most recently from bb0b714 to 73c16c1 Compare July 30, 2019 14:00
t.Errorf("Unexpected action if no flag(s) set")
}

if err != nil {
Copy link
Contributor

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.

Copy link
Author

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 {
Copy link
Contributor

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 :)

Copy link
Author

@zhanggbj zhanggbj Jul 31, 2019

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!

Copy link
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ok-to-test

@knative-prow-robot knative-prow-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 30, 2019
@zhanggbj zhanggbj force-pushed the service_update_input branch 3 times, most recently from 73c16c1 to dd02b81 Compare July 31, 2019 08:15
@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 31, 2019
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)
@zhanggbj zhanggbj force-pushed the service_update_input branch from dd02b81 to d4fcd1f Compare July 31, 2019 08:19
@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/kn/commands/service/service_update.go 73.7% 76.2% 2.5

Copy link
Contributor

@toVersus toVersus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@knative-prow-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@maximilien
Copy link
Contributor

Thanks @zhanggbj and @toVersus for the review

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 31, 2019
@knative-prow-robot knative-prow-robot merged commit 8fbb51f into knative:master Jul 31, 2019
navidshaikh pushed a commit to navidshaikh/client that referenced this pull request Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kn service update should print an error message when invalid or no option is passed
6 participants