-
Notifications
You must be signed in to change notification settings - Fork 531
fix: prefer core resources when enabling a type #1294
fix: prefer core resources when enabling a type #1294
Conversation
When a resource type such as `pods` is `services` is passed to `kubefedctl enable` and there's a match for this name in the `core` group as well as another group, there was no way to tell `kubefedctl` that the `core` resource should be enabled. Now, whenever an API resource from the `core` group matches the desired type to be enabled, this resource type is preferred.
/assign @jimmidyson |
@makkes thanks for doing this. |
I wonder if we should do the same as kubectl does and follow API group/version priority when short names (or unqualified as in this case) are used? |
@jimmidyson do you have a hint where I would find out how kubectl does it? |
@makkes Check out |
We're already using @jimmidyson wdyt? |
This PR effectively puts core v1 API as higher priority than anything else, which is reasonable and fixes the reported bug, so I'm happy to approve this PR as-is and follow up with a PR that aligns with kubectl semantics. I agree with @irfanurrehman that this should be documented and then we can get this merged. I think we can clean up the code quite a bit by using discovery client smarter, something like: restMapper := restmapper.NewDeferredDiscoveryRESTMapper(discoveryClient)
shortcutRestMapper := restmapper.NewShortcutExpander(restMapper, discoveryClient)
gvks, err := shortcutRestMapper.KindsFor(schema.GroupVersionResource{Group: optionalGroup, Version: optionalVersion, Resource: resource}) |
I agree and will add documentation soon! |
@irfanurrehman @jimmidyson I added a section to the user guide. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jimmidyson, makkes 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 |
/lgtm |
What this PR does / why we need it:
When a resource type such as
pods
isservices
is passed tokubefedctl enable
and there's a match for this name in thecore
group as well as another group, there was no way to tell
kubefedctl
that the
core
resource should be enabled.Now, whenever an API resource from the
core
group matches thedesired type to be enabled, this resource type is preferred.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #1078
Special notes for your reviewer:
Here's the steps to test this:
kind create cluster
kubectl apply --filename https://github.com/knative/serving/releases/download/v0.18.0/serving-crds.yaml
make kubefedctl
./bin/kubefedctl enable services --kubefed-namespace="default" -o yaml
Before this change:
With this change: