Merge pull request #12942 from klaases/go5
Exit if --kubernetes-version and --no-kubernetes are specified.pull/13001/head
commit
119a0f07d7
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue