Skip to content

Commit e3a125a

Browse files
authored
Merge pull request kubernetes#79979 from SataQiu/cleanup-kubeadm-20190710
kubeadm: cleanup code about cobra
2 parents e2b21c8 + b837f8d commit e3a125a

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

cmd/kubeadm/app/cmd/cmd.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121

2222
"github.com/lithammer/dedent"
2323
"github.com/spf13/cobra"
24-
"github.com/spf13/pflag"
2524
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/alpha"
25+
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
2626
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/upgrade"
2727
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
2828
// Register the kubeadm configuration types because CLI flag generation
@@ -90,15 +90,7 @@ func NewKubeadmCommand(in io.Reader, out, err io.Writer) *cobra.Command {
9090
cmds.AddCommand(upgrade.NewCmdUpgrade(out))
9191
cmds.AddCommand(alpha.NewCmdAlpha(in, out))
9292

93-
AddKubeadmOtherFlags(cmds.PersistentFlags(), &rootfsPath)
93+
options.AddKubeadmOtherFlags(cmds.PersistentFlags(), &rootfsPath)
9494

9595
return cmds
9696
}
97-
98-
// AddKubeadmOtherFlags adds flags that are not bound to a configuration file to the given flagset
99-
func AddKubeadmOtherFlags(flagSet *pflag.FlagSet, rootfsPath *string) {
100-
flagSet.StringVar(
101-
rootfsPath, "rootfs", *rootfsPath,
102-
"[EXPERIMENTAL] The path to the 'real' host root filesystem.",
103-
)
104-
}

cmd/kubeadm/app/cmd/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,5 +538,5 @@ func AddImagesCommonConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta2.Cl
538538
options.AddKubernetesVersionFlag(flagSet, &cfg.KubernetesVersion)
539539
options.AddFeatureGatesStringFlag(flagSet, featureGatesString)
540540
options.AddImageMetaFlags(flagSet, &cfg.ImageRepository)
541-
flagSet.StringVar(cfgPath, "config", *cfgPath, "Path to kubeadm config file.")
541+
options.AddConfigFlag(flagSet, cfgPath)
542542
}

cmd/kubeadm/app/cmd/options/generic.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,11 @@ func AddKubernetesVersionFlag(fs *pflag.FlagSet, kubernetesVersion *string) {
8080
`Choose a specific Kubernetes version for the control plane.`,
8181
)
8282
}
83+
84+
// AddKubeadmOtherFlags adds flags that are not bound to a configuration file to the given flagset
85+
func AddKubeadmOtherFlags(flagSet *pflag.FlagSet, rootfsPath *string) {
86+
flagSet.StringVar(
87+
rootfsPath, "rootfs", *rootfsPath,
88+
"[EXPERIMENTAL] The path to the 'real' host root filesystem.",
89+
)
90+
}

0 commit comments

Comments
 (0)