From aa619621feeeee62f62c124a3f4896e2a7d98ef6 Mon Sep 17 00:00:00 2001 From: Cheng Fang Date: Mon, 29 Jun 2026 15:33:00 -0400 Subject: [PATCH] fix(hack): enhance hack/propagate.sh with git optimization, support custom argocd-operator branch, and inclusion in Makefile targets Signed-off-by: Cheng Fang Co-authored-by: Claude --- Makefile | 12 +++++++++++- hack/propagate.sh | 40 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 16343bc1ddb..5e3c6bf104f 100644 --- a/Makefile +++ b/Makefile @@ -267,7 +267,7 @@ rm -rf $$TMP_DIR ;\ endef .PHONY: bundle -bundle: operator-sdk manifests kustomize ## Generate bundle manifests and metadata, then validate generated files. +bundle: operator-sdk propagate-manifests 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 $(BUNDLE_GEN_FLAGS) @@ -281,6 +281,16 @@ bundle-build: ## Build the bundle image. bundle-push: ## Push the bundle image. $(MAKE) docker-push IMG=$(BUNDLE_IMG) +ARGOCD_OPERATOR_BRANCH ?= master + +# To run propagate-manifests target with the default argocd-operator master brach: +# make propagate-manifests +# To run propagate-manifests target with a custom argocd-operator branch or tag: +# ARGOCD_OPERATOR_BRANCH=release-0.19 make propagate-manifests +.PHONY: propagate-manifests +propagate-manifests: ## compare and propagate manifests from argocd-operator repo + ./hack/propagate.sh --skip-make --from-branch $(ARGOCD_OPERATOR_BRANCH) + .PHONY: opm OPM = ./bin/opm opm: ## Download opm locally if necessary. diff --git a/hack/propagate.sh b/hack/propagate.sh index 769753e88cc..998908fca03 100755 --- a/hack/propagate.sh +++ b/hack/propagate.sh @@ -2,6 +2,34 @@ set -e +FROM_BRANCH="master" +SKIP_MAKE=false + +usage() { + echo "Usage: $0 [--from-branch ] [--skip-make]" + echo "" + echo "Options:" + echo " --from-branch argocd-operator repo branch or tag to source manifests from (default: master)" + echo " --skip-make skip running 'make bundle' after copying changed files (default: false)" + exit 1 +} + +while [[ $# -gt 0 ]]; do + case "$1" in + --from-branch) + FROM_BRANCH="$2" + shift 2 + ;; + --skip-make) + SKIP_MAKE=true + shift + ;; + *) + usage + ;; + esac +done + trap cleanup EXIT function cleanup { @@ -11,7 +39,7 @@ function cleanup { mkdir -p /tmp/argocd-operator-hack -git clone https://github.com/argoproj-labs/argocd-operator.git /tmp/argocd-operator-hack/ +git clone --depth 1 --branch "$FROM_BRANCH" --single-branch --no-tags https://github.com/argoproj-labs/argocd-operator.git /tmp/argocd-operator-hack/ changedFiles=$(diff -qr /tmp/argocd-operator-hack/config/crd/bases/ ../config/crd/bases/ | grep -v argoproj.io_argocdexports.yaml | grep differ | awk -F ' ' '{print $2}') @@ -22,7 +50,11 @@ if [ -z "$changedFiles" ] then echo "No difference found" else - cp ${changedFiles} ../config/crd/bases/ - cd .. - make bundle + cp ${changedFiles} ../config/crd/bases/ + if [ "$SKIP_MAKE" = false ]; then + cd .. + make bundle + else + echo "Skipping 'make bundle' (--skip-make specified)" + fi fi