Merge pull request #11988 from johngmyers/fix-export

Fix "kops export kubeconfig"
This commit is contained in:
Kubernetes Prow Robot 2021-07-13 22:48:26 -07:00 committed by GitHub
commit 963149791f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 10 deletions

View File

@ -76,16 +76,17 @@ func NewCmdExportKubeconfig(f *util.Factory, out io.Writer) *cobra.Command {
Long: exportKubeconfigLong,
Example: exportKubeconfigExample,
Args: func(cmd *cobra.Command, args []string) error {
if options.admin != 0 && options.user != "" {
return fmt.Errorf("cannot use both --admin and --user")
}
if options.all {
if len(args) != 0 {
return fmt.Errorf("cannot use both --all flag and positional arguments")
}
return nil
} else {
return rootCommand.clusterNameArgs(&options.ClusterName)(cmd, args)
}
if options.admin != 0 && options.user != "" {
return fmt.Errorf("cannot use both --admin and --user")
}
return rootCommand.clusterNameArgs(&options.ClusterName)(cmd, args)
},
ValidArgsFunction: commandutils.CompleteClusterName(&rootCommand, true),
RunE: func(cmd *cobra.Command, args []string) error {
@ -121,11 +122,7 @@ func RunExportKubeconfig(ctx context.Context, f *util.Factory, out io.Writer, op
clusterList = append(clusterList, &list.Items[i])
}
} else {
err := rootCommand.ProcessArgs(args)
if err != nil {
return err
}
cluster, err := rootCommand.Cluster(ctx)
cluster, err := GetCluster(ctx, f, options.ClusterName)
if err != nil {
return err
}