Skip to content

Commit

Permalink
Handle bundle annotations manually
Browse files Browse the repository at this point in the history
This is necessary now that we're migrating to
Konflux--this was previously handled in CPAAS.

Signed-off-by: Dale Haiducek <[email protected]>
  • Loading branch information
dhaiducek committed Oct 31, 2024
1 parent bdd142b commit 7f09a86
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<base64-string>"/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
Expand Down
21 changes: 12 additions & 9 deletions build/bundle.Dockerfile
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions bundle/metadata/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7f09a86

Please sign in to comment.