Skip to content

Commit

Permalink
Merge pull request #307 from gibizer/fix-e2e
Browse files Browse the repository at this point in the history
Remove build in the git hash to the operator binary
  • Loading branch information
openshift-merge-robot authored Mar 24, 2023
2 parents 14f6bc2 + 30409bc commit 165d29f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN mkdir -p ${DEST_ROOT}/usr/local/bin/
RUN if [ ! -f $CACHITO_ENV_FILE ]; then go mod download ; fi

# Build manager
RUN if [ -f $CACHITO_ENV_FILE ] ; then source $CACHITO_ENV_FILE ; fi ; export GIT_COMMIT=$(git describe --always --dirty 2>/dev/null || echo "<failed to generate>") && echo $GIT_COMMIT && CGO_ENABLED=0 GO111MODULE=on go build -ldflags "-X main.gitBuildHash=$GIT_COMMIT" ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/manager main.go
RUN if [ -f $CACHITO_ENV_FILE ] ; then source $CACHITO_ENV_FILE ; fi ; CGO_ENABLED=0 GO111MODULE=on go build ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/manager main.go

RUN cp -r templates ${DEST_ROOT}/templates
RUN cp -r playbooks ${DEST_ROOT}/playbooks
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ endif
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

BUILD_HASH = "main.gitBuildHash=$(shell git describe --always --dirty 2>/dev/null || echo "<failed to generate>")"

.PHONY: all
all: build

Expand Down Expand Up @@ -132,11 +130,11 @@ test: manifests generate fmt vet envtest ginkgo ## Run tests.

.PHONY: build
build: generate fmt vet ## Build manager binary.
go build -ldflags "-X $(BUILD_HASH)" -o bin/manager main.go
go build -o bin/manager main.go

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run -ldflags "-X $(BUILD_HASH)" ./main.go
go run ./main.go

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
Expand Down
8 changes: 2 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package main

import (
"flag"
"fmt"
"os"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
Expand Down Expand Up @@ -53,9 +52,8 @@ import (
)

var (
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
gitBuildHash = "<not provided during build>"
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
)

func init() {
Expand Down Expand Up @@ -90,8 +88,6 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

setupLog.Info(fmt.Sprintf("Git build hash: %s", gitBuildHash))

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Expand Down

0 comments on commit 165d29f

Please sign in to comment.