Skip to content

Commit

Permalink
changed commit to gitSHA
Browse files Browse the repository at this point in the history
  • Loading branch information
ehearneRedHat committed Jul 4, 2024
1 parent 616d832 commit 6fce58c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ COPY pkg/ pkg/
COPY version/ version/

# Build
ARG COMMIT
ARG GIT_SHA
ARG DIRTY

ENV COMMIT=${COMMIT:-unknown}
ENV GIT_SHA=${GIT_SHA:-unknown}
ENV DIRTY=${DIRTY:-unknown}
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags "-X main.commit=${COMMIT} -X main.dirty=${DIRTY}" -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags "-X main.gitSHA=${GIT_SHA} -X main.dirty=${DIRTY}" -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -278,22 +278,22 @@ test-unit: clean-cov generate fmt vet ## Run Unit tests.
go test $(UNIT_DIRS) -coverprofile $(PROJECT_PATH)/coverage/unit/cover.out -v -timeout 0 $(TEST_PATTERN)

##@ Build
build: COMMIT=$(shell git rev-parse HEAD)
build: GIT_SHA=$(shell git rev-parse HEAD)
build: DIRTY=$(shell $(check_dirty))
build: generate fmt vet ## Build manager binary.
go build -ldflags "-X main.commit=${COMMIT} -X main.dirty=${DIRTY}" -o bin/manager main.go
go build -ldflags "-X main.gitSHA=${GIT_SHA} -X main.dirty=${DIRTY}" -o bin/manager main.go

run: export LOG_LEVEL = debug
run: export LOG_MODE = development
run: COMMIT=$(shell git rev-parse HEAD)
run: GIT_SHA=$(shell git rev-parse HEAD)
run: DIRTY=$(shell $(check_dirty))
run: manifests generate fmt vet ## Run a controller from your host.)
go run -ldflags "-X main.commit=${COMMIT} -X main.dirty=${DIRTY}" ./main.go
go run -ldflags "-X main.gitSHA=${GIT_SHA} -X main.dirty=${DIRTY}" ./main.go

docker-build: COMMIT=$(shell git rev-parse HEAD)
docker-build: GIT_SHA=$(shell git rev-parse HEAD)
docker-build: DIRTY=$(shell $(check_dirty))
docker-build: ## Build docker image with the manager.
docker build --build-arg COMMIT=$(COMMIT) --build-arg DIRTY=$(DIRTY) -t $(IMG) .
docker build --build-arg GIT_SHA=$(GIT_SHA) --build-arg DIRTY=$(DIRTY) -t $(IMG) .

docker-push: ## Push docker image with the manager.
docker push $(IMG)
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var (
scheme = k8sruntime.NewScheme()
logLevel = env.GetString("LOG_LEVEL", "info")
logMode = env.GetString("LOG_MODE", "production")
commit string
gitSHA string
dirty string
)

Expand All @@ -72,7 +72,7 @@ func printControllerMetaInfo() {
setupLog.Info(fmt.Sprintf("go version: %s", runtime.Version()))
setupLog.Info(fmt.Sprintf("go os/arch: %s/%s", runtime.GOOS, runtime.GOARCH))
setupLog.Info("base logger", "log level", logLevel, "log mode", logMode)
setupLog.Info("", "version", version.Version, "commit", commit, "dirty", dirty)
setupLog.Info("", "version", version.Version, "commit", gitSHA, "dirty", dirty)
}

func main() {
Expand Down

0 comments on commit 6fce58c

Please sign in to comment.