From 1ee5f75e33e44b35e2b7d78243244c642d1ad61e Mon Sep 17 00:00:00 2001 From: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com> Date: Wed, 6 Nov 2024 11:02:58 -0500 Subject: [PATCH] Tweak image logic for Konflux Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com> --- ...per-operator-bundle-3-17-pull-request.yaml | 2 +- .../gatekeeper-operator-bundle-3-17-push.yaml | 2 +- Makefile | 5 ++- build/bundle.Dockerfile | 2 +- build/bundle.Dockerfile.rhtap | 37 +++++++++++++++++++ build/install-yq.sh | 17 +++++++++ build/konflux-patch.sh | 9 +++++ bundle/metadata/annotations.yaml | 2 +- 8 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 build/bundle.Dockerfile.rhtap create mode 100755 build/install-yq.sh create mode 100755 build/konflux-patch.sh diff --git a/.tekton/gatekeeper-operator-bundle-3-17-pull-request.yaml b/.tekton/gatekeeper-operator-bundle-3-17-pull-request.yaml index b93e02981..e174fa61e 100644 --- a/.tekton/gatekeeper-operator-bundle-3-17-pull-request.yaml +++ b/.tekton/gatekeeper-operator-bundle-3-17-pull-request.yaml @@ -26,7 +26,7 @@ spec: - name: image-expires-after value: 5d - name: dockerfile - value: build/bundle.Dockerfile + value: build/bundle.Dockerfile.rhtap - name: path-context value: . pipelineSpec: diff --git a/.tekton/gatekeeper-operator-bundle-3-17-push.yaml b/.tekton/gatekeeper-operator-bundle-3-17-push.yaml index 4d2e63d9a..7dc09bc2c 100644 --- a/.tekton/gatekeeper-operator-bundle-3-17-push.yaml +++ b/.tekton/gatekeeper-operator-bundle-3-17-push.yaml @@ -23,7 +23,7 @@ spec: - name: output-image value: quay.io/redhat-user-workloads/gatekeeper-tenant/gatekeeper-operator-3-17/gatekeeper-operator-bundle-3-17:{{revision}} - name: dockerfile - value: build/bundle.Dockerfile + value: build/bundle.Dockerfile.rhtap - name: path-context value: . pipelineSpec: diff --git a/Makefile b/Makefile index c2797aa51..594fadcf6 100644 --- a/Makefile +++ b/Makefile @@ -187,14 +187,15 @@ update-bindata: go-bindata ## Update bindata.go file. rm -rf ./$(GATEKEEPER_MANIFEST_DIR)-rendered $(MAKE) fmt -GATEKEEPER_IMAGE ?= quay.io/gatekeeper/gatekeeper +GATEKEEPER_IMG_BASE ?= quay.io/gatekeeper/gatekeeper +GATEKEEPER_IMG ?= $(GATEKEEPER_IMAGE_BASE):v$(GATEKEEPER_VERSION) .PHONY: update-gatekeeper-image update-gatekeeper-image: ## Update Gatekeeper image in manifests. yq 'select(.kind == "Deployment") \ |= .spec.template.spec.containers[] \ |= select(.name == "manager").env[] \ - |= select(.name == "RELATED_IMAGE_GATEKEEPER").value = "$(GATEKEEPER_IMAGE):v$(GATEKEEPER_VERSION)"' \ + |= select(.name == "RELATED_IMAGE_GATEKEEPER").value = "$(GATEKEEPER_IMG)"' \ -i config/manager/manager.yaml # Set version variables for LDFLAGS diff --git a/build/bundle.Dockerfile b/build/bundle.Dockerfile index 3bc1e4790..50b44487a 100644 --- a/build/bundle.Dockerfile +++ b/build/bundle.Dockerfile @@ -22,7 +22,7 @@ LABEL com.redhat.openshift.versions=v4.12 # Bundle metadata LABEL name=gatekeeper/gatekeeper-operator-bundle LABEL description="The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper." -LABEL io.k8s.description=gatekeeper-operator-bundle +LABEL io.k8s.description="The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper." LABEL summary="Red Hat Gatekeeper Operator" LABEL version=v3.17.0 LABEL release="" diff --git a/build/bundle.Dockerfile.rhtap b/build/bundle.Dockerfile.rhtap new file mode 100644 index 000000000..405736821 --- /dev/null +++ b/build/bundle.Dockerfile.rhtap @@ -0,0 +1,37 @@ +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_9_1.22 AS builder + +COPY . . +RUN ./konflux-patch.sh + +FROM scratch + +# Copy files to locations specified by labels. +COPY --from=builder /manifests /manifests/ +COPY --from=builder /metadata /metadata/ + +# Core bundle annotations. +LABEL operators.operatorframework.io.bundle.channel.default.v1=stable +LABEL operators.operatorframework.io.bundle.channels.v1="stable,3.17" +LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/ +LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1 +LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/ +LABEL operators.operatorframework.io.bundle.package.v1=gatekeeper-operator +LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.34.1 +LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1 +LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3 +# Red Hat annotations. +LABEL com.redhat.component=gatekeeper-operator-bundle-container +LABEL com.redhat.delivery.backport=false +LABEL com.redhat.delivery.operator.bundle=true +LABEL com.redhat.openshift.versions=v4.12 +# Bundle metadata +LABEL name=gatekeeper/gatekeeper-operator-bundle +LABEL description="The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper." +LABEL io.k8s.description="The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper." +LABEL summary="Red Hat Gatekeeper Operator" +LABEL version=v3.17.0 +LABEL release="" +LABEL distribution-scope=public +LABEL maintainer="acm-component-maintainers@redhat.com" +LABEL url=https://github.com/stolostron/gatekeeper-operator +LABEL vendor="Red Hat, Inc." diff --git a/build/install-yq.sh b/build/install-yq.sh new file mode 100755 index 000000000..18ecbc2b0 --- /dev/null +++ b/build/install-yq.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +# Install yq command +VERSION="v4.44.3" +ARCH=$(uname -m) +if [[ "$ARCH" == "x86_64" ]]; then + ARCH="amd64" +elif [[ "$ARCH" == "aarch64" ]]; then + ARCH="arm64" +fi + +BINARY="yq_linux_$ARCH" + +curl -s "https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}" -o /usr/bin/yq +chmod +x /usr/bin/yq diff --git a/build/konflux-patch.sh b/build/konflux-patch.sh new file mode 100755 index 000000000..9b5ad21c8 --- /dev/null +++ b/build/konflux-patch.sh @@ -0,0 +1,9 @@ +#! /bin/bash + +# Gatekeeper Operator image +export IMG="quay.io/redhat-user-workloads/gatekeeper-tenant/gatekeeper-operator-3-17/gatekeeper-operator-3-17@sha256:9eeb73c02969ab9c08b867564958133b5f5febc86dfaf6809cd768adcd05ca22" +# Gatekeeper image +export GATEKEEPER_IMG="quay.io/redhat-user-workloads/gatekeeper-tenant/gatekeeper-operator-3-17/gatekeeper-3-17@sha256:ea331b53f5b1ccbc30841cbe81f6faee79101dbb50ecfb7e2ba7a2b944ecc212" + +make update-gatekeeper-image +make bundle diff --git a/bundle/metadata/annotations.yaml b/bundle/metadata/annotations.yaml index d34fd6f6b..ab271e78a 100644 --- a/bundle/metadata/annotations.yaml +++ b/bundle/metadata/annotations.yaml @@ -17,7 +17,7 @@ annotations: # Bundle metadata name: gatekeeper/gatekeeper-operator-bundle description: "The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper." - io.k8s.description: gatekeeper-operator-bundle + io.k8s.description: "The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper." summary: "Red Hat Gatekeeper Operator" version: v3.17.0 release: ""