code cleanup for kubectl config

pull/564/head
Pingan2017 2018-12-25 15:24:57 +08:00
parent 5252352ad8
commit 672cad60e9
5 changed files with 7 additions and 17 deletions

View File

@ -52,8 +52,7 @@ func NewCmdConfigCurrentContext(out io.Writer, configAccess clientcmd.ConfigAcce
Long: currentContextLong,
Example: currentContextExample,
Run: func(cmd *cobra.Command, args []string) {
err := RunCurrentContext(out, options)
cmdutil.CheckErr(err)
cmdutil.CheckErr(RunCurrentContext(out, options))
},
}

View File

@ -42,8 +42,7 @@ func NewCmdConfigDeleteCluster(out io.Writer, configAccess clientcmd.ConfigAcces
Long: "Delete the specified cluster from the kubeconfig",
Example: deleteClusterExample,
Run: func(cmd *cobra.Command, args []string) {
err := runDeleteCluster(out, configAccess, cmd)
cmdutil.CheckErr(err)
cmdutil.CheckErr(runDeleteCluster(out, configAccess, cmd))
},
}

View File

@ -42,8 +42,7 @@ func NewCmdConfigDeleteContext(out, errOut io.Writer, configAccess clientcmd.Con
Long: "Delete the specified context from the kubeconfig",
Example: deleteContextExample,
Run: func(cmd *cobra.Command, args []string) {
err := runDeleteContext(out, errOut, configAccess, cmd)
cmdutil.CheckErr(err)
cmdutil.CheckErr(runDeleteContext(out, errOut, configAccess, cmd))
},
}

View File

@ -42,8 +42,7 @@ func NewCmdConfigGetClusters(out io.Writer, configAccess clientcmd.ConfigAccess)
Long: "Display clusters defined in the kubeconfig.",
Example: getClustersExample,
Run: func(cmd *cobra.Command, args []string) {
err := runGetClusters(out, configAccess)
cmdutil.CheckErr(err)
cmdutil.CheckErr(runGetClusters(out, configAccess))
},
}

View File

@ -67,15 +67,9 @@ func NewCmdConfigRenameContext(out io.Writer, configAccess clientcmd.ConfigAcces
Long: renameContextLong,
Example: renameContextExample,
Run: func(cmd *cobra.Command, args []string) {
if err := options.Complete(cmd, args, out); err != nil {
cmdutil.CheckErr(err)
}
if err := options.Validate(); err != nil {
cmdutil.CheckErr(cmdutil.UsageErrorf(cmd, err.Error()))
}
if err := options.RunRenameContext(out); err != nil {
cmdutil.CheckErr(err)
}
cmdutil.CheckErr(options.Complete(cmd, args, out))
cmdutil.CheckErr(options.Validate())
cmdutil.CheckErr(options.RunRenameContext(out))
},
}
return cmd