Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

honor --image-repository even if --image-mirror-country is set #8249

Merged
merged 1 commit into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func ClusterFlagValue() string {

// 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) {
cc := config.ClusterConfig{}
var cc config.ClusterConfig
if existing != nil { // create profile config first time
cc = updateExistingConfigFromFlags(cmd, existing)
} else {
Expand Down Expand Up @@ -242,10 +242,6 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
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.
selectedEnableDefaultCNI := viper.GetBool(enableDefaultCNI)
selectedNetworkPlugin := viper.GetString(networkPlugin)
Expand All @@ -258,7 +254,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k

repository := viper.GetString(imageRepository)
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)))
if err != nil {
exit.WithError("Failed to check main repository and mirrors for images", err)
Expand Down
15 changes: 15 additions & 0 deletions cmd/minikube/cmd/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ func TestMirrorCountry(t *testing.T) {
imageRepository: "",
mirrorCountry: "",
},
{
description: "image-repository none, image-mirror-country china",
imageRepository: "",
mirrorCountry: "cn",
},
{
description: "image-repository auto, image-mirror-country none",
imageRepository: "auto",
Expand All @@ -107,6 +112,16 @@ func TestMirrorCountry(t *testing.T) {
imageRepository: "auto",
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 {
Expand Down