mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Allow api-resources to return cached data
This commit is contained in:
parent
74b7cec0c6
commit
918df97a0f
@ -59,6 +59,7 @@ type ApiResourcesOptions struct {
|
|||||||
Namespaced bool
|
Namespaced bool
|
||||||
Verbs []string
|
Verbs []string
|
||||||
NoHeaders bool
|
NoHeaders bool
|
||||||
|
Cached bool
|
||||||
|
|
||||||
genericclioptions.IOStreams
|
genericclioptions.IOStreams
|
||||||
}
|
}
|
||||||
@ -94,6 +95,7 @@ func NewCmdApiResources(f cmdutil.Factory, ioStreams genericclioptions.IOStreams
|
|||||||
cmd.Flags().StringVar(&o.APIGroup, "api-group", "", "Limit to resources in the specified API group.")
|
cmd.Flags().StringVar(&o.APIGroup, "api-group", "", "Limit to resources in the specified API group.")
|
||||||
cmd.Flags().BoolVar(&o.Namespaced, "namespaced", true, "Namespaced indicates if a resource is namespaced or not.")
|
cmd.Flags().BoolVar(&o.Namespaced, "namespaced", true, "Namespaced indicates if a resource is namespaced or not.")
|
||||||
cmd.Flags().StringSliceVar(&o.Verbs, "verbs", o.Verbs, "Limit to resources that support the specified verbs.")
|
cmd.Flags().StringSliceVar(&o.Verbs, "verbs", o.Verbs, "Limit to resources that support the specified verbs.")
|
||||||
|
cmd.Flags().BoolVar(&o.Cached, "cached", o.Cached, "Use the cached list of resources if available.")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,8 +127,10 @@ func (o *ApiResourcesOptions) RunApiResources(cmd *cobra.Command, f cmdutil.Fact
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !o.Cached {
|
||||||
// Always request fresh data from the server
|
// Always request fresh data from the server
|
||||||
discoveryclient.Invalidate()
|
discoveryclient.Invalidate()
|
||||||
|
}
|
||||||
|
|
||||||
lists, err := discoveryclient.ServerPreferredResources()
|
lists, err := discoveryclient.ServerPreferredResources()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user