Skip to content

Commit

Permalink
Add git commit info to IC log (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
pleshakov committed Dec 20, 2017
1 parent b4cbd3d commit 29918c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
13 changes: 4 additions & 9 deletions nginx-controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
5 changes: 3 additions & 2 deletions nginx-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 29918c7

Please sign in to comment.