Merge pull request #79979 from SataQiu/cleanup-kubeadm-20190710

kubeadm: cleanup code about cobra
This commit is contained in:
Kubernetes Prow Robot 2019-07-10 13:58:40 -07:00 committed by GitHub
commit e3a125a64e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 11 deletions

View File

@ -21,8 +21,8 @@ import (
"github.com/lithammer/dedent"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/alpha"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/upgrade"
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
// Register the kubeadm configuration types because CLI flag generation
@ -90,15 +90,7 @@ func NewKubeadmCommand(in io.Reader, out, err io.Writer) *cobra.Command {
cmds.AddCommand(upgrade.NewCmdUpgrade(out))
cmds.AddCommand(alpha.NewCmdAlpha(in, out))
AddKubeadmOtherFlags(cmds.PersistentFlags(), &rootfsPath)
options.AddKubeadmOtherFlags(cmds.PersistentFlags(), &rootfsPath)
return cmds
}
// AddKubeadmOtherFlags adds flags that are not bound to a configuration file to the given flagset
func AddKubeadmOtherFlags(flagSet *pflag.FlagSet, rootfsPath *string) {
flagSet.StringVar(
rootfsPath, "rootfs", *rootfsPath,
"[EXPERIMENTAL] The path to the 'real' host root filesystem.",
)
}

View File

@ -538,5 +538,5 @@ func AddImagesCommonConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta2.Cl
options.AddKubernetesVersionFlag(flagSet, &cfg.KubernetesVersion)
options.AddFeatureGatesStringFlag(flagSet, featureGatesString)
options.AddImageMetaFlags(flagSet, &cfg.ImageRepository)
flagSet.StringVar(cfgPath, "config", *cfgPath, "Path to kubeadm config file.")
options.AddConfigFlag(flagSet, cfgPath)
}

View File

@ -80,3 +80,11 @@ func AddKubernetesVersionFlag(fs *pflag.FlagSet, kubernetesVersion *string) {
`Choose a specific Kubernetes version for the control plane.`,
)
}
// AddKubeadmOtherFlags adds flags that are not bound to a configuration file to the given flagset
func AddKubeadmOtherFlags(flagSet *pflag.FlagSet, rootfsPath *string) {
flagSet.StringVar(
rootfsPath, "rootfs", *rootfsPath,
"[EXPERIMENTAL] The path to the 'real' host root filesystem.",
)
}