mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #16058 from janetkuo/revert-kubectl-slash
Auto commit by PR queue bot
This commit is contained in:
commit
0884214fe0
@ -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 <group><syntax><resource>).
|
||||
// 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 {
|
||||
|
@ -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, ".")
|
||||
|
Loading…
Reference in New Issue
Block a user