Skip to content

Commit 8acf482

Browse files
josedonizettimedyagh
authored andcommitted
Add commit id to docker-machine-driver-kvm2 version
1 parent 6222e74 commit 8acf482

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ CMD_SOURCE_DIRS = cmd pkg
8383
SOURCE_DIRS = $(CMD_SOURCE_DIRS) test
8484
SOURCE_PACKAGES = ./cmd/... ./pkg/... ./test/...
8585

86+
# kvm2 ldflags
87+
KVM2_LDFLAGS := -X k8s.io/minikube/pkg/drivers/kvm.version=$(VERSION) -X k8s.io/minikube/pkg/drivers/kvm.gitCommitID=$(COMMIT)
88+
8689
# $(call DOCKER, image, command)
8790
define DOCKER
8891
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)'
@@ -387,11 +390,11 @@ release-minikube: out/minikube checksum
387390
gsutil cp out/minikube-$(GOOS)-$(GOARCH).sha256 $(MINIKUBE_UPLOAD_LOCATION)/$(MINIKUBE_VERSION)/minikube-$(GOOS)-$(GOARCH).sha256
388391

389392
out/docker-machine-driver-kvm2:
390-
go build \
391-
-installsuffix "static" \
392-
-ldflags "-X k8s.io/minikube/pkg/drivers/kvm.version=$(VERSION)" \
393+
go build \
394+
-installsuffix "static" \
395+
-ldflags="$(KVM2_LDFLAGS)" \
393396
-tags libvirt.1.3.1 \
394-
-o $(BUILD_DIR)/docker-machine-driver-kvm2 \
397+
-o $(BUILD_DIR)/docker-machine-driver-kvm2 \
395398
k8s.io/minikube/cmd/drivers/kvm
396399
chmod +X $@
397400

cmd/drivers/kvm/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ import (
2727
)
2828

2929
func main() {
30-
if len(os.Args) > 1 && os.Args[1] == "--version" {
31-
fmt.Println(kvm.GetVersion())
30+
if len(os.Args) > 1 && os.Args[1] == "version" {
31+
fmt.Println("version:", kvm.GetVersion())
32+
fmt.Println("commit:", kvm.GetGitCommitID())
3233
return
3334
}
3435

docs/drivers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ virsh net-start default
9999
Make sure you are running the lastest version of your driver.
100100

101101
```shell
102-
docker-machine-driver-kvm2 --version
102+
docker-machine-driver-kvm2 version
103103
```
104104

105105
## Hyperkit driver

pkg/drivers/kvm/version.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ package kvm
2121
// version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/drivers/kvm.version=vX.Y.Z"
2222
var version = "v0.0.0-unset"
2323

24+
// gitCommitID is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/drivers/kvm.gitCommitID=<commit-id>"
25+
var gitCommitID = ""
26+
2427
// GetVersion returns the current docker-machine-driver-kvm2 version
2528
func GetVersion() string {
2629
return version
2730
}
31+
32+
// GetGitCommitID returns the git commit id from which it is being built
33+
func GetGitCommitID() string {
34+
return gitCommitID
35+
}

0 commit comments

Comments
 (0)