mirror of https://github.com/k3s-io/k3s
Merge pull request #58741 from dixudx/fix_kubectl_alias_group
Automatic merge from submit-queue (batch tested with PRs 58302, 58782, 58555, 58741). 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>. use containing API group when resolving shortname from discovery **What this PR does / why we need it**: kubectl does not use containing API group when resolving shortname from discovery **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 #58695 **Special notes for your reviewer**: /assign @liggitt /cc @nikhita @zjj2wry **Release note**: ```release-note use containing API group when resolving shortname from discovery ```pull/6/head
commit
617c87ba06
|
@ -115,6 +115,7 @@ func (e shortcutExpander) expandResourceShortcut(resource schema.GroupVersionRes
|
|||
}
|
||||
if resource.Resource == item.ShortForm.Resource {
|
||||
resource.Resource = item.LongForm.Resource
|
||||
resource.Group = item.LongForm.Group
|
||||
return resource
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ func TestReplaceAliases(t *testing.T) {
|
|||
{
|
||||
name: "hpa-priority",
|
||||
arg: "hpa",
|
||||
expected: schema.GroupVersionResource{Resource: "superhorizontalpodautoscalers"},
|
||||
expected: schema.GroupVersionResource{Resource: "superhorizontalpodautoscalers", Group: "autoscaling"},
|
||||
srvRes: []*metav1.APIResourceList{
|
||||
{
|
||||
GroupVersion: "autoscaling/v1",
|
||||
|
@ -68,6 +68,31 @@ func TestReplaceAliases(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "resource-override",
|
||||
arg: "dpl",
|
||||
expected: schema.GroupVersionResource{Resource: "deployments", Group: "foo"},
|
||||
srvRes: []*metav1.APIResourceList{
|
||||
{
|
||||
GroupVersion: "foo/v1",
|
||||
APIResources: []metav1.APIResource{
|
||||
{
|
||||
Name: "deployments",
|
||||
ShortNames: []string{"dpl"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
GroupVersion: "extension/v1beta1",
|
||||
APIResources: []metav1.APIResource{
|
||||
{
|
||||
Name: "deployments",
|
||||
ShortNames: []string{"deploy"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
ds := &fakeDiscoveryClient{}
|
||||
|
|
Loading…
Reference in New Issue