mirror of https://github.com/kubernetes/kops.git
Fix completion of instancegroups when cluster argument provided
This commit is contained in:
parent
13bfa283cf
commit
dbf4f23654
|
@ -270,7 +270,7 @@ func completeCreateKeyset(options *CreateKeypairOptions, args []string, toComple
|
|||
commandutils.ConfigureKlogForCompletion()
|
||||
ctx := context.TODO()
|
||||
|
||||
cluster, clientSet, completions, directive := GetClusterForCompletion(ctx, &rootCommand, "")
|
||||
cluster, clientSet, completions, directive := GetClusterForCompletion(ctx, &rootCommand, nil)
|
||||
if cluster == nil {
|
||||
return completions, directive
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ func completeDistrustKeyset(options *DistrustKeypairOptions, args []string, toCo
|
|||
commandutils.ConfigureKlogForCompletion()
|
||||
ctx := context.TODO()
|
||||
|
||||
cluster, clientSet, completions, directive := GetClusterForCompletion(ctx, &rootCommand, "")
|
||||
cluster, clientSet, completions, directive := GetClusterForCompletion(ctx, &rootCommand, nil)
|
||||
if cluster == nil {
|
||||
return completions, directive
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ func completeGetKeypairs(options *GetKeypairsOptions, args []string, toComplete
|
|||
commandutils.ConfigureKlogForCompletion()
|
||||
ctx := context.TODO()
|
||||
|
||||
cluster, clientSet, completions, directive := GetClusterForCompletion(ctx, &rootCommand, "")
|
||||
cluster, clientSet, completions, directive := GetClusterForCompletion(ctx, &rootCommand, nil)
|
||||
if cluster == nil {
|
||||
return completions, directive
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ func completePromoteKeyset(options *PromoteKeypairOptions, args []string, toComp
|
|||
commandutils.ConfigureKlogForCompletion()
|
||||
ctx := context.TODO()
|
||||
|
||||
cluster, clientSet, completions, directive := GetClusterForCompletion(ctx, &rootCommand, "")
|
||||
cluster, clientSet, completions, directive := GetClusterForCompletion(ctx, &rootCommand, nil)
|
||||
if cluster == nil {
|
||||
return completions, directive
|
||||
}
|
||||
|
|
|
@ -434,7 +434,7 @@ func completeInstanceGroup(options *RollingUpdateOptions) func(cmd *cobra.Comman
|
|||
commandutils.ConfigureKlogForCompletion()
|
||||
ctx := context.TODO()
|
||||
|
||||
cluster, clientSet, completions, directive := GetClusterForCompletion(ctx, &rootCommand, options.ClusterName)
|
||||
cluster, clientSet, completions, directive := GetClusterForCompletion(ctx, &rootCommand, args)
|
||||
if cluster == nil {
|
||||
return completions, directive
|
||||
}
|
||||
|
|
|
@ -317,8 +317,12 @@ func GetCluster(ctx context.Context, factory commandutils.Factory, clusterName s
|
|||
return cluster, nil
|
||||
}
|
||||
|
||||
func GetClusterForCompletion(ctx context.Context, factory commandutils.Factory, clusterName string) (cluster *kopsapi.Cluster, clientSet simple.Clientset, completions []string, directive cobra.ShellCompDirective) {
|
||||
if clusterName == "" {
|
||||
func GetClusterForCompletion(ctx context.Context, factory commandutils.Factory, clusterArgs []string) (cluster *kopsapi.Cluster, clientSet simple.Clientset, completions []string, directive cobra.ShellCompDirective) {
|
||||
clusterName := ""
|
||||
|
||||
if len(clusterArgs) > 0 {
|
||||
clusterName = clusterArgs[0]
|
||||
} else {
|
||||
clusterName = rootCommand.ClusterName(false)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue