mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #79979 from SataQiu/cleanup-kubeadm-20190710
kubeadm: cleanup code about cobra
This commit is contained in:
commit
e3a125a64e
@ -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.",
|
||||
)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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.",
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user