From 558f04c713f15a6acfde15a5daa895115a4f40cf Mon Sep 17 00:00:00 2001 From: Michael Pleshakov Date: Wed, 20 Dec 2017 19:36:51 +0000 Subject: [PATCH] Add git commit info to IC log --- nginx-controller/Makefile | 13 ++++--------- nginx-controller/main.go | 5 +++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/nginx-controller/Makefile b/nginx-controller/Makefile index e5acba725b..ed86970119 100644 --- a/nginx-controller/Makefile +++ b/nginx-controller/Makefile @@ -12,11 +12,13 @@ BUILD_IN_CONTAINER = 1 PUSH_TO_GCR = GENERATE_DEFAULT_CERT_AND_KEY = +GIT_COMMIT=$(shell git rev-parse --short HEAD) + nginx-ingress: ifeq ($(BUILD_IN_CONTAINER),1) - $(DOCKER_RUN) -e CGO_ENABLED=0 $(GOLANG_CONTAINER) go build -a -installsuffix cgo -ldflags "-w -X main.version=${VERSION}" -o nginx-ingress *.go + $(DOCKER_RUN) -e CGO_ENABLED=0 $(GOLANG_CONTAINER) go build -a -installsuffix cgo -ldflags "-w -X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT}" -o nginx-ingress *.go else - CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-w -X main.version=${VERSION}" -o nginx-ingress *.go + CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-w -X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT}" -o nginx-ingress *.go endif test: @@ -41,12 +43,5 @@ else docker push $(PREFIX):$(TAG) endif -osx: -ifeq ($(BUILD_IN_CONTAINER),1) - $(DOCKER_RUN) -e CGO_ENABLED=0 -e GOOS=darwin $(GOLANG_CONTAINER) go build -a -installsuffix cgo -ldflags "-w -X main.version=${VERSION}" -o osx-nginx-ingress *.go -else - CGO_ENABLED=0 GOOS=darwin go build -a -installsuffix cgo -ldflags "-w -X main.version=${VERSION}" -o osx-nginx-ingress *.go -endif - clean: rm -f nginx-ingress diff --git a/nginx-controller/main.go b/nginx-controller/main.go index ec9bdd2b2b..dbf7c94a54 100644 --- a/nginx-controller/main.go +++ b/nginx-controller/main.go @@ -22,7 +22,8 @@ import ( var ( // Set during build - version string + version string + gitCommit string healthStatus = flag.Bool("health-status", false, `If present, the default server listening on port 80 with the health check @@ -61,7 +62,7 @@ func main() { flag.Parse() flag.Lookup("logtostderr").Value.Set("true") - glog.Infof("Starting NGINX Ingress controller Version %v\n", version) + glog.Infof("Starting NGINX Ingress controller Version=%v GitCommit=%v\n", version, gitCommit) var err error var config *rest.Config