mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #95253 from sallyom/apigroup-version-output-api-resources
include APIVersion in output of 'kubectl api-resources'
This commit is contained in:
commit
838e7bb278
@ -71,8 +71,9 @@ type APIResourceOptions struct {
|
|||||||
|
|
||||||
// groupResource contains the APIGroup and APIResource
|
// groupResource contains the APIGroup and APIResource
|
||||||
type groupResource struct {
|
type groupResource struct {
|
||||||
APIGroup string
|
APIGroup string
|
||||||
APIResource metav1.APIResource
|
APIGroupVersion string
|
||||||
|
APIResource metav1.APIResource
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAPIResourceOptions creates the options for APIResource
|
// NewAPIResourceOptions creates the options for APIResource
|
||||||
@ -184,8 +185,9 @@ func (o *APIResourceOptions) RunAPIResources(cmd *cobra.Command, f cmdutil.Facto
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
resources = append(resources, groupResource{
|
resources = append(resources, groupResource{
|
||||||
APIGroup: gv.Group,
|
APIGroup: gv.Group,
|
||||||
APIResource: resource,
|
APIGroupVersion: gv.String(),
|
||||||
|
APIResource: resource,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,7 +213,7 @@ func (o *APIResourceOptions) RunAPIResources(cmd *cobra.Command, f cmdutil.Facto
|
|||||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%v\t%s\t%v\n",
|
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%v\t%s\t%v\n",
|
||||||
r.APIResource.Name,
|
r.APIResource.Name,
|
||||||
strings.Join(r.APIResource.ShortNames, ","),
|
strings.Join(r.APIResource.ShortNames, ","),
|
||||||
r.APIGroup,
|
r.APIGroupVersion,
|
||||||
r.APIResource.Namespaced,
|
r.APIResource.Namespaced,
|
||||||
r.APIResource.Kind,
|
r.APIResource.Kind,
|
||||||
r.APIResource.Verbs); err != nil {
|
r.APIResource.Verbs); err != nil {
|
||||||
@ -221,7 +223,7 @@ func (o *APIResourceOptions) RunAPIResources(cmd *cobra.Command, f cmdutil.Facto
|
|||||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%v\t%s\n",
|
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%v\t%s\n",
|
||||||
r.APIResource.Name,
|
r.APIResource.Name,
|
||||||
strings.Join(r.APIResource.ShortNames, ","),
|
strings.Join(r.APIResource.ShortNames, ","),
|
||||||
r.APIGroup,
|
r.APIGroupVersion,
|
||||||
r.APIResource.Namespaced,
|
r.APIResource.Namespaced,
|
||||||
r.APIResource.Kind); err != nil {
|
r.APIResource.Kind); err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
@ -236,7 +238,7 @@ func (o *APIResourceOptions) RunAPIResources(cmd *cobra.Command, f cmdutil.Facto
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printContextHeaders(out io.Writer, output string) error {
|
func printContextHeaders(out io.Writer, output string) error {
|
||||||
columnNames := []string{"NAME", "SHORTNAMES", "APIGROUP", "NAMESPACED", "KIND"}
|
columnNames := []string{"NAME", "SHORTNAMES", "APIVERSION", "NAMESPACED", "KIND"}
|
||||||
if output == "wide" {
|
if output == "wide" {
|
||||||
columnNames = append(columnNames, "VERBS")
|
columnNames = append(columnNames, "VERBS")
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ func NewCmdExplain(parent string, f cmdutil.Factory, streams genericclioptions.I
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.Flags().BoolVar(&o.Recursive, "recursive", o.Recursive, "Print the fields of fields (Currently only 1 level deep)")
|
cmd.Flags().BoolVar(&o.Recursive, "recursive", o.Recursive, "Print the fields of fields (Currently only 1 level deep)")
|
||||||
cmd.Flags().StringVar(&o.APIVersion, "api-version", o.APIVersion, "Get different explanations for particular API version")
|
cmd.Flags().StringVar(&o.APIVersion, "api-version", o.APIVersion, "Get different explanations for particular API version (API group/version)")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user