Skip to content

Commit

Permalink
fix make bundle
Browse files Browse the repository at this point in the history
Signed-off-by: Eguzki Astiz Lezaun <[email protected]>
  • Loading branch information
eguzki committed Nov 11, 2024
1 parent 05a28f4 commit 5c45eff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,6 @@ define update-csv-config
$(YQ) eval '$(3) = strenv(V)' -i $2
endef

define update-operator-dependencies
V=`$(PROJECT_PATH)/utils/parse-bundle-version.sh $(OPM) $(YQ) $2` \
$(YQ) eval '(.dependencies[] | select(.value.packageName == "$1").value.version) = strenv(V)' -i bundle/metadata/dependencies.yaml
endef

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) crd paths="./api/v1beta1;./api/v1" output:crd:artifacts:config=config/crd/bases
Expand Down Expand Up @@ -414,15 +409,17 @@ bundle: $(OPM) $(YQ) manifests dependencies-manifests kustomize operator-sdk ##
bundle-post-generate: OPENSHIFT_VERSIONS_ANNOTATION_KEY="com.redhat.openshift.versions"
# Supports Openshift v4.12+ (https://redhat-connect.gitbook.io/certified-operator-guide/ocp-deployment/operator-metadata/bundle-directory/managing-openshift-versions)
bundle-post-generate: OPENSHIFT_SUPPORTED_VERSIONS="v4.12"
bundle-post-generate:
bundle-post-generate: $(YQ) $(OPM)
# Set Openshift version in bundle annotations
$(YQ) -i '.annotations[$(OPENSHIFT_VERSIONS_ANNOTATION_KEY)] = $(OPENSHIFT_SUPPORTED_VERSIONS)' bundle/metadata/annotations.yaml
$(YQ) -i '(.annotations[$(OPENSHIFT_VERSIONS_ANNOTATION_KEY)] | key) headComment = "Custom annotations"' bundle/metadata/annotations.yaml
# Update operator dependencies
# TODO(eguzki): run only if not default one. Avoid bundle parsing if version is known in advance
$(call update-operator-dependencies,limitador-operator,$(LIMITADOR_OPERATOR_BUNDLE_IMG))
$(call update-operator-dependencies,authorino-operator,$(AUTHORINO_OPERATOR_BUNDLE_IMG))
$(call update-operator-dependencies,dns-operator,$(DNS_OPERATOR_BUNDLE_IMG))
PATH=$(PROJECT_PATH)/bin:$$PATH; \
$(PROJECT_PATH)/utils/update-operator-dependencies.sh limitador-operator $(LIMITADOR_OPERATOR_BUNDLE_IMG)
PATH=$(PROJECT_PATH)/bin:$$PATH; \
$(PROJECT_PATH)/utils/update-operator-dependencies.sh authorino-operator $(AUTHORINO_OPERATOR_BUNDLE_IMG)
PATH=$(PROJECT_PATH)/bin:$$PATH; \
$(PROJECT_PATH)/utils/update-operator-dependencies.sh dns-operator $(DNS_OPERATOR_BUNDLE_IMG)

.PHONY: bundle-ignore-createdAt
bundle-ignore-createdAt:
Expand Down
13 changes: 13 additions & 0 deletions utils/update-operator-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -euo pipefail

COMPONENT="${1?:Error \$COMPONENT not set. Bye}"
IMG="${2?:Error \$IMG not set. Bye}"

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
DEP_FILE="${SCRIPT_DIR}/../bundle/metadata/dependencies.yaml"
V="$( ${SCRIPT_DIR}/parse-bundle-version.sh opm yq ${IMG} )"

COMPONENT=$COMPONENT V=$V \
yq eval '(.dependencies[] | select(.value.packageName == strenv(COMPONENT)).value.version) = strenv(V)' -i $DEP_FILE

0 comments on commit 5c45eff

Please sign in to comment.