From ab9f3b234dd60d01bcdb5aa5dc74f852feb0fbab Mon Sep 17 00:00:00 2001 From: Yongkun Anfernee Gui Date: Fri, 9 Feb 2018 11:19:19 -0800 Subject: [PATCH] Remove OS dependent SupportedVMDrivers Use ListDrivers() method to get the list of VM drivers. SupportedVMDrivers become the whole list of VM drivers on all platforms, which is used in gendocs only. --- Makefile | 2 +- pkg/minikube/cluster/cluster_test.go | 4 +-- pkg/minikube/constants/constants.go | 10 +++++++ pkg/minikube/constants/constants_darwin.go | 9 +----- pkg/minikube/constants/constants_gendocs.go | 33 --------------------- pkg/minikube/constants/constants_linux.go | 9 +----- pkg/minikube/constants/constants_windows.go | 7 +---- 7 files changed, 16 insertions(+), 58 deletions(-) delete mode 100644 pkg/minikube/constants/constants_gendocs.go diff --git a/Makefile b/Makefile index 9bcd973c9f..45f6f1a35f 100755 --- a/Makefile +++ b/Makefile @@ -233,7 +233,7 @@ fmt: @gofmt -l -s -w $(SOURCE_DIRS) out/docs/minikube.md: $(shell find cmd) $(shell find pkg/minikube/constants) pkg/minikube/assets/assets.go - cd $(GOPATH)/src/$(REPOPATH) && go run -ldflags="$(K8S_VERSION_LDFLAGS) $(MINIKUBE_LDFLAGS)" -tags gendocs hack/gen_help_text.go + cd $(GOPATH)/src/$(REPOPATH) && go run -ldflags="$(K8S_VERSION_LDFLAGS) $(MINIKUBE_LDFLAGS)" hack/gen_help_text.go out/minikube_$(DEB_VERSION).deb: out/minikube-linux-amd64 cp -r installers/linux/deb/minikube_deb_template out/minikube_$(DEB_VERSION) diff --git a/pkg/minikube/cluster/cluster_test.go b/pkg/minikube/cluster/cluster_test.go index f8729100d7..97ca4625e9 100644 --- a/pkg/minikube/cluster/cluster_test.go +++ b/pkg/minikube/cluster/cluster_test.go @@ -67,7 +67,7 @@ func TestCreateHost(t *testing.T) { } found := false - for _, driver := range constants.SupportedVMDrivers { + for _, driver := range ListDrivers() { if h.DriverName == driver { found = true break @@ -75,7 +75,7 @@ func TestCreateHost(t *testing.T) { } if !found { - t.Fatalf("Wrong driver name: %v. Should be virtualbox, vmwarefusion, kvm or xhyve.", h.DriverName) + t.Fatalf("Wrong driver name: %v. Should be among %v", h.DriverName, ListDrivers()) } } diff --git a/pkg/minikube/constants/constants.go b/pkg/minikube/constants/constants.go index e4f237fb31..01ed9fd488 100644 --- a/pkg/minikube/constants/constants.go +++ b/pkg/minikube/constants/constants.go @@ -46,6 +46,16 @@ func GetMinipath() string { return filepath.Join(os.Getenv(MinikubeHome), ".minikube") } +// SupportedVMDrivers is a list of supported drivers on all platforms. Currently +// used in gendocs. +var SupportedVMDrivers = [...]string{ + "virtualbox", + "vmwarefusion", + "kvm", + "xhyve", + "hyperv", +} + var DefaultMinipath = filepath.Join(homedir.HomeDir(), ".minikube") // KubeconfigPath is the path to the Kubernetes client config diff --git a/pkg/minikube/constants/constants_darwin.go b/pkg/minikube/constants/constants_darwin.go index a6effc509f..081ffea3fe 100644 --- a/pkg/minikube/constants/constants_darwin.go +++ b/pkg/minikube/constants/constants_darwin.go @@ -1,4 +1,4 @@ -// +build darwin,!gendocs +// +build darwin /* Copyright 2016 The Kubernetes Authors All rights reserved. @@ -18,11 +18,4 @@ limitations under the License. package constants -var SupportedVMDrivers = [...]string{ - "virtualbox", - "xhyve", - "vmwarefusion", - "hyperkit", -} - var DefaultMountDir = "/Users" diff --git a/pkg/minikube/constants/constants_gendocs.go b/pkg/minikube/constants/constants_gendocs.go deleted file mode 100644 index 04f32635fc..0000000000 --- a/pkg/minikube/constants/constants_gendocs.go +++ /dev/null @@ -1,33 +0,0 @@ -// +build gendocs - -/* -Copyright 2016 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package constants - -import ( - "k8s.io/client-go/util/homedir" -) - -var SupportedVMDrivers = [...]string{ - "virtualbox", - "vmwarefusion", - "kvm", - "xhyve", - "hyperv", -} - -var DefaultMountDir = homedir.HomeDir() diff --git a/pkg/minikube/constants/constants_linux.go b/pkg/minikube/constants/constants_linux.go index 30e0203105..1df7788d30 100644 --- a/pkg/minikube/constants/constants_linux.go +++ b/pkg/minikube/constants/constants_linux.go @@ -1,4 +1,4 @@ -// +build linux,!gendocs +// +build linux /* Copyright 2016 The Kubernetes Authors All rights reserved. @@ -22,11 +22,4 @@ import ( "k8s.io/client-go/util/homedir" ) -var SupportedVMDrivers = [...]string{ - "virtualbox", - "kvm", - "kvm2", - "none", -} - var DefaultMountDir = homedir.HomeDir() diff --git a/pkg/minikube/constants/constants_windows.go b/pkg/minikube/constants/constants_windows.go index 475f2f322c..aa66af22a6 100644 --- a/pkg/minikube/constants/constants_windows.go +++ b/pkg/minikube/constants/constants_windows.go @@ -1,4 +1,4 @@ -// +build windows,!gendocs +// +build windows /* Copyright 2016 The Kubernetes Authors All rights reserved. @@ -22,9 +22,4 @@ import ( "k8s.io/client-go/util/homedir" ) -var SupportedVMDrivers = [...]string{ - "virtualbox", - "hyperv", -} - var DefaultMountDir = homedir.HomeDir()