Skip to content

Commit a2f8b41

Browse files
authored
Merge pull request #34 from xing-yang/update_version
Update version in the Makefile
2 parents 4fd714a + 69118cd commit a2f8b41

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@ IMAGE_NAME=csi-snapshotter
1919
IMAGE_VERSION=canary
2020
IMAGE_TAG=$(REGISTRY_NAME)/$(IMAGE_NAME):$(IMAGE_VERSION)
2121

22+
REV=$(shell git describe --long --tags --match='v*' --dirty)
23+
2224
ifdef V
2325
TESTARGS = -v -args -alsologtostderr -v 5
2426
else
2527
TESTARGS =
2628
endif
2729

28-
2930
all: csi-snapshotter
3031

3132
csi-snapshotter:
3233
mkdir -p bin
33-
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o ./bin/csi-snapshotter ./cmd/csi-snapshotter
34+
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/csi-snapshotter ./cmd/csi-snapshotter
3435

3536
clean:
3637
-rm -rf bin

cmd/csi-snapshotter/main.go

+11
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,23 @@ var (
5858
resyncPeriod = flag.Duration("resync-period", 60*time.Second, "Resync interval of the controller.")
5959
snapshotNamePrefix = flag.String("snapshot-name-prefix", "snapshot", "Prefix to apply to the name of a created snapshot")
6060
snapshotNameUUIDLength = flag.Int("snapshot-name-uuid-length", -1, "Length in characters for the generated uuid of a created snapshot. Defaults behavior is to NOT truncate.")
61+
showVersion = flag.Bool("version", false, "Show version.")
62+
)
63+
64+
var (
65+
version = "unknown"
6166
)
6267

6368
func main() {
6469
flag.Set("logtostderr", "true")
6570
flag.Parse()
6671

72+
if *showVersion {
73+
fmt.Println(os.Args[0], version)
74+
os.Exit(0)
75+
}
76+
glog.Infof("Version: %s", version)
77+
6778
// Create the client config. Use kubeconfig if given, otherwise assume in-cluster.
6879
config, err := buildConfig(*kubeconfig)
6980
if err != nil {

0 commit comments

Comments
 (0)