-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Add Local and Unstructured resource builder attributes and handle <rsrsc> / <name> pairs when --local is set #48763
Add Local and Unstructured resource builder attributes and handle <rsrsc> / <name> pairs when --local is set #48763
Conversation
Hi @juanvallejo. 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 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. I understand the commands that are listed here. |
2580ccc
to
8172607
Compare
/ok-to-test |
8172607
to
a07f1d7
Compare
@fabianofranz wondering if this is good to go? Thanks! |
@juanvallejo This works for me, but here goes an idea. I didn't check the feasibility so it may not even work. Anyways: would it make sense to make "local" an attribute of the Main concept of the idea would be to rely on the actual client and, in any tentative of an API call, throw the error. Would fix it for any new commands we add in future, an avoid the need for so many conditionals. |
Also I remember fixing a few days ago a panic related to that |
I think this would certainly improve the way we would handle local command invocations. |
a07f1d7
to
dcb86ae
Compare
@fabianofranz ecfa394 adds a new |
pkg/kubectl/resource/mapper.go
Outdated
@@ -32,7 +32,7 @@ type DisabledClientForMapping struct { | |||
} | |||
|
|||
func (f DisabledClientForMapping) ClientForMapping(mapping *meta.RESTMapping) (RESTClient, error) { | |||
return nil, nil | |||
return nil, fmt.Errorf("attempt to make api call using a disabled client") |
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.
@fabianofranz not sure if this is the right approach, or if it's better to just make and return a fake RESTClient
EDIT: Implementing a disabled RESTClient would be a bit tricky as each of its methods returns a k8s.io/client-go/rest#Request
. This means that I would either have to return a request with most of its data missing, which would then return an error due to missing info when its methods are called, or I could return nil
for each of the disabled RESTClient's methods. This would then cause a panic in this part of the code
dcb86ae
to
0d0f723
Compare
/test pull-kubernetes-unit |
7ec02b0
to
07b444a
Compare
@fabianofranz Not sure how to fix bazel test. Getting the error:
Tried adding this line to |
4d2fceb
to
68a3c1b
Compare
91e3f6a
to
a799172
Compare
@fabianofranz had to rebase to bring in the |
/test pull-kubernetes-e2e-kops-aws |
/unassign |
a799172
to
b2ff055
Compare
Moves DisabledClientMapperForMapping wrapper to new Local attribute. Removes Factory#NewUnstructuredBuilder in favor of new Unstructured builder attribute.
b2ff055
to
04d319d
Compare
/retest |
/test pull-kubernetes-kubemark-e2e-gce |
@cblecker or @fabianofranz wondering if you could /lgtm this once more? Thanks! |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fabianofranz, juanvallejo Associated issue requirement bypassed by: fabianofranz The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all |
/retest Review the full test history for this PR. |
2 similar comments
/retest Review the full test history for this PR. |
/retest Review the full test history for this PR. |
Automatic merge from submit-queue (batch tested with PRs 47806, 49539, 48763, 47049, 50600). If you want to cherry-pick this change to another branch, please follow the instructions here.. |
// Unstructured updates the builder's ClientMapper, RESTMapper, | ||
// ObjectTyper, and codec for working with unstructured api objects | ||
func (b *Builder) Unstructured(mapperFunc ClientMapperFunc, mapper meta.RESTMapper, typer runtime.ObjectTyper) *Builder { | ||
if b.isLocal { |
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 is not the right place to check this. Local and unstructured have nothing to do with each other. Local commands should absolutely be able to function without needing to have compiled in objects.
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.
@smarterclayton Thanks, will make a patch to address this
…urce-builder Automatic merge from submit-queue (batch tested with PRs 54399, 54557, 54506). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. remove mutual exclusivity check - local, unstructured builder attrs **Release note**: ```release-note NONE ``` Remove incorrect mutual exclusivity check between the resource builder `Local` and `Unstructured` attributes. Related comment: #48763 (comment) Followup to #48763 cc @smarterclayton
Release note:
Related downstream BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1390139
Adds an error message if a non-filename (or stdin) resource is specified with the
--local
flag in any of thekube set ...
sub-commands.cc @fabianofranz @kubernetes/sig-cli-misc