Remove rootCommand.Cluster()

This commit is contained in:
John Gardiner Myers 2021-07-27 22:20:40 -07:00
parent 825b8d476a
commit 4174430728
2 changed files with 3 additions and 16 deletions

View File

@ -302,15 +302,6 @@ func (c *RootCmd) Clientset() (simple.Clientset, error) {
return c.factory.Clientset()
}
func (c *RootCmd) Cluster(ctx context.Context) (*kopsapi.Cluster, error) {
clusterName := c.ClusterName(true)
if clusterName == "" {
return nil, fmt.Errorf("--name is required")
}
return GetCluster(ctx, c.factory, clusterName)
}
func GetCluster(ctx context.Context, factory commandutils.Factory, clusterName string) (*kopsapi.Cluster, error) {
if clusterName == "" {
return nil, field.Required(field.NewPath("clusterName"), "Cluster name is required")

View File

@ -235,7 +235,7 @@ func NewCmdToolboxInstanceSelector(f *util.Factory, out io.Writer) *cobra.Comman
// RunToolboxInstanceSelector executes the instance-selector tool to create instance groups with declarative resource specifications
func RunToolboxInstanceSelector(ctx context.Context, f *util.Factory, out io.Writer, commandline *cli.CommandLineInterface, options *InstanceSelectorOptions) error {
clientset, cluster, channel, err := retrieveClusterRefs(ctx, f)
clientset, cluster, channel, err := retrieveClusterRefs(ctx, f, options.ClusterName)
if err != nil {
return err
}
@ -373,21 +373,17 @@ func processAndValidateFlags(commandline *cli.CommandLineInterface) error {
return nil
}
func retrieveClusterRefs(ctx context.Context, f *util.Factory) (simple.Clientset, *kops.Cluster, *kops.Channel, error) {
func retrieveClusterRefs(ctx context.Context, f *util.Factory, clusterName string) (simple.Clientset, *kops.Cluster, *kops.Channel, error) {
clientset, err := f.Clientset()
if err != nil {
return nil, nil, nil, err
}
cluster, err := rootCommand.Cluster(ctx)
cluster, err := GetCluster(ctx, f, clusterName)
if err != nil {
return nil, nil, nil, err
}
if cluster == nil {
return nil, nil, nil, fmt.Errorf("cluster not found")
}
channel, err := cloudup.ChannelForCluster(cluster)
if err != nil {
return nil, nil, nil, err