From dd557b8ebfdc4b75f28076a5654bd2012844eba6 Mon Sep 17 00:00:00 2001 From: Marcin Owsiany Date: Thu, 29 Jan 2026 12:52:28 +0100 Subject: [PATCH] chore(operator): wrapper for bundle helpers --- operator/Makefile | 6 ++-- operator/bundle_helpers/dispatch.sh | 32 +++++++++++++++++++ .../prepare-bundle-manifests.sh | 2 +- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100755 operator/bundle_helpers/dispatch.sh diff --git a/operator/Makefile b/operator/Makefile index 919cd8e57f205..e165979814c11 100644 --- a/operator/Makefile +++ b/operator/Makefile @@ -457,10 +457,10 @@ bundle: yq manifests kustomize operator-sdk ## Generate bundle manifests and met # Yet we want most of the contents autogenerated from the Makefile variables as a single source of truth. # Therefore we append ".extra" file to the end of bundle's dockerfile. cat bundle.Dockerfile.extra >> bundle.Dockerfile -# Run a python script to fix the orders in the specDescriptors (children must not appear before their parents). +# Fix the orders in the specDescriptors (children must not appear before their parents). set -euo pipefail ;\ $(ACTIVATE_PYTHON) ;\ - bundle_helpers/fix-spec-descriptor-order.py \ + ./bundle_helpers/dispatch.sh fix-spec-descriptor-order \ bundle/manifests/rhacs-operator.clusterserviceversion.yaml.fixed mv bundle/manifests/rhacs-operator.clusterserviceversion.yaml.fixed \ @@ -472,7 +472,7 @@ bundle-post-process: test-bundle-helpers operator-sdk ## Post-process CSV file t set -euo pipefail ;\ $(ACTIVATE_PYTHON) ;\ first_version=3.62.0 `# 3.62.0 is the first operator version ever released` ;\ - candidate_version=$$(./bundle_helpers/patch-csv.py \ + candidate_version=$$(./bundle_helpers/dispatch.sh patch-csv \ --use-version $(VERSION) \ --first-version $${first_version} \ --operator-image $(IMG) \ diff --git a/operator/bundle_helpers/dispatch.sh b/operator/bundle_helpers/dispatch.sh new file mode 100755 index 0000000000000..1cab887ffc1d4 --- /dev/null +++ b/operator/bundle_helpers/dispatch.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# +# Wrapper script for bundle helper tools. +# +# Provides an abstraction layer that allows switching between Python and Go +# implementations of bundle helper scripts without changing Makefile or Dockerfiles. +# The implementation is selected via the USE_GO_BUNDLE_HELPER environment variable. +# +# Usage: dispatch.sh [args...] + +set -euo pipefail + +if [[ $# -lt 1 ]]; then + echo "Usage: $0 [args...]" >&2 + echo "Available scripts: fix-spec-descriptor-order, patch-csv" >&2 + exit 1 +fi + +script_name="$1" +shift + +script_dir="$(dirname "$0")" + +case "$script_name" in +fix-spec-descriptor-order|patch-csv) + if [[ "${USE_GO_BUNDLE_HELPER:-false}" == "true" ]]; then + echo "No Go implementation of $script_name available yet." >&2 + exit 1 + fi + exec "${script_dir}/${script_name}.py" "$@" + ;; +esac diff --git a/operator/bundle_helpers/prepare-bundle-manifests.sh b/operator/bundle_helpers/prepare-bundle-manifests.sh index d08bfc9f8a61a..b363fac844030 100755 --- a/operator/bundle_helpers/prepare-bundle-manifests.sh +++ b/operator/bundle_helpers/prepare-bundle-manifests.sh @@ -9,6 +9,6 @@ mkdir -p build/ rm -rf build/bundle cp -a bundle build/ -"$(dirname "$0")/patch-csv.py" "$@" \ +"$(dirname "$0")/dispatch.sh" patch-csv "$@" \ < bundle/manifests/rhacs-operator.clusterserviceversion.yaml \ > build/bundle/manifests/rhacs-operator.clusterserviceversion.yaml