Merge pull request #8249 from SataQiu/fix-20200522
honor --image-repository even if --image-mirror-country is setpull/8323/head
commit
a9359c0ba1
|
@ -211,7 +211,7 @@ func ClusterFlagValue() string {
|
||||||
|
|
||||||
// generateClusterConfig generate a config.ClusterConfig based on flags or existing cluster config
|
// generateClusterConfig generate a config.ClusterConfig based on flags or existing cluster config
|
||||||
func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k8sVersion string, drvName string) (config.ClusterConfig, config.Node, error) {
|
func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k8sVersion string, drvName string) (config.ClusterConfig, config.Node, error) {
|
||||||
cc := config.ClusterConfig{}
|
var cc config.ClusterConfig
|
||||||
if existing != nil { // create profile config first time
|
if existing != nil { // create profile config first time
|
||||||
cc = updateExistingConfigFromFlags(cmd, existing)
|
cc = updateExistingConfigFromFlags(cmd, existing)
|
||||||
} else {
|
} else {
|
||||||
|
@ -242,10 +242,6 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
|
||||||
return cc, config.Node{}, errors.Wrap(err, "new runtime manager")
|
return cc, config.Node{}, errors.Wrap(err, "new runtime manager")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Flags().Changed(imageRepository) {
|
|
||||||
cc.KubernetesConfig.ImageRepository = viper.GetString(imageRepository)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pick good default values for --network-plugin and --enable-default-cni based on runtime.
|
// Pick good default values for --network-plugin and --enable-default-cni based on runtime.
|
||||||
selectedEnableDefaultCNI := viper.GetBool(enableDefaultCNI)
|
selectedEnableDefaultCNI := viper.GetBool(enableDefaultCNI)
|
||||||
selectedNetworkPlugin := viper.GetString(networkPlugin)
|
selectedNetworkPlugin := viper.GetString(networkPlugin)
|
||||||
|
@ -258,7 +254,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
|
||||||
|
|
||||||
repository := viper.GetString(imageRepository)
|
repository := viper.GetString(imageRepository)
|
||||||
mirrorCountry := strings.ToLower(viper.GetString(imageMirrorCountry))
|
mirrorCountry := strings.ToLower(viper.GetString(imageMirrorCountry))
|
||||||
if strings.ToLower(repository) == "auto" || mirrorCountry != "" {
|
if strings.ToLower(repository) == "auto" || (mirrorCountry != "" && repository == "") {
|
||||||
found, autoSelectedRepository, err := selectImageRepository(mirrorCountry, semver.MustParse(strings.TrimPrefix(k8sVersion, version.VersionPrefix)))
|
found, autoSelectedRepository, err := selectImageRepository(mirrorCountry, semver.MustParse(strings.TrimPrefix(k8sVersion, version.VersionPrefix)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("Failed to check main repository and mirrors for images", err)
|
exit.WithError("Failed to check main repository and mirrors for images", err)
|
||||||
|
|
|
@ -97,6 +97,11 @@ func TestMirrorCountry(t *testing.T) {
|
||||||
imageRepository: "",
|
imageRepository: "",
|
||||||
mirrorCountry: "",
|
mirrorCountry: "",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "image-repository none, image-mirror-country china",
|
||||||
|
imageRepository: "",
|
||||||
|
mirrorCountry: "cn",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: "image-repository auto, image-mirror-country none",
|
description: "image-repository auto, image-mirror-country none",
|
||||||
imageRepository: "auto",
|
imageRepository: "auto",
|
||||||
|
@ -107,6 +112,16 @@ func TestMirrorCountry(t *testing.T) {
|
||||||
imageRepository: "auto",
|
imageRepository: "auto",
|
||||||
mirrorCountry: "cn",
|
mirrorCountry: "cn",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "image-repository registry.test.com, image-mirror-country none",
|
||||||
|
imageRepository: "registry.test.com",
|
||||||
|
mirrorCountry: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "image-repository registry.test.com, image-mirror-country china",
|
||||||
|
imageRepository: "registry.test.com",
|
||||||
|
mirrorCountry: "cn",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
Loading…
Reference in New Issue