diff --git a/pkg/kubectl/cmd/explain.go b/pkg/kubectl/cmd/explain.go index 94abb923de6..0e13beaf509 100644 --- a/pkg/kubectl/cmd/explain.go +++ b/pkg/kubectl/cmd/explain.go @@ -72,17 +72,18 @@ func RunExplain(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st apiV := cmdutil.GetFlagString(cmd, "api-version") mapper, _ := f.Object() - group, inModel, fieldsPath, err := kubectl.SplitAndParseResourceRequest(args[0], mapper) + // TODO: After we figured out the new syntax to separate group and resource, allow + // the users to use it in explain (kubectl explain ). + // Refer to issue #16039 for why we do this. Refer to PR #15808 that used "/" syntax. + inModel, fieldsPath, err := kubectl.SplitAndParseResourceRequest(args[0], mapper) if err != nil { return err } - if len(group) == 0 { - // TODO: We should deduce the group for a resource by discovering the supported resources at server. - group, err = mapper.GroupForResource(inModel) - if err != nil { - return err - } + // TODO: We should deduce the group for a resource by discovering the supported resources at server. + group, err := mapper.GroupForResource(inModel) + if err != nil { + return err } if len(apiV) == 0 { diff --git a/pkg/kubectl/explain.go b/pkg/kubectl/explain.go index fa8da7834b1..ef7cd8ddb0b 100644 --- a/pkg/kubectl/explain.go +++ b/pkg/kubectl/explain.go @@ -41,11 +41,10 @@ func GetSwaggerSchema(apiVer string, kubeClient client.Interface) (*swagger.ApiD } // SplitAndParseResourceRequest separates the users input into a model and fields -func SplitAndParseResourceRequest(inResource string, mapper meta.RESTMapper) (string, string, []string, error) { +func SplitAndParseResourceRequest(inResource string, mapper meta.RESTMapper) (string, []string, error) { inResource, fieldsPath := splitDotNotation(inResource) - group, inResource := splitGroupFromResource(inResource) inResource, _ = mapper.ResourceSingularizer(expandResourceShortcut(inResource)) - return group, inResource, fieldsPath, nil + return inResource, fieldsPath, nil } // PrintModelDescription prints the description of a specific model or dot path @@ -86,15 +85,6 @@ func PrintModelDescription(inModel string, fieldsPath []string, w io.Writer, swa return printModelInfo(w, pointedModel, pointedModelAsProp) } -func splitGroupFromResource(resource string) (string, string) { - seg := strings.SplitN(resource, "/", 2) - if len(seg) == 1 { - return "", seg[0] - } else { - return seg[0], seg[1] - } -} - func splitDotNotation(model string) (string, []string) { var fieldsPath []string dotModel := strings.Split(model, ".")