Add a kubectl command to set the HNC configuration of a specific type #595
/hold
Will make this PR on hold till #592 is merged.
/assign @adrianludwin
/assign @yiqigao217
@adrianchung
Thanks for reviewing my previous PR. I will resolve comments in that PR first and ping you again once that one is merged.
@sophieliu15: GitHub didn't allow me to request PR reviews from the following users: adrianchung.
Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.
<details>
In response to this:
>/assign @adrianludwin
>/assign @yiqigao217
>/cc @adrianchung
>Thanks for reviewing my previous PR. I will resolve comments in that PR first and ping you again once that one is merged.
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.
</details>
Is the string(x) cast really needed?
Also, the usage should be something more like set-type --kind X --apiVersion Y <propagate|remove|ignore>, right?
Some examples here might be nice, e.g. "v1" for core objects or "example.com/v1beta1" for a contributed type.
It doesn't look like we need the string(x) cast. Removed them. Changed to the usage to contain the flags.
Thanks for the suggestion! Done. PTAL.
Eh? That's odd. Is this behaviour documented anywhere? Or is our plugin not treating the Details field properly?
If you type in kubectl help create role, you get a lot of examples. Can we add some examples here as well? I don't know if they belong in the "Use" field or somewhere else (e.g., is ther a "Long" help field?).
I don't think it is related to our plugin. When tracing back the call tree of Error(), it calls FromObject, which generates a StatusError from metav1.Status (this is the type of AdmissionResponse.Result). The StatusError implements the Error interface using Message field from the status. IIUC, that's why when we print Error() it only prints the Message field.
Sure! I added two examples in the Example field and removed the examples in the flag definitions. Feel free to take a look.
/hold cancel
#592 was merged and this PR was rebased.
You need to manually indent like this? That's annoying :P
Ah, but that _is_ our plugin then. We're the ones calling Error(), which is only based on the Message field below.
By contrast, it sounds like kubectl ignores Message and only displays Details instead?
Looks like kubectl ignores Message and prints out Details if the error is Invalid (see implementation here). Do you think we should do something similar in our plugin?
Oh, I just thought there might be something special for Example because it's a builtin feature of Cobra. But that's fine, thanks!
No, I don't think that's needed, but can you please update this comment to include everything we've discussed? Because it is super-confusing. And don't try to write a short comment, make it as long and rambling as you like (e.g. https://github.com/kubernetes-sigs/multi-tenancy/blob/master/incubator/hnc/pkg/reconcilers/hierarchy_config.go#L306) - give any future reader as much of a chance as you can that they'll be able to figure out why we did this.
Thanks for the suggestion! I added a detailed the comment here. PTAL. I also added code links in the comment, feel free to let me know if it makes the comment less readable or any suggestions to improve the readability. Thank you!
Perfect :)
/approve
/lgtm
/hold
/assign @rjbez17
I changed the commit and PR message to refer to the correct issue (454 instead of 545).
type in this context isn't that obvious IMO. Maybe resources type is better? Thoughts?
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: <a href="https://github.com/kubernetes-sigs/multi-tenancy/pull/595#issuecomment-609914130" title="LGTM">adrianludwin</a>, <a href="https://github.com/kubernetes-sigs/multi-tenancy/pull/595#issuecomment-610024069" title="Approved">rjbez17</a>, <a href="https://github.com/kubernetes-sigs/multi-tenancy/pull/595#" title="Author self-approved">sophieliu15</a>
The full list of commands accepted by this bot can be found here.
The pull request process is described here
<details >
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
</details>
<!-- META={"approvers":[]} -->
Hi Ryan!
Thanks for the suggestion! I feel set-resources-type might be a little bit long (e.g., the whole command will be like kubectl hns config set-resources-type [flags] propagate) but I don't have a better suggestion about the naming. Are there other kinds of "types" that users might be confused with "resource types"?
I don't have preference between type and resources-type. If you think resources-type is not too long, we can go for it. :)
@adrianludwin WDYT?
I was referring just to the short description, not the actual command names. I agree it'd be too long for the name.
Cool! Thanks for the clarification. Changed to "resources type" in the short description.
/lgtm
/hold cancel
This lgtm!
adrianludwin
sophieliu15
This PR adds a kubectl command to set the HNC configuration of a specific type. Specifically it implements the following features:
Example usage:
kubectl hns config --apiVersion v1 --kind Secret ignoreIssue: #454