Skip to content

Commit 4610663

Browse files
authored
Merge pull request #4398 from josedonizetti/add-kvm-version-flag
Add kvm2 --version
2 parents b3c7496 + a024c6d commit 4610663

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ release-minikube: out/minikube checksum
367367
out/docker-machine-driver-kvm2:
368368
go build \
369369
-installsuffix "static" \
370-
-ldflags "-X k8s.io/minikube/pkg/drivers/kvm/version.VERSION=$(VERSION)" \
370+
-ldflags "-X k8s.io/minikube/pkg/drivers/kvm.version=$(VERSION)" \
371371
-tags libvirt.1.3.1 \
372372
-o $(BUILD_DIR)/docker-machine-driver-kvm2 \
373373
k8s.io/minikube/cmd/drivers/kvm

cmd/drivers/kvm/main.go

+8
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ limitations under the License.
1919
package main
2020

2121
import (
22+
"fmt"
23+
"os"
24+
2225
"github.com/docker/machine/libmachine/drivers/plugin"
2326
"k8s.io/minikube/pkg/drivers/kvm"
2427
)
2528

2629
func main() {
30+
if len(os.Args) > 1 && os.Args[1] == "--version" {
31+
fmt.Println(kvm.GetVersion())
32+
return
33+
}
34+
2735
plugin.RegisterDriver(kvm.NewDriver("", ""))
2836
}

pkg/drivers/kvm/version.go

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Copyright 2016 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package kvm
18+
19+
// The current version of the docker-machine-driver-kvm2
20+
21+
// version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/drivers/kvm.version=vX.Y.Z"
22+
var version = "v0.0.0-unset"
23+
24+
// GetVersion returns the current docker-machine-driver-kvm2 version
25+
func GetVersion() string {
26+
return version
27+
}

0 commit comments

Comments
 (0)