Skip to content

Commit

Permalink
Refactored setting defaultAuthorinoImage
Browse files Browse the repository at this point in the history
Signed-off-by: Grzegorz Piotrowski <[email protected]>
Co-authored-by: Adam Cattermole <[email protected]>
  • Loading branch information
grzpiotrowski and adam-cattermole committed Jul 21, 2023
1 parent 469ff92 commit 1546df7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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 }}
target_commitish: release-v${{ github.event.inputs.operatorVersion }}
prerelease: ${{ github.event.inputs.prerelease }}
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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_VERSION=quay.io/kuadrant/authorino:latest
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -ldflags "-X main.version=${VERSION} -X controllers.defaultAuthorinoImage=${DEFAULT_AUTHORINO_VERSION}" -o manager main.go

# Use Red Hat minimal base image to package the binary
# https://catalog.redhat.com/software/containers/ubi9-minimal
Expand Down
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit 1546df7

Please sign in to comment.