Skip to content

Commit 29918c7

Browse files
authored
Add git commit info to IC log (#221)
1 parent b4cbd3d commit 29918c7

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

nginx-controller/Makefile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ BUILD_IN_CONTAINER = 1
1212
PUSH_TO_GCR =
1313
GENERATE_DEFAULT_CERT_AND_KEY =
1414

15+
GIT_COMMIT=$(shell git rev-parse --short HEAD)
16+
1517
nginx-ingress:
1618
ifeq ($(BUILD_IN_CONTAINER),1)
17-
$(DOCKER_RUN) -e CGO_ENABLED=0 $(GOLANG_CONTAINER) go build -a -installsuffix cgo -ldflags "-w -X main.version=${VERSION}" -o nginx-ingress *.go
19+
$(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
1820
else
19-
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-w -X main.version=${VERSION}" -o nginx-ingress *.go
21+
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
2022
endif
2123

2224
test:
@@ -41,12 +43,5 @@ else
4143
docker push $(PREFIX):$(TAG)
4244
endif
4345

44-
osx:
45-
ifeq ($(BUILD_IN_CONTAINER),1)
46-
$(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
47-
else
48-
CGO_ENABLED=0 GOOS=darwin go build -a -installsuffix cgo -ldflags "-w -X main.version=${VERSION}" -o osx-nginx-ingress *.go
49-
endif
50-
5146
clean:
5247
rm -f nginx-ingress

nginx-controller/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import (
2222

2323
var (
2424
// Set during build
25-
version string
25+
version string
26+
gitCommit string
2627

2728
healthStatus = flag.Bool("health-status", false,
2829
`If present, the default server listening on port 80 with the health check
@@ -61,7 +62,7 @@ func main() {
6162
flag.Parse()
6263
flag.Lookup("logtostderr").Value.Set("true")
6364

64-
glog.Infof("Starting NGINX Ingress controller Version %v\n", version)
65+
glog.Infof("Starting NGINX Ingress controller Version=%v GitCommit=%v\n", version, gitCommit)
6566

6667
var err error
6768
var config *rest.Config

0 commit comments

Comments
 (0)