Merge pull request #75874 from SataQiu/refactor-kubeadm-20190329

Refactor code about setting KubernetesVersionFlag
k3s-v1.15.3
Kubernetes Prow Robot 2019-03-29 23:53:33 -07:00 committed by GitHub
commit 214340256f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 8 deletions

View File

@ -514,10 +514,7 @@ func (i *ImagesList) Run(out io.Writer) error {
// AddImagesCommonConfigFlags adds the flags that configure kubeadm (and affect the images kubeadm will use)
func AddImagesCommonConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta1.InitConfiguration, cfgPath *string, featureGatesString *string) {
flagSet.StringVar(
&cfg.ClusterConfiguration.KubernetesVersion, "kubernetes-version", cfg.ClusterConfiguration.KubernetesVersion,
`Choose a specific Kubernetes version for the control plane.`,
)
options.AddKubernetesVersionFlag(flagSet, &cfg.ClusterConfiguration.KubernetesVersion)
options.AddFeatureGatesStringFlag(flagSet, featureGatesString)
flagSet.StringVar(cfgPath, "config", *cfgPath, "Path to kubeadm config file.")
}

View File

@ -217,10 +217,9 @@ func AddInitConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta1.InitConfig
&cfg.Networking.DNSDomain, options.NetworkingDNSDomain, cfg.Networking.DNSDomain,
`Use alternative domain for services, e.g. "myorg.internal".`,
)
flagSet.StringVar(
&cfg.KubernetesVersion, options.KubernetesVersion, cfg.KubernetesVersion,
`Choose a specific Kubernetes version for the control plane.`,
)
options.AddKubernetesVersionFlag(flagSet, &cfg.KubernetesVersion)
flagSet.StringVar(
&cfg.CertificatesDir, options.CertificatesDir, cfg.CertificatesDir,
`The path where to save and store the certificates.`,

View File

@ -72,3 +72,11 @@ func AddFeatureGatesStringFlag(fs *pflag.FlagSet, featureGatesString *string) {
"No feature gates are available in this release.")
}
}
// AddKubernetesVersionFlag adds the --kubernetes-version flag to the given flagset
func AddKubernetesVersionFlag(fs *pflag.FlagSet, kubernetesVersion *string) {
fs.StringVar(
kubernetesVersion, KubernetesVersion, *kubernetesVersion,
`Choose a specific Kubernetes version for the control plane.`,
)
}