diff --git a/Makefile b/Makefile index ccc6d1eb87..351e76f888 100755 --- a/Makefile +++ b/Makefile @@ -86,6 +86,9 @@ SOURCE_PACKAGES = ./cmd/... ./pkg/... ./test/... # kvm2 ldflags KVM2_LDFLAGS := -X k8s.io/minikube/pkg/drivers/kvm.version=$(VERSION) -X k8s.io/minikube/pkg/drivers/kvm.gitCommitID=$(COMMIT) +# hyperkit ldflags +HYPERKIT_LDFLAGS := -X k8s.io/minikube/pkg/drivers/hyperkit.version=$(VERSION) -X k8s.io/minikube/pkg/drivers/hyperkit.gitCommitID=$(COMMIT) + # $(call DOCKER, image, command) define DOCKER docker run --rm -e GOCACHE=/app/.cache -e IN_DOCKER=1 --user $(shell id -u):$(shell id -g) -w /app -v $(PWD):/app -v $(GOPATH):/go --entrypoint /bin/bash $(1) -c '$(2)' @@ -329,7 +332,9 @@ out/docker-machine-driver-hyperkit: ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y) $(call DOCKER,$(HYPERKIT_BUILD_IMAGE),CC=o64-clang CXX=o64-clang++ /usr/bin/make $@) else - GOOS=darwin CGO_ENABLED=1 go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit + GOOS=darwin CGO_ENABLED=1 go build \ + -ldflags="$(HYPERKIT_LDFLAGS)" \ + -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit endif .PHONY: install-hyperkit-driver diff --git a/cmd/drivers/hyperkit/main.go b/cmd/drivers/hyperkit/main.go index 5089b6e9ec..32788b0c2b 100644 --- a/cmd/drivers/hyperkit/main.go +++ b/cmd/drivers/hyperkit/main.go @@ -19,10 +19,19 @@ limitations under the License. package main import ( + "fmt" + "os" + "github.com/docker/machine/libmachine/drivers/plugin" "k8s.io/minikube/pkg/drivers/hyperkit" ) func main() { + if len(os.Args) > 1 && os.Args[1] == "version" { + fmt.Println("version:", hyperkit.GetVersion()) + fmt.Println("commit:", hyperkit.GetGitCommitID()) + return + } + plugin.RegisterDriver(hyperkit.NewDriver("", "")) } diff --git a/docs/drivers.md b/docs/drivers.md index 9c2b3fccb7..cee958354b 100644 --- a/docs/drivers.md +++ b/docs/drivers.md @@ -133,6 +133,14 @@ or, to use hyperkit as a default driver for minikube: minikube config set vm-driver hyperkit ``` +### Troubleshoot + +Make sure you are running the lastest version of your driver. + +```shell +docker-machine-driver-hyperkit version +``` + ## HyperV driver Hyper-v users may need to create a new external network switch as described [here](https://docs.docker.com/machine/drivers/hyper-v/). This step may prevent a problem in which `minikube start` hangs indefinitely, unable to ssh into the minikube virtual machine. In this add, add the `--hyperv-virtual-switch=switch-name` argument to the `minikube start` command. diff --git a/pkg/drivers/hyperkit/version.go b/pkg/drivers/hyperkit/version.go new file mode 100644 index 0000000000..249da2fdc5 --- /dev/null +++ b/pkg/drivers/hyperkit/version.go @@ -0,0 +1,35 @@ +/* +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 hyperkit + +// The current version of the docker-machine-driver-hyperkit + +// version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/drivers/hyperkit.version=vX.Y.Z" +var version = "v0.0.0-unset" + +// gitCommitID is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/drivers/hyperkit.gitCommitID=" +var gitCommitID = "" + +// GetVersion returns the current docker-machine-driver-hyperkit version +func GetVersion() string { + return version +} + +// GetGitCommitID returns the git commit id from which it is being built +func GetGitCommitID() string { + return gitCommitID +}