Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for logging latest commit hash of GLBC build being used #226

Merged
merged 1 commit into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -52,6 +52,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"