add example for kubectl config unset, this will help user use

This commit is contained in:
zhengjiajin 2017-11-11 09:50:09 +08:00
parent 97b28552be
commit 46f760e8d0

View File

@ -35,11 +35,20 @@ type unsetOptions struct {
propertyName string propertyName string
} }
var unset_long = templates.LongDesc(` var (
unsetLong = templates.LongDesc(`
Unsets an individual value in a kubeconfig file Unsets an individual value in a kubeconfig file
PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.`) PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.`)
unsetExample = templates.Examples(`
# Unset the current-context.
kubectl config unset current-context
# Unset namespace in foo context.
kubectl config unset contexts.foo.namespace`)
)
func NewCmdConfigUnset(out io.Writer, configAccess clientcmd.ConfigAccess) *cobra.Command { func NewCmdConfigUnset(out io.Writer, configAccess clientcmd.ConfigAccess) *cobra.Command {
options := &unsetOptions{configAccess: configAccess} options := &unsetOptions{configAccess: configAccess}
@ -47,7 +56,8 @@ func NewCmdConfigUnset(out io.Writer, configAccess clientcmd.ConfigAccess) *cobr
Use: "unset PROPERTY_NAME", Use: "unset PROPERTY_NAME",
DisableFlagsInUseLine: true, DisableFlagsInUseLine: true,
Short: i18n.T("Unsets an individual value in a kubeconfig file"), Short: i18n.T("Unsets an individual value in a kubeconfig file"),
Long: unset_long, Long: unsetLong,
Example: unsetExample,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
cmdutil.CheckErr(options.complete(cmd, args)) cmdutil.CheckErr(options.complete(cmd, args))
cmdutil.CheckErr(options.run(out)) cmdutil.CheckErr(options.run(out))