Skip to content
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

use containing API group when resolving shortname from discovery #58741

Merged
merged 1 commit into from
Jan 25, 2018

Conversation

dixudx
Copy link
Member

@dixudx dixudx commented Jan 24, 2018

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:

use containing API group when resolving shortname from discovery

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jan 24, 2018
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 24, 2018
@dixudx
Copy link
Member Author

dixudx commented Jan 24, 2018

/kind bug
/area kubectl
/sig cli

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. area/kubectl sig/cli Categorizes an issue or PR as relevant to SIG CLI. labels Jan 24, 2018
@dixudx dixudx force-pushed the fix_kubectl_alias_group branch from 1b22e3b to d5facf7 Compare January 24, 2018 13:28
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 24, 2018
@@ -115,6 +115,9 @@ func (e shortcutExpander) expandResourceShortcut(resource schema.GroupVersionRes
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably add the same check if version is present and not equal

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, nevermind... version isn't in the shortcut mapping

@nikhita
Copy link
Member

nikhita commented Jan 24, 2018

@dixudx A test in shortcut_restmapper_test.go would be nice. :)

@@ -115,6 +115,9 @@ func (e shortcutExpander) expandResourceShortcut(resource schema.GroupVersionRes
}
if resource.Resource == item.ShortForm.Resource {
resource.Resource = item.LongForm.Resource
if len(resource.Group) == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should unconditionally set to item.LongForm.Group

@dixudx dixudx force-pushed the fix_kubectl_alias_group branch from d5facf7 to 97ec47b Compare January 25, 2018 02:17
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 25, 2018
@dixudx
Copy link
Member Author

dixudx commented Jan 25, 2018

@nikhita Tests have already been added. PTAL. Thanks.

/cc @kubernetes/sig-cli-pr-reviews

@liggitt
Copy link
Member

liggitt commented Jan 25, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 25, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dixudx, liggitt

Associated issue: #58695

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 /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 25, 2018
@k8s-github-robot
Copy link

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 here.

@k8s-github-robot k8s-github-robot merged commit 617c87b into kubernetes:master Jan 25, 2018
@dixudx dixudx deleted the fix_kubectl_alias_group branch January 26, 2018 02:47
yasker added a commit to yasker/longhorn-manager that referenced this pull request Jun 27, 2018
There is a bug before Kubernetes v1.10 that kubectl will incorrectly parse the
shorthand resource name without checking the full name. It can result in
`kubectl delete lhn --all` will be treated as `kubectl delete node --all`.

The bug is kubernetes/kubernetes#58741

The bug has been fixed since v1.10 release.
yasker added a commit to longhorn/longhorn-manager that referenced this pull request Jun 27, 2018
There is a bug before Kubernetes v1.10 that kubectl will incorrectly parse the
shorthand resource name without checking the full name. It can result in
`kubectl delete lhn --all` will be treated as `kubectl delete node --all`.

The bug is kubernetes/kubernetes#58741

The bug has been fixed since v1.10 release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubectl does not use containing API group when resolving shortname from discovery
5 participants