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
"kubectl explain" should be able to explain "apiservices" and "customresourcedefinition" #49465
Comments
/cc |
@kubernetes/sig-cli-bugs |
@xiangpengzhao: Reiterating the mentions to trigger a notification: In response to this:
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. |
cc @mbohlool |
This look like a problem with old swagger 1.2. We do not aggregate swagger 1.2 spec. When kubectl move to OpenAPI, it should by fix this by design. |
Automatic merge from submit-queue (batch tested with PRs 53228, 53232, 53353). 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>. Openapi explain **What this PR does / why we need it**: This rewrites `kubectl explain` but using openapi rather than swagger 1.2. Also removes the former code. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #49465, fixes partially #44589, fixes partially #38637 **Special notes for your reviewer**: FYI @mbohlool **Release note**: ```release-note `kubectl explain` now uses openapi rather than swagger 1.2. ```
This is still not fixed (even after kubectl moving to OpenAPI). There are two problems here:
--- a/pkg/kubectl/cmd/explain.go
+++ b/pkg/kubectl/cmd/explain.go
@@ -26,7 +26,6 @@ import (
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/explain"
- "k8s.io/kubernetes/pkg/kubectl/scheme"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
)
@@ -91,7 +90,6 @@ func RunExplain(f cmdutil.Factory, out, cmdErr io.Writer, cmd *cobra.Command, ar
return err
}
- // TODO: We should deduce the group for a resource by discovering the supported resources at server.
fullySpecifiedGVR, groupResource := schema.ParseResourceArg(inModel)
gvk := schema.GroupVersionKind{}
if fullySpecifiedGVR != nil {
@@ -104,20 +102,12 @@ func RunExplain(f cmdutil.Factory, out, cmdErr io.Writer, cmd *cobra.Command, ar
}
}
- if len(apiVersionString) == 0 {
- groupMeta, err := scheme.Registry.Group(gvk.Group)
- if err != nil {
- return err
- }
- apiVersion = groupMeta.GroupVersion
-
- } else {
- apiVersion, err = schema.ParseGroupVersion(apiVersionString)
- if err != nil {
+ if len(apiVersionString) != 0 {
+ if apiVersion, err = schema.ParseGroupVersion(apiVersionString); err != nil {
return err
}
+ gvk = apiVersion.WithKind(gvk.Kind)
}
- gvk = apiVersion.WithKind(gvk.Kind)
resources, err := f.OpenAPISchema()
if err != nil { However, after this it gives:
kubectl explain looks up the gvk of the resource in question from a list of resources: kubernetes/pkg/kubectl/cmd/util/openapi/openapi.go Lines 71 to 77 in ff626a3
It gets the gvk here:
kubernetes/pkg/kubectl/cmd/util/openapi/openapi.go Lines 83 to 87 in ff626a3
Here, However, we do not generate /reopen |
@nikhita: you can't re-open an issue/PR unless you authored it or you are assigned to it. In response to this:
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. |
/reopen |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
Looks like the blocker was fixed in #64174 🎉 I will move forward with the fix. |
/assign |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
fixed in 1.11 in #64174 |
Is this a BUG REPORT or FEATURE REQUEST?:
/kind bug
What happened:
What you expected to happen:
kubectl explain
should be able to explain the above two resources.Print something as below, etc.
How to reproduce it (as minimally and precisely as possible):
Run the commands above.
Anything else we need to know?:
/sig cli
/sig api-machinery
Environment:
kubectl version
): a9bf441uname -a
):The text was updated successfully, but these errors were encountered: