-
Notifications
You must be signed in to change notification settings - Fork 250
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
Check if Namespace Exists for Task List Command #349
Conversation
Hi @danielhelfand. Thanks for your PR. I'm waiting for a tektoncd 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. |
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
The following is the coverage report on pkg/.
|
pkg/cmd/task/list.go
Outdated
// Check if namespace exists. Return error if namespace specified with -n doesn't exist. | ||
_, err = cs.Kube.CoreV1().Namespaces().Get(p.Namespace(), metav1.GetOptions{}) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Error: Namespace \"%s\" does not exist. Please enter a valid namespace.\n", p.Namespace()) |
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 we need to handle the case of if the user doesn't have access to that namespace
. In that case, this error message may be misleading.
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.
It may be better to just return err
here as what ever is returned will be displayed to the user. I ran into issues with testing by returning err
originally since it appears to display the usage as part of the output. I'll take another shot at that approach.
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.
This should now display RBAC errors as well with most recent push.
The following is the coverage report on pkg/.
|
@@ -33,6 +33,7 @@ func ExecuteCommandC(c *cobra.Command, args ...string) (*cobra.Command, string, | |||
buf := new(bytes.Buffer) | |||
c.SetOutput(buf) | |||
c.SetArgs(args) | |||
c.SilenceUsage = true |
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.
Adding this since tkn
already has SilenceUsage
set to true in root.go
. Tests should be the same output.
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vdemeester 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 |
This pull request is a proposal to help deal with #311. It adds an error message to the CLI to check whether the namespace specified by the user exists on his or her cluster.
Assuming this is a valid proposal, I can begin implementing this same change for other locations in the CLI that use
-n
.Changes
Adds a check to
task/list.go
to see whether a namespace exists. If it does not, an error message is returned:"Error: namespaces \"foo\" not found\n"
. The use ofnamespaces
versus non-pluralnamespace
in the error message is not considered an issue for client-go.Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
make docs
andmake man
if needed.make check
See the contribution guide
for more details.
Release Notes