Merge pull request #12942 from klaases/go5

Exit if --kubernetes-version and --no-kubernetes are specified.
pull/13001/head
Medya Ghazizadeh 2021-11-22 10:01:21 -08:00 committed by GitHub
commit 119a0f07d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -1546,6 +1546,14 @@ func isBaseImageApplicable(drv string) bool {
func getKubernetesVersion(old *config.ClusterConfig) string {
if viper.GetBool(noKubernetes) {
// Exit if --kubernetes-version is specified.
if viper.GetString(kubernetesVersion) != "" {
exit.Message(reason.Usage, `cannot specify --kubernetes-version with --no-kubernetes,
to unset a global config run:
$ minikube config unset kubernetes-version`)
}
klog.Infof("No Kubernetes flag is set, setting Kubernetes version to %s", constants.NoKubernetesVersion)
if old != nil {
old.KubernetesConfig.KubernetesVersion = constants.NoKubernetesVersion

View File

@ -45,6 +45,7 @@ func TestNoKubernetes(t *testing.T) {
name string
validator validateFunc
}{
{"StartNoK8sWithVersion", validateStartNoK8sWithVersion},
{"Start", validateStartNoK8S},
{"VerifyK8sNotRunning", validateK8SNotRunning},
{"ProfileList", validateProfileListNoK8S},
@ -70,6 +71,17 @@ func TestNoKubernetes(t *testing.T) {
})
}
// validateStartNoK8sWithVersion expect an error when starting a minikube cluster without kubernetes and with a kubernetes version.
func validateStartNoK8sWithVersion(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)
args := append([]string{"start", "-p", profile, "--no-kubernetes", "--kubernetes-version=1.20"}, StartArgs()...)
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err == nil {
t.Fatalf("expected an error but none was thrown with args: %q", rr.Command())
}
}
// validateStartNoK8S starts a minikube cluster without kubernetes started/configured
func validateStartNoK8S(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)