From 10f2e6c8195879085036941b9e711bf6661df9a4 Mon Sep 17 00:00:00 2001 From: Grzegorz Piotrowski Date: Wed, 19 Jul 2023 13:35:00 +0100 Subject: [PATCH 1/6] Add prepare-release and fix-csv-replaces Signed-off-by: Grzegorz Piotrowski Co-authored-by: Adam Cattermole --- Makefile | 85 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index cb4afc5a..30143702 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,46 @@ all: build help: ## Display this help. @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +##@ Tools + +OPERATOR_SDK = $(shell pwd)/bin/operator-sdk +OPERATOR_SDK_VERSION = v1.22.0 +operator-sdk: ## Download operator-sdk locally if necessary. + ./utils/install-operator-sdk.sh $(OPERATOR_SDK) $(OPERATOR_SDK_VERSION) + +CONTROLLER_GEN = $(shell pwd)/bin/controller-gen +controller-gen: ## Download controller-gen locally if necessary. + $(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.1) + +KUSTOMIZE = $(shell pwd)/bin/kustomize +kustomize: ## Download kustomize locally if necessary. + $(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v4@v4.5.5) + +YQ = $(shell pwd)/bin/yq +$(YQ): + $(call go-get-tool,$(YQ),github.com/mikefarah/yq/v4@latest) + +.PHONY: yq +yq: $(YQ) ## Download yq locally if necessary. + +.PHONY: opm +OPM = ./bin/opm +opm: ## Download opm locally if necessary. +ifeq (,$(wildcard $(OPM))) +ifeq (,$(shell which opm 2>/dev/null)) + @{ \ + set -e ;\ + mkdir -p $(dir $(OPM)) ;\ + OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \ + curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$${OS}-$${ARCH}-opm ;\ + chmod +x $(OPM) ;\ + } +else +OPM = $(shell which opm) +endif +endif + ##@ Development manifests: controller-gen kustomize authorino-manifests ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. @@ -155,14 +195,6 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi install-authorino: ## install RBAC and CRD for authorino $(KUSTOMIZE) build config/authorino | kubectl apply -f - -CONTROLLER_GEN = $(shell pwd)/bin/controller-gen -controller-gen: ## Download controller-gen locally if necessary. - $(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.1) - -KUSTOMIZE = $(shell pwd)/bin/kustomize -kustomize: ## Download kustomize locally if necessary. - $(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v4@v4.5.5) - # go-get-tool will 'go install' any package $2 and install it to $1. PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) define go-get-tool @@ -187,11 +219,6 @@ deploy-manifest: # clean up cd $(PROJECT_DIR)/config/manager && $(KUSTOMIZE) edit set image controller=${DEFAULT_OPERATOR_IMAGE} -OPERATOR_SDK = $(shell pwd)/bin/operator-sdk -OPERATOR_SDK_VERSION = v1.22.0 -operator-sdk: ## Download operator-sdk locally if necessary. - ./utils/install-operator-sdk.sh $(OPERATOR_SDK) $(OPERATOR_SDK_VERSION) - .PHONY: bundle bundle: export IMAGE_TAG := $(IMAGE_TAG) bundle: export BUNDLE_VERSION := $(BUNDLE_VERSION) @@ -214,22 +241,22 @@ bundle-build: ## Build the bundle image. bundle-push: ## Push the bundle image. $(MAKE) docker-push OPERATOR_IMAGE=$(BUNDLE_IMG) -.PHONY: opm -OPM = ./bin/opm -opm: ## Download opm locally if necessary. -ifeq (,$(wildcard $(OPM))) -ifeq (,$(shell which opm 2>/dev/null)) - @{ \ - set -e ;\ - mkdir -p $(dir $(OPM)) ;\ - OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \ - curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$${OS}-$${ARCH}-opm ;\ - chmod +x $(OPM) ;\ - } -else -OPM = $(shell which opm) -endif -endif +.PHONY: fix-csv-replaces +fix-csv-replaces: $(YQ) + $(eval REPLACES_VERSION=$(shell curl -sSL -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GH_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/Kuadrant/authorino-operator/releases/latest | \ + jq -r '.name')) + + @echo $(REPLACES_VERSION) + V="authorino-operator.$(REPLACES_VERSION)" $(YQ) eval '.spec.replaces = strenv(V)' -i bundle/manifests/authorino-operator.clusterserviceversion.yaml + +.PHONY: prepare-release +prepare-release: + $(MAKE) manifests bundle VERSION=$(VERSION) AUTHORINO_VERSION=$(AUTHORINO_VERSION) + sed -i 's|\(defaultAuthorinoImage\s\+string = "quay.io/kuadrant/authorino:\).*"|\1v'$(AUTHORINO_VERSION)'"|' controllers/constants.go + GH_TOKEN=$(GH_TOKEN) $(MAKE) fix-csv-replaces # A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0). # These images MUST exist in a registry and be pull-able. From 469ff9228aa80dfd007fe10dc2cc5788b40ccc07 Mon Sep 17 00:00:00 2001 From: Grzegorz Piotrowski Date: Wed, 19 Jul 2023 14:13:18 +0100 Subject: [PATCH 2/6] Added release workflow Co-authored-by: Adam Cattermole Signed-off-by: Grzegorz Piotrowski --- .github/workflows/release.yaml | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..1db8d2c9 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,53 @@ +name: Release operator + +on: + workflow_dispatch: + inputs: + commitSha: + description: Commit SHA + required: true + operatorVersion: + description: Operator version + required: true + authorinoVersion: + description: Authorino version + required: true + default: latest + +jobs: + build: + name: Release operator + runs-on: ubuntu-20.04 + steps: + - name: Install gettext-base + run: | + sudo apt-get update + sudo apt-get install -y gettext-base + - name: Set up Go 1.19.x + uses: actions/setup-go@v2 + with: + go-version: 1.19.x + id: go + - name: Checkout code at commit SHA + uses: actions/checkout@v3 + with: + ref: ${{ github.event.inputs.commitSha }} + - name: Create release branch + run: | + git checkout -b release-v${{ github.event.inputs.operatorVersion }} + - name: Prepare release + run: VERSION=${{ github.event.inputs.operatorVersion }} AUTHORINO_VERSION=${{ github.event.inputs.authorinoVersion }} GH_TOKEN=${{ secrets.GITHUB_TOKEN }} make prepare-release + - name: Commit and push + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git commit -m "Prepared release v${{ github.event.inputs.operatorVersion }}" -a + git push origin release-v${{ github.event.inputs.operatorVersion }} + - name: Create release + uses: softprops/action-gh-release@v1 + with: + name: v${{ github.event.inputs.operatorVersion }} + tag_name: v${{ github.event.inputs.operatorVersion }} + body: "**This release enables installations of Authorino v${{ github.event.inputs.authorinoVersion }}**" + generate_release_notes: true + target_commitish: release-v${{ github.event.inputs.operatorVersion }} \ No newline at end of file From 4bb06113b3e8911339bdf66796a0d965474de63d Mon Sep 17 00:00:00 2001 From: Grzegorz Piotrowski Date: Fri, 21 Jul 2023 10:46:04 +0100 Subject: [PATCH 3/6] Refactored setting defaultAuthorinoImage Signed-off-by: Grzegorz Piotrowski Co-authored-by: Adam Cattermole --- .github/workflows/build-images.yaml | 6 +++++- .github/workflows/release.yaml | 16 +++++++++++----- Dockerfile | 5 +++-- Makefile | 17 +++++++++++------ 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml index ddc37f7a..ba9cd1ff 100644 --- a/.github/workflows/build-images.yaml +++ b/.github/workflows/build-images.yaml @@ -48,6 +48,9 @@ jobs: run: | sudo apt-get update sudo apt-get install -y qemu-user-static + - name: Set default authorino image + run: | + echo "DEFAULT_AUTHORINO_IMAGE=$(cat authorino_image || echo ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/authorino:latest)" >> $GITHUB_ENV - name: Build Image id: build-image uses: redhat-actions/buildah-build@v2 @@ -56,7 +59,8 @@ jobs: tags: ${{ env.IMG_TAGS }} platforms: linux/amd64,linux/arm64 build-args: | - version=${{ env.VERSION }} + VERSION=${{ env.VERSION }} + DEFAULT_AUTHORINO_IMAGE=${{ env.DEFAULT_AUTHORINO_IMAGE }} containerfiles: | ./Dockerfile - name: Push Image diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1db8d2c9..96df9d91 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,8 +3,8 @@ name: Release operator on: workflow_dispatch: inputs: - commitSha: - description: Commit SHA + gitRef: + description: Commit SHA or branch name required: true operatorVersion: description: Operator version @@ -13,6 +13,10 @@ on: description: Authorino version required: true default: latest + prerelease: + description: Is the release a prerelease + required: false + type: boolean jobs: build: @@ -28,11 +32,12 @@ jobs: with: go-version: 1.19.x id: go - - name: Checkout code at commit SHA + - name: Checkout code at git ref uses: actions/checkout@v3 with: - ref: ${{ github.event.inputs.commitSha }} + ref: ${{ github.event.inputs.gitRef }} - name: Create release branch + if: ${{ !startsWith(github.event.inputs.gitRef, 'release-v') }} run: | git checkout -b release-v${{ github.event.inputs.operatorVersion }} - name: Prepare release @@ -50,4 +55,5 @@ jobs: tag_name: v${{ github.event.inputs.operatorVersion }} body: "**This release enables installations of Authorino v${{ github.event.inputs.authorinoVersion }}**" generate_release_notes: true - target_commitish: release-v${{ github.event.inputs.operatorVersion }} \ No newline at end of file + target_commitish: release-v${{ github.event.inputs.operatorVersion }} + prerelease: ${{ github.event.inputs.prerelease }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 15f0fb7b..e5c6a0d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,8 +16,9 @@ COPY api/ api/ COPY controllers/ controllers/ COPY pkg/ pkg/ -ARG version=latest -RUN CGO_ENABLED=0 GO111MODULE=on go build -a -ldflags "-X main.version=${version}" -o manager main.go +ARG VERSION=latest +ARG DEFAULT_AUTHORINO_IMAGE=quay.io/kuadrant/authorino:latest +RUN CGO_ENABLED=0 GO111MODULE=on go build -a -ldflags "-X main.version=${VERSION} -X controllers.defaultAuthorinoImage=${DEFAULT_AUTHORINO_IMAGE}" -o manager main.go # Use Red Hat minimal base image to package the binary # https://catalog.redhat.com/software/containers/ubi9-minimal diff --git a/Makefile b/Makefile index 30143702..10ebdf08 100644 --- a/Makefile +++ b/Makefile @@ -78,6 +78,9 @@ else AUTHORINO_BRANCH = v$(AUTHORINO_VERSION) endif +AUTHORINO_IMAGE_FILE ?= authorino_image +DEFAULT_AUTHORINO_IMAGE ?= $(shell cat $(AUTHORINO_IMAGE_FILE) || echo $(DEFAULT_REGISTRY)/$(DEFAULT_ORG)/authorino:latest) + all: build ##@ General @@ -164,13 +167,13 @@ test: manifests generate fmt vet setup-envtest ##@ Build build: generate fmt vet ## Build manager binary. - go build -ldflags "-X main.version=$(VERSION)" -o bin/manager main.go + go build -ldflags "-X main.version=$(VERSION) -X controllers.defaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" -o bin/manager main.go run: manifests generate fmt vet ## Run a controller from your host. - go run -ldflags "-X main.version=$(VERSION)" ./main.go + go run -ldflags "-X main.version=$(VERSION) -X controllers.defaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" ./main.go docker-build: ## Build docker image with the manager. - docker build --build-arg version=$(VERSION) -t $(OPERATOR_IMAGE) . + docker build --build-arg VERSION=$(VERSION) --build-arg DEFAULT_AUTHORINO_IMAGE=${DEFAULT_AUTHORINO_IMAGE} -t $(OPERATOR_IMAGE) . docker-push: ## Push docker image with the manager. docker push ${OPERATOR_IMAGE} @@ -248,14 +251,16 @@ fix-csv-replaces: $(YQ) -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/Kuadrant/authorino-operator/releases/latest | \ jq -r '.name')) - - @echo $(REPLACES_VERSION) V="authorino-operator.$(REPLACES_VERSION)" $(YQ) eval '.spec.replaces = strenv(V)' -i bundle/manifests/authorino-operator.clusterserviceversion.yaml .PHONY: prepare-release prepare-release: $(MAKE) manifests bundle VERSION=$(VERSION) AUTHORINO_VERSION=$(AUTHORINO_VERSION) - sed -i 's|\(defaultAuthorinoImage\s\+string = "quay.io/kuadrant/authorino:\).*"|\1v'$(AUTHORINO_VERSION)'"|' controllers/constants.go + @if [ "$(AUTHORINO_VERSION)" = "latest" ]; then\ + [ -e "$(AUTHORINO_IMAGE_FILE)" ] && rm $(AUTHORINO_IMAGE_FILE); \ + else \ + echo quay.io/kuadrant/authorino:v$(AUTHORINO_VERSION) > $(AUTHORINO_IMAGE_FILE); \ + fi GH_TOKEN=$(GH_TOKEN) $(MAKE) fix-csv-replaces # A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0). From 93fc61c06e363cd48e0221a1a56fbd727e0e5fc7 Mon Sep 17 00:00:00 2001 From: Grzegorz Piotrowski Date: Fri, 28 Jul 2023 14:11:30 +0100 Subject: [PATCH 4/6] Changed defaultAuthorinoImage to var and removed not needed headers Signed-off-by: Grzegorz Piotrowski Co-authored-by: Adam Cattermole --- .github/workflows/release.yaml | 2 +- Makefile | 10 ++++------ controllers/constants.go | 4 +++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 96df9d91..f408f86d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -41,7 +41,7 @@ jobs: run: | git checkout -b release-v${{ github.event.inputs.operatorVersion }} - name: Prepare release - run: VERSION=${{ github.event.inputs.operatorVersion }} AUTHORINO_VERSION=${{ github.event.inputs.authorinoVersion }} GH_TOKEN=${{ secrets.GITHUB_TOKEN }} make prepare-release + run: VERSION=${{ github.event.inputs.operatorVersion }} AUTHORINO_VERSION=${{ github.event.inputs.authorinoVersion }} make prepare-release - name: Commit and push run: | git config --global user.name "github-actions[bot]" diff --git a/Makefile b/Makefile index 10ebdf08..1f95be69 100644 --- a/Makefile +++ b/Makefile @@ -167,13 +167,13 @@ test: manifests generate fmt vet setup-envtest ##@ Build build: generate fmt vet ## Build manager binary. - go build -ldflags "-X main.version=$(VERSION) -X controllers.defaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" -o bin/manager main.go + go build -ldflags "-X main.version=$(VERSION) -X github.com/kuadrant/authorino-operator/controllers.defaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" -o bin/manager main.go run: manifests generate fmt vet ## Run a controller from your host. - go run -ldflags "-X main.version=$(VERSION) -X controllers.defaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" ./main.go + go run -ldflags "-X main.version=$(VERSION) -X github.com/kuadrant/authorino-operator/controllers.defaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" ./main.go docker-build: ## Build docker image with the manager. - docker build --build-arg VERSION=$(VERSION) --build-arg DEFAULT_AUTHORINO_IMAGE=${DEFAULT_AUTHORINO_IMAGE} -t $(OPERATOR_IMAGE) . + docker build --build-arg VERSION=$(VERSION) --build-arg DEFAULT_AUTHORINO_IMAGE=$(DEFAULT_AUTHORINO_IMAGE) -t $(OPERATOR_IMAGE) . docker-push: ## Push docker image with the manager. docker push ${OPERATOR_IMAGE} @@ -247,8 +247,6 @@ bundle-push: ## Push the bundle image. .PHONY: fix-csv-replaces fix-csv-replaces: $(YQ) $(eval REPLACES_VERSION=$(shell curl -sSL -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${GH_TOKEN}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/Kuadrant/authorino-operator/releases/latest | \ jq -r '.name')) V="authorino-operator.$(REPLACES_VERSION)" $(YQ) eval '.spec.replaces = strenv(V)' -i bundle/manifests/authorino-operator.clusterserviceversion.yaml @@ -261,7 +259,7 @@ prepare-release: else \ echo quay.io/kuadrant/authorino:v$(AUTHORINO_VERSION) > $(AUTHORINO_IMAGE_FILE); \ fi - GH_TOKEN=$(GH_TOKEN) $(MAKE) fix-csv-replaces + $(MAKE) fix-csv-replaces # A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0). # These images MUST exist in a registry and be pull-able. diff --git a/controllers/constants.go b/controllers/constants.go index dd498762..f4ceb4f3 100644 --- a/controllers/constants.go +++ b/controllers/constants.go @@ -53,7 +53,6 @@ const ( flagMaxHttpRequestBodySize string = "max-http-request-body-size" // defaults - defaultAuthorinoImage string = "quay.io/kuadrant/authorino:latest" defaultTlsCertPath string = "/etc/ssl/certs/tls.crt" defaultTlsCertKeyPath string = "/etc/ssl/private/tls.key" defaultOidcTlsCertPath string = "/etc/ssl/certs/oidc.crt" @@ -89,3 +88,6 @@ const ( statusUnableToUpdateDeployment = "UnableToUpdateDeployment" statusDeploymentNotReady = "DeploymentNotReady" ) + +// ldflags +var defaultAuthorinoImage string From 1789a7f9eda61bcc7be6220e70cde4d4ef1912ba Mon Sep 17 00:00:00 2001 From: Adam Cattermole Date: Fri, 28 Jul 2023 17:05:30 +0100 Subject: [PATCH 5/6] Rename DefaultAuthorinoImage and set in Dockerfile Co-authored-by: Grzegorz Piotrowski --- Dockerfile | 2 +- Makefile | 6 +++--- controllers/authorino_controller.go | 2 +- controllers/authorino_controller_test.go | 4 ++-- controllers/constants.go | 2 +- main.go | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index e5c6a0d6..40509105 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ COPY pkg/ pkg/ ARG VERSION=latest ARG DEFAULT_AUTHORINO_IMAGE=quay.io/kuadrant/authorino:latest -RUN CGO_ENABLED=0 GO111MODULE=on go build -a -ldflags "-X main.version=${VERSION} -X controllers.defaultAuthorinoImage=${DEFAULT_AUTHORINO_IMAGE}" -o manager main.go +RUN CGO_ENABLED=0 GO111MODULE=on go build -a -ldflags "-X main.version=${VERSION} -X github.com/kuadrant/authorino-operator/controllers.DefaultAuthorinoImage=${DEFAULT_AUTHORINO_IMAGE}" -o manager main.go # Use Red Hat minimal base image to package the binary # https://catalog.redhat.com/software/containers/ubi9-minimal diff --git a/Makefile b/Makefile index 1f95be69..41e6ac48 100644 --- a/Makefile +++ b/Makefile @@ -167,10 +167,10 @@ test: manifests generate fmt vet setup-envtest ##@ Build build: generate fmt vet ## Build manager binary. - go build -ldflags "-X main.version=$(VERSION) -X github.com/kuadrant/authorino-operator/controllers.defaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" -o bin/manager main.go + go build -ldflags "-X main.version=$(VERSION) -X github.com/kuadrant/authorino-operator/controllers.DefaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" -o bin/manager main.go run: manifests generate fmt vet ## Run a controller from your host. - go run -ldflags "-X main.version=$(VERSION) -X github.com/kuadrant/authorino-operator/controllers.defaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" ./main.go + go run -ldflags "-X main.version=$(VERSION) -X github.com/kuadrant/authorino-operator/controllers.DefaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" ./main.go docker-build: ## Build docker image with the manager. docker build --build-arg VERSION=$(VERSION) --build-arg DEFAULT_AUTHORINO_IMAGE=$(DEFAULT_AUTHORINO_IMAGE) -t $(OPERATOR_IMAGE) . @@ -252,7 +252,7 @@ fix-csv-replaces: $(YQ) V="authorino-operator.$(REPLACES_VERSION)" $(YQ) eval '.spec.replaces = strenv(V)' -i bundle/manifests/authorino-operator.clusterserviceversion.yaml .PHONY: prepare-release -prepare-release: +prepare-release: $(MAKE) manifests bundle VERSION=$(VERSION) AUTHORINO_VERSION=$(AUTHORINO_VERSION) @if [ "$(AUTHORINO_VERSION)" = "latest" ]; then\ [ -e "$(AUTHORINO_IMAGE_FILE)" ] && rm $(AUTHORINO_IMAGE_FILE); \ diff --git a/controllers/authorino_controller.go b/controllers/authorino_controller.go index 18f9ad49..e1b8d396 100644 --- a/controllers/authorino_controller.go +++ b/controllers/authorino_controller.go @@ -192,7 +192,7 @@ func (r *AuthorinoReconciler) buildAuthorinoDeployment(authorino *api.Authorino) var saName = authorino.Name + "-authorino" if authorino.Spec.Image == "" { - authorino.Spec.Image = defaultAuthorinoImage + authorino.Spec.Image = DefaultAuthorinoImage } var volumes []k8score.Volume diff --git a/controllers/authorino_controller_test.go b/controllers/authorino_controller_test.go index 1fab65a2..0f50b32d 100644 --- a/controllers/authorino_controller_test.go +++ b/controllers/authorino_controller_test.go @@ -121,7 +121,7 @@ var _ = Describe("Authorino controller", func() { }, testTimeout, testInterval).Should(BeTrue()) replicas := int32(testAuthorinoReplicas) - image := defaultAuthorinoImage + image := DefaultAuthorinoImage existContainer := false Expect(deployment.Spec.Replicas).Should(Equal(&replicas)) @@ -238,7 +238,7 @@ func newExtServerConfigMap() *k8score.ConfigMap { func newFullAuthorinoInstance() *api.Authorino { name := "a" + string(uuid.NewUUID()) - image := defaultAuthorinoImage + image := DefaultAuthorinoImage replicas := int32(testAuthorinoReplicas) tslEnable := true tlsDisabled := false diff --git a/controllers/constants.go b/controllers/constants.go index f4ceb4f3..39fb92d9 100644 --- a/controllers/constants.go +++ b/controllers/constants.go @@ -90,4 +90,4 @@ const ( ) // ldflags -var defaultAuthorinoImage string +var DefaultAuthorinoImage string diff --git a/main.go b/main.go index 9f1dc997..5a3c2815 100644 --- a/main.go +++ b/main.go @@ -67,7 +67,7 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - setupLog.Info("botting up authorino operator", "version", version) + setupLog.Info("botting up authorino operator", "version", version, "default authorino image", controllers.DefaultAuthorinoImage) mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, From 1a5f562c090ca6cc01e277184ae210c730387c68 Mon Sep 17 00:00:00 2001 From: Grzegorz Piotrowski Date: Fri, 28 Jul 2023 17:31:52 +0100 Subject: [PATCH 6/6] Set -ldflags in go test Signed-off-by: Grzegorz Piotrowski Co-authored-by: Adam Cattermole --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 41e6ac48..24257250 100644 --- a/Makefile +++ b/Makefile @@ -162,7 +162,7 @@ endif # Run the tests test: manifests generate fmt vet setup-envtest echo $(SETUP_ENVTEST) - KUBEBUILDER_ASSETS='$(strip $(shell $(SETUP_ENVTEST) --arch=amd64 use -p path 1.22.x))' go test ./... -coverprofile cover.out + KUBEBUILDER_ASSETS='$(strip $(shell $(SETUP_ENVTEST) --arch=amd64 use -p path 1.22.x))' go test -ldflags="-X github.com/kuadrant/authorino-operator/controllers.DefaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" ./... -coverprofile cover.out ##@ Build