Merge pull request #111689 from ardaguclu/use-restgetter-clusterinfo
(kubectl cluster-info): Move towards RESTClientGetter instead cmdutil.Factory Kubernetes-commit: f51d934aed721a0cdb169c0f61bcbf18bd138a69
This commit is contained in:
commit
35125e2226
|
@ -55,7 +55,7 @@ type ClusterInfoOptions struct {
|
||||||
Client *restclient.Config
|
Client *restclient.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCmdClusterInfo(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
|
func NewCmdClusterInfo(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericclioptions.IOStreams) *cobra.Command {
|
||||||
o := &ClusterInfoOptions{
|
o := &ClusterInfoOptions{
|
||||||
IOStreams: ioStreams,
|
IOStreams: ioStreams,
|
||||||
}
|
}
|
||||||
|
@ -66,17 +66,17 @@ func NewCmdClusterInfo(f cmdutil.Factory, ioStreams genericclioptions.IOStreams)
|
||||||
Long: longDescr,
|
Long: longDescr,
|
||||||
Example: clusterinfoExample,
|
Example: clusterinfoExample,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cmdutil.CheckErr(o.Complete(f, cmd))
|
cmdutil.CheckErr(o.Complete(restClientGetter, cmd))
|
||||||
cmdutil.CheckErr(o.Run())
|
cmdutil.CheckErr(o.Run())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.AddCommand(NewCmdClusterInfoDump(f, ioStreams))
|
cmd.AddCommand(NewCmdClusterInfoDump(restClientGetter, ioStreams))
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ClusterInfoOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
|
func (o *ClusterInfoOptions) Complete(restClientGetter genericclioptions.RESTClientGetter, cmd *cobra.Command) error {
|
||||||
var err error
|
var err error
|
||||||
o.Client, err = f.ToRESTConfig()
|
o.Client, err = restClientGetter.ToRESTConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ func (o *ClusterInfoOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) err
|
||||||
}
|
}
|
||||||
o.Namespace = cmdNamespace
|
o.Namespace = cmdNamespace
|
||||||
|
|
||||||
o.Builder = f.NewBuilder()
|
o.Builder = resource.NewBuilder(restClientGetter)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ type ClusterInfoDumpOptions struct {
|
||||||
genericclioptions.IOStreams
|
genericclioptions.IOStreams
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCmdClusterInfoDump(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
|
func NewCmdClusterInfoDump(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericclioptions.IOStreams) *cobra.Command {
|
||||||
o := &ClusterInfoDumpOptions{
|
o := &ClusterInfoDumpOptions{
|
||||||
PrintFlags: genericclioptions.NewPrintFlags("").WithTypeSetter(scheme.Scheme).WithDefaultOutput("json"),
|
PrintFlags: genericclioptions.NewPrintFlags("").WithTypeSetter(scheme.Scheme).WithDefaultOutput("json"),
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ func NewCmdClusterInfoDump(f cmdutil.Factory, ioStreams genericclioptions.IOStre
|
||||||
Long: dumpLong,
|
Long: dumpLong,
|
||||||
Example: dumpExample,
|
Example: dumpExample,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cmdutil.CheckErr(o.Complete(f, cmd))
|
cmdutil.CheckErr(o.Complete(restClientGetter, cmd))
|
||||||
cmdutil.CheckErr(o.Run())
|
cmdutil.CheckErr(o.Run())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ func setupOutputWriter(dir string, defaultWriter io.Writer, filename string, fil
|
||||||
return file
|
return file
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ClusterInfoDumpOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
|
func (o *ClusterInfoDumpOptions) Complete(restClientGetter genericclioptions.RESTClientGetter, cmd *cobra.Command) error {
|
||||||
printer, err := o.PrintFlags.ToPrinter()
|
printer, err := o.PrintFlags.ToPrinter()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -134,7 +134,7 @@ func (o *ClusterInfoDumpOptions) Complete(f cmdutil.Factory, cmd *cobra.Command)
|
||||||
|
|
||||||
o.PrintObj = printer.PrintObj
|
o.PrintObj = printer.PrintObj
|
||||||
|
|
||||||
config, err := f.ToRESTConfig()
|
config, err := restClientGetter.ToRESTConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -154,12 +154,12 @@ func (o *ClusterInfoDumpOptions) Complete(f cmdutil.Factory, cmd *cobra.Command)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
o.Namespace, _, err = f.ToRawKubeConfigLoader().Namespace()
|
o.Namespace, _, err = restClientGetter.ToRawKubeConfigLoader().Namespace()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// TODO this should eventually just be the completed kubeconfigflag struct
|
|
||||||
o.RESTClientGetter = f
|
o.RESTClientGetter = restClientGetter
|
||||||
o.LogsForObject = polymorphichelpers.LogsForObjectFn
|
o.LogsForObject = polymorphichelpers.LogsForObjectFn
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue