From 7f09a8651ab0434e73262d7e510f91c87fcb58d0 Mon Sep 17 00:00:00 2001 From: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com> Date: Thu, 31 Oct 2024 08:14:58 -0400 Subject: [PATCH] Handle bundle annotations manually This is necessary now that we're migrating to Konflux--this was previously handled in CPAAS. Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com> --- Makefile | 8 ++++++-- build/bundle.Dockerfile | 21 ++++++++++++--------- bundle/metadata/annotations.yaml | 5 +++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index a4fbab75d..e4a61d36b 100644 --- a/Makefile +++ b/Makefile @@ -311,19 +311,23 @@ operator-sdk: $(OPERATOR_SDK) bundle: operator-sdk manifests kustomize ## Generate bundle manifests and metadata, then validate generated files. $(OPERATOR_SDK) generate kustomize manifests -q cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) - $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) + $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --manifests --overwrite --version $(VERSION) $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) # Set base64data in CSV with SVG logo: $(SED) -i 's/base64data: ""/base64data: ""/g' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml @$(SED) -i 's/base64data: \"\"/base64data: \"$(shell $(BASE64) -i bundle/logo.svg)\"/g' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml $(SED) -i 's/mediatype: \"\"/mediatype: \"image\/svg+xml\"/g' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml $(SED) -i 's/^ version:.*/ version: "$(VERSION)"/' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml $(SED) -i '/^ createdAt:.*/d' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml - $(SED) -i 's/$(CHANNELS)/"$(CHANNELS)"/g' bundle/metadata/annotations.yaml + $(SED) -i 's/$(CHANNELS)/$(CHANNELS)/g' bundle/metadata/annotations.yaml $(SED) -i 's/^ olm.skipRange:.*/ olm.skipRange: "<$(VERSION)"/' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml ifneq ($(REPLACES_VERSION), none) $(SED) -i 's/^ replaces:.*/ replaces: gatekeeper-operator.v$(REPLACES_VERSION)/' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml else $(SED) -i 's/^ replaces:.*/ # replaces: none/' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml endif + awk '/FROM/,/# Core bundle annotations./' build/bundle.Dockerfile | sed '$$d' > build/bundle.Dockerfile.tmp + mv build/bundle.Dockerfile.tmp build/bundle.Dockerfile + yq '.annotations' bundle/metadata/annotations.yaml | sed 's/: /=/' | sed 's/^\([^#]\)/LABEL \1/' >> build/bundle.Dockerfile + $(OPERATOR_SDK) bundle validate ./bundle .PHONY: bundle-build diff --git a/build/bundle.Dockerfile b/build/bundle.Dockerfile index d836ea497..778740b17 100644 --- a/build/bundle.Dockerfile +++ b/build/bundle.Dockerfile @@ -1,21 +1,24 @@ FROM scratch -# Core bundle labels. +# Copy files to locations specified by labels. +COPY bundle/manifests /manifests/ +COPY bundle/metadata /metadata/ +COPY bundle/tests/scorecard /tests/scorecard/ + +# Core bundle annotations. LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1 LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/ LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/ LABEL operators.operatorframework.io.bundle.package.v1=gatekeeper-operator -LABEL operators.operatorframework.io.bundle.channels.v1=stable,3.17 +LABEL operators.operatorframework.io.bundle.channels.v1="stable,3.17" LABEL operators.operatorframework.io.bundle.channel.default.v1=stable 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 - -# Labels for testing. +# Annotations for testing. LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1 LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/ - -# Copy files to locations specified by labels. -COPY bundle/manifests /manifests/ -COPY bundle/metadata /metadata/ -COPY bundle/tests/scorecard /tests/scorecard/ +# Red Hat annotations. +LABEL com.redhat.delivery.operator.bundle=true +LABEL com.redhat.openshift.versions=X.Y +LABEL com.redhat.delivery.backport=false diff --git a/bundle/metadata/annotations.yaml b/bundle/metadata/annotations.yaml index ae2bd552a..3834693e6 100644 --- a/bundle/metadata/annotations.yaml +++ b/bundle/metadata/annotations.yaml @@ -13,3 +13,8 @@ annotations: # Annotations for testing. operators.operatorframework.io.test.mediatype.v1: scorecard+v1 operators.operatorframework.io.test.config.v1: tests/scorecard/ + + # Red Hat annotations. + com.redhat.delivery.operator.bundle: true + com.redhat.openshift.versions: X.Y + com.redhat.delivery.backport: false