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

avoid concrete examples for missingResourceError #45582

Merged
merged 1 commit into from
May 18, 2017

Conversation

CaoShuFeng
Copy link
Contributor

@CaoShuFeng CaoShuFeng commented May 10, 2017

missingResourceError uses pod and services as an example in error message. However some sub-commands doesn't support pod/service, this change use <resource> <name> instead of concrete examples.
Before this change:

$ kubectl set subject
error: You must provide one or more resources by argument or filename.
Example resource specifications include:
   '-f rsrc.yaml'
   '--filename=rsrc.json'
   'pods my-pod'
   'services'

After this change:

$ kubectl set subject
error: You must provide one or more resources by argument or filename.
Example resource specifications include:
   '-f rsrc.yaml'
   '--filename=rsrc.json'
   '<resource> <name>'
   '<resource>'

Release note:

avoid concrete examples for missingResourceError

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 10, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-ci-robot
Copy link
Contributor

Hi @CaoShuFeng. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with @k8s-bot 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.

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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 10, 2017
@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels May 10, 2017
@rootfs
Copy link
Contributor

rootfs commented May 10, 2017

/assign @janetkuo

@janetkuo
Copy link
Member

@k8s-bot ok to test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 11, 2017
Copy link
Member

@janetkuo janetkuo left a comment

Choose a reason for hiding this comment

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

@CaoShuFeng, thanks for the fix. IMO it's a valid error when the resource isn't specified (missingResourceError). It's one of general kubectl usage errors, so I don't want to special case it for kubectl set.

I'd like to hear more on why you think the error message is odd. What part of the original error message is confusing?

@CaoShuFeng
Copy link
Contributor Author

@janetkuo
For example, "kubectl set subject" only support "rolebinding/clusterrolebinding" but the help message uses "pods my-pod/services" as an example. In fact, we can't use "kubectl set subject pods".

@CaoShuFeng
Copy link
Contributor Author

@k8s-bot verify test this

@janetkuo
Copy link
Member

@CaoShuFeng I see, that makes sense. Please put the options validation code in Validate, ref kubectl convention https://github.com/kubernetes/community/blob/master/contributors/devel/kubectl-conventions.md#command-implementation-conventions

@CaoShuFeng
Copy link
Contributor Author

@janetkuo
Looks like someone else met a similar problem before:
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/resource/builder.go#L91
So is use this API to check the error.

@CaoShuFeng
Copy link
Contributor Author

CaoShuFeng commented May 14, 2017

Please put the options validation code in Validate

I tried your suggestion, but I found that error happens before we call Validate(), so it's difficult to check options in Validate().

@CaoShuFeng
Copy link
Contributor Author

@k8s-bot pull-kubernetes-federation-e2e-gce test this

@janetkuo
Copy link
Member

@CaoShuFeng I see, the missingResourceError is returned by resource builder. We can just modify the example part of missingResourceError -- don't use concrete examples since it's a generic error for kubectl, but not all commands support the resources specified in the example.

In summary, change it to something like:

var missingResourceError = fmt.Errorf(`You must provide one or more resources by argument or filename.
Example resource specifications include:
   '-f app.yaml'
   '--filename=app.json'
   '<resource> <name>'
   '<resource>'`)

"missingResourceError" is a generic error for kubectl, so we should
not use concrete examples in the error message.
@k8s-github-robot k8s-github-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 16, 2017
@CaoShuFeng CaoShuFeng changed the title Fix odd help message of "kubectl set" avoid concrete examples for missingResourceError May 16, 2017
@CaoShuFeng
Copy link
Contributor Author

CaoShuFeng commented May 16, 2017

@janetkuo
Done.

@CaoShuFeng
Copy link
Contributor Author

@k8s-bot unit test this

@janetkuo
Copy link
Member

Thanks!
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 17, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CaoShuFeng, janetkuo

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 17, 2017
@CaoShuFeng
Copy link
Contributor Author

@k8s-bot gce etcd3 e2e test this

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 212150b into kubernetes:master May 18, 2017
@CaoShuFeng CaoShuFeng deleted the kubectl_set branch November 6, 2017 05:45
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants