Skip to content

Commit

Permalink
Merge pull request #226 from rramkumar1/master
Browse files Browse the repository at this point in the history
Add support for logging latest commit hash of GLBC build being used
  • Loading branch information
nicksardo committed Apr 18, 2018
2 parents 61159a3 + fc5e2f4 commit 7e233ee
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ PKG := k8s.io/ingress-gce
# for each BINARY.
CONTAINER_BINARIES := glbc

# Latest commit hash for current branch.
GIT_COMMIT := $(shell git rev-parse HEAD)

# Registry to push to.
REGISTRY ?= gcr.io/google_containers

Expand Down
11 changes: 8 additions & 3 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ fi
if [ -z "${VERSION}" ]; then
echo "VERSION must be set"
exit 1

fi
if [ -z "${GIT_COMMIT}" ]; then
echo "GIT_COMMIT must be set"
exit 1
fi

export CGO_ENABLED=0
Expand All @@ -37,7 +42,7 @@ if [ $GOARCH == "amd64" ]; then
export GOBIN="$GOPATH/bin/linux_amd64"
fi

go install \
-installsuffix "static" \
-ldflags "-X ${PKG}/pkg/version.Version=${VERSION}" \
go install \
-installsuffix "static" \
-ldflags "-X ${PKG}/pkg/version.Version=${VERSION} -X ${PKG}/pkg/version.GitCommit=${GIT_COMMIT}" \
./...
1 change: 1 addition & 0 deletions build/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ $(GO_BINARIES): build-dirs
ARCH=$(ARCH) \
VERSION=$(VERSION) \
PKG=$(PKG) \
GIT_COMMIT=$(GIT_COMMIT) \
./build/build.sh \
"

Expand Down
1 change: 1 addition & 0 deletions cmd/glbc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func main() {
}

glog.V(0).Infof("Starting GLBC image: %q, cluster name %q", version.Version, flags.F.ClusterName)
glog.V(0).Infof("Latest commit hash: %q", version.GitCommit)
for i, a := range os.Args {
glog.V(0).Infof("argv[%d]: %q", i, a)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ package version
// Version is a version string populated by the build using -ldflags "-X
// ${PKG}/pkg/version.Version=${VERSION}".
var Version = "UNKNOWN"

// GitCommit is the latest git commit hash populated by the build using
// -ldflags "-X ${PKG}/pkg/version.GitCommit=${GIT_COMMIT}".
var GitCommit = "UNKNOWN"

0 comments on commit 7e233ee

Please sign in to comment.