-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix cmctl renew
flags validation
#20
Fix cmctl renew
flags validation
#20
Conversation
Hi @jace-ys. Thanks for your PR. I'm waiting for a cert-manager 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. |
"If there are arguments, as well as --all-namespaces, error": { | ||
options: &Options{ | ||
AllNamespaces: true, | ||
}, | ||
args: []string{"abc"}, | ||
expErr: 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.
If arguments are specified:
- You would get an
Error from server (NotFound):
error with--all-namespaces
, unless the first namespace that is listed happens to contain the certificate(s) specified in the arguments.- This behaviour doesn't sound ideal so I think it's more intuitive to disallow use of arguments with
--all-namespaces
; arguments should really only be used with--namespace
.
- This behaviour doesn't sound ideal so I think it's more intuitive to disallow use of arguments with
cd921cf
to
beb912f
Compare
cmdctl renew
flags validationcmctl renew
flags validation
"If there are all certificates selected, as well as label selector, error": { | ||
options: &Options{ | ||
LabelSelector: "foo=bar", | ||
All: true, | ||
}, | ||
args: []string{""}, |
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 looks like a minor bug in the test case, as providing []string{""}
as args is triggering a different error cannot specify Certificate names in conjunction with label selectors
than intended (cannot specify label selectors in conjunction with --all flag
)
d85427f
to
5ded621
Compare
Signed-off-by: jace-ys <jace@duffel.com>
Signed-off-by: jace-ys <jace@duffel.com>
Signed-off-by: jace-ys <jace@duffel.com>
5ded621
to
5babd3e
Compare
"If --namespace and --all namespace specified, error": { | ||
"If --namespace and --all specified, don't error": { | ||
options: &Options{ | ||
All: true, | ||
}, | ||
setStringFlags: []stringFlag{ | ||
{name: "namespace", value: "foo"}, | ||
}, | ||
expErr: 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.
This test case doesn't seem right, as looking at the description for --all
as well as the actual Run function, they seem to suggest that --all
should work with --namespace
.
I've updated the validation function accordingly too.
/ok-to-test |
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
Thanks @jace-ys, I added some comments that explain in what cases the Validation function should fail. |
Thanks! Looks great and is much cleaner now👍🏻 |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: inteon 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 |
Hey folks 👋🏻
While using
cmctl renew
earlier today, we noticed some bugs in the flags that caused an error when runningcmctl renew --all-namespaces -l app=my-service
as documented in the CLI help.The error we saw:
I made an attempt to fix this bug in the renew validation function, so keen to hear your thoughts on it 😄
I've also updated the tests accordingly!
Reasoning
Based on my understanding of the actual
Run
command, I believe these hold true:--all
and--label-selectors
--all
or--label-selectors
--all
, or--label-selectors
Error from server (NotFound)
: error with--all-namespaces
, unless the first namespace that is listed happens to contain the certificate(s) specified in the arguments.--all-namespaces
; arguments should really only be used with--namespace
.