Update driver version during build time

update driver version and add git commit
to the image. This will help us to identify
what latest git commit image contains.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna
2019-07-12 15:48:00 +05:30
parent 0d566ee30c
commit 3f8bd3b2a6
6 changed files with 24 additions and 11 deletions

View File

@ -21,6 +21,16 @@ CSI_IMAGE_VERSION=$(if $(ENV_CSI_IMAGE_VERSION),$(ENV_CSI_IMAGE_VERSION),canary)
$(info cephcsi image settings: $(CSI_IMAGE_NAME) version $(CSI_IMAGE_VERSION))
GIT_COMMIT=$(shell git rev-list -1 HEAD)
GO_PROJECT=github.com/ceph/ceph-csi
# go build flags
LDFLAGS ?=
LDFLAGS += -X $(GO_PROJECT)/pkg/util.GitCommit=$(GIT_COMMIT)
# CSI_IMAGE_VERSION will be considered as the driver version
LDFLAGS += -X $(GO_PROJECT)/pkg/util.DriverVersion=$(CSI_IMAGE_VERSION)
all: cephcsi
test: go-test static-check
@ -38,7 +48,7 @@ func-test:
.PHONY: cephcsi
cephcsi:
if [ ! -d ./vendor ]; then dep ensure -vendor-only; fi
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o _output/cephcsi ./cmd/
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '$(LDFLAGS) -extldflags "-static"' -o _output/cephcsi ./cmd/
image-cephcsi: cephcsi
cp _output/cephcsi deploy/cephcsi/image/cephcsi