From c72f052a0b11dcb40a89c6cfa52e90180a0504f8 Mon Sep 17 00:00:00 2001 From: Fran Perea Date: Tue, 23 Sep 2025 01:38:45 +0200 Subject: [PATCH 1/9] Update Makefile to handle old versions in OLM Signed-off-by: Fran Perea --- Makefile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Makefile b/Makefile index 6fc8b61d..291d33b7 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,10 @@ # - use environment variables to overwrite this value (e.g export VERSION=0.0.2) VERSION ?= 3.3.0 +# REPLACES defines the operator version that this version replaces for upgrades (OLM path). +# Set to empty to disable (e.g make bundle REPLACES=) +REPLACES ?= nginx-ingress-operator.v3.2.3 + # CHANNELS define the bundle channels used in the bundle. # Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable") # To re-generate a bundle for other specific channels without changing the standard setup, you can: @@ -201,6 +205,20 @@ bundle: kustomize operator-sdk ## Generate bundle manifests and metadata, then v cd config/default && $(KUSTOMIZE) edit set image kube-rbac-proxy=$(KRP_IMAGE_BASE):$(KRP_IMAGE_TAG) if [ -n "$(IMAGE_PULL_SECRET_NAME)" ]; then cd config/default && $(KUSTOMIZE) edit add patch --kind Deployment --group apps --version v1 --name controller-manager --patch '${image_pull_secrets_patch}'; fi $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) + @if [ -n "$(REPLACES)" ]; then \ + echo "Adding replaces: $(REPLACES) to ClusterServiceVersion"; \ + if command -v yq >/dev/null 2>&1; then \ + yq eval '.spec.replaces = "$(REPLACES)"' -i bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml; \ + else \ + sed -i 's|^ provider:| replaces: $(REPLACES)\n provider:|' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml; \ + fi; \ + fi + @echo "Adding skips: [] to ClusterServiceVersion"; \ + if command -v yq >/dev/null 2>&1; then \ + yq eval '.spec.skips = []' -i bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml; \ + else \ + sed -i 's|^ version:| skips: []\n version:|' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml; \ + fi @printf "%s\n" '' 'LABEL com.redhat.openshift.versions="$(OPENSHIFT_VERSION)"' 'LABEL com.redhat.delivery.operator.bundle=true' 'LABEL com.redhat.delivery.backport=true' >> bundle.Dockerfile @printf "%s\n" '' ' # OpenShift annotations.' ' com.redhat.openshift.versions: $(OPENSHIFT_VERSION)' >> bundle/metadata/annotations.yaml $(OPERATOR_SDK) bundle validate ./bundle From faba5046bfd817bb41f757877c1208820e56235d Mon Sep 17 00:00:00 2001 From: Fran Perea Date: Thu, 23 Oct 2025 16:40:50 +0200 Subject: [PATCH 2/9] Add the REPLACES field to the sync-chart CI file Signed-off-by: Fran Perea --- .github/workflows/sync-chart.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/sync-chart.yml b/.github/workflows/sync-chart.yml index f7a34d58..43291ea2 100644 --- a/.github/workflows/sync-chart.yml +++ b/.github/workflows/sync-chart.yml @@ -117,6 +117,14 @@ jobs: regex: false exclude: .github/** + - name: Update REPLACES to current version + run: | + current_replaces=$(egrep '^REPLACES' Makefile | awk -F'=' '{ print $2 }' | xargs) + current_version=$(egrep '^VERSION' Makefile | awk '{ print $3 }') + echo "Current REPLACES: $current_replaces" + echo "Will set REPLACES to: nginx-ingress-operator.v$current_version" + sed -i "s|^REPLACES ?= .*|REPLACES ?= nginx-ingress-operator.v$current_version|" Makefile + - name: Find and Replace Operator version uses: jacobtomlinson/gha-find-replace@f1069b438f125e5395d84d1c6fd3b559a7880cb5 # v3.0.5 with: From 5aa42f11aae7b169e0936918ef064c79d5bf9f4a Mon Sep 17 00:00:00 2001 From: Fran Perea Date: Thu, 23 Oct 2025 17:51:12 +0200 Subject: [PATCH 3/9] Remove yq and allow sed command to run in Linux and MacOS Signed-off-by: Fran Perea --- Makefile | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index caaf25c9..bedefb0e 100644 --- a/Makefile +++ b/Makefile @@ -217,18 +217,12 @@ bundle: kustomize operator-sdk ## Generate bundle manifests and metadata, then v $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) @if [ -n "$(REPLACES)" ]; then \ echo "Adding replaces: $(REPLACES) to ClusterServiceVersion"; \ - if command -v yq >/dev/null 2>&1; then \ - yq eval '.spec.replaces = "$(REPLACES)"' -i bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml; \ - else \ - sed -i 's|^ provider:| replaces: $(REPLACES)\n provider:|' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml; \ - fi; \ + sed -i.bak 's|^ provider:| replaces: $(REPLACES)\n provider:|' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ + rm -f bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml.bak; \ fi @echo "Adding skips: [] to ClusterServiceVersion"; \ - if command -v yq >/dev/null 2>&1; then \ - yq eval '.spec.skips = []' -i bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml; \ - else \ - sed -i 's|^ version:| skips: []\n version:|' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml; \ - fi + sed -i.bak 's|^ version:| skips: []\n version:|' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ + rm -f bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml.bak @printf "%s\n" '' 'LABEL com.redhat.openshift.versions="$(OPENSHIFT_VERSION)"' 'LABEL com.redhat.delivery.operator.bundle=true' 'LABEL com.redhat.delivery.backport=true' >> bundle.Dockerfile @printf "%s\n" '' ' # OpenShift annotations.' ' com.redhat.openshift.versions: $(OPENSHIFT_VERSION)' >> bundle/metadata/annotations.yaml $(OPERATOR_SDK) bundle validate ./bundle From 6de4b82ad9a6373d0ca3aef05c801a48b52c1184 Mon Sep 17 00:00:00 2001 From: Fran Perea <32894988+fperearodriguez@users.noreply.github.com> Date: Mon, 10 Nov 2025 23:17:35 +0100 Subject: [PATCH 4/9] Update Makefile Change the sed command to use a more portable approach. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Fran Perea <32894988+fperearodriguez@users.noreply.github.com> --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bedefb0e..96c97e4f 100644 --- a/Makefile +++ b/Makefile @@ -217,7 +217,7 @@ bundle: kustomize operator-sdk ## Generate bundle manifests and metadata, then v $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) @if [ -n "$(REPLACES)" ]; then \ echo "Adding replaces: $(REPLACES) to ClusterServiceVersion"; \ - sed -i.bak 's|^ provider:| replaces: $(REPLACES)\n provider:|' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ + sed -i.bak -e '/^ provider:/i\' -e ' replaces: $(REPLACES)' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ rm -f bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml.bak; \ fi @echo "Adding skips: [] to ClusterServiceVersion"; \ From de888106b9b84db478d3ecb18f504a6289dc6fee Mon Sep 17 00:00:00 2001 From: Fran Perea <32894988+fperearodriguez@users.noreply.github.com> Date: Mon, 10 Nov 2025 23:18:12 +0100 Subject: [PATCH 5/9] Update Makefile Change the sed command to use a more portable approach. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Fran Perea <32894988+fperearodriguez@users.noreply.github.com> --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 96c97e4f..6c8682b1 100644 --- a/Makefile +++ b/Makefile @@ -221,7 +221,9 @@ bundle: kustomize operator-sdk ## Generate bundle manifests and metadata, then v rm -f bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml.bak; \ fi @echo "Adding skips: [] to ClusterServiceVersion"; \ - sed -i.bak 's|^ version:| skips: []\n version:|' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ + sed -i.bak -e '/^ version:/i\ + skips: [] + ' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ rm -f bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml.bak @printf "%s\n" '' 'LABEL com.redhat.openshift.versions="$(OPENSHIFT_VERSION)"' 'LABEL com.redhat.delivery.operator.bundle=true' 'LABEL com.redhat.delivery.backport=true' >> bundle.Dockerfile @printf "%s\n" '' ' # OpenShift annotations.' ' com.redhat.openshift.versions: $(OPENSHIFT_VERSION)' >> bundle/metadata/annotations.yaml From 8d20d0c338998f73666f70a0175663261cfd6da1 Mon Sep 17 00:00:00 2001 From: Fran Perea <32894988+fperearodriguez@users.noreply.github.com> Date: Mon, 10 Nov 2025 23:19:23 +0100 Subject: [PATCH 6/9] Update .github/workflows/sync-chart.yml Change the grep command to avoid a deprecated option. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Fran Perea <32894988+fperearodriguez@users.noreply.github.com> --- .github/workflows/sync-chart.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-chart.yml b/.github/workflows/sync-chart.yml index 43291ea2..f73efc05 100644 --- a/.github/workflows/sync-chart.yml +++ b/.github/workflows/sync-chart.yml @@ -119,7 +119,7 @@ jobs: - name: Update REPLACES to current version run: | - current_replaces=$(egrep '^REPLACES' Makefile | awk -F'=' '{ print $2 }' | xargs) + current_replaces=$(grep -E '^REPLACES' Makefile | awk -F'=' '{ print $2 }' | xargs) current_version=$(egrep '^VERSION' Makefile | awk '{ print $3 }') echo "Current REPLACES: $current_replaces" echo "Will set REPLACES to: nginx-ingress-operator.v$current_version" From 680e7e7a98b7234ee0e0bc193b698fcf82568497 Mon Sep 17 00:00:00 2001 From: Fran Perea <32894988+fperearodriguez@users.noreply.github.com> Date: Mon, 10 Nov 2025 23:19:48 +0100 Subject: [PATCH 7/9] Update .github/workflows/sync-chart.yml Change the grep command to avoid a deprecated option. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Fran Perea <32894988+fperearodriguez@users.noreply.github.com> --- .github/workflows/sync-chart.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-chart.yml b/.github/workflows/sync-chart.yml index f73efc05..8f08e746 100644 --- a/.github/workflows/sync-chart.yml +++ b/.github/workflows/sync-chart.yml @@ -120,7 +120,7 @@ jobs: - name: Update REPLACES to current version run: | current_replaces=$(grep -E '^REPLACES' Makefile | awk -F'=' '{ print $2 }' | xargs) - current_version=$(egrep '^VERSION' Makefile | awk '{ print $3 }') + current_version=$(grep -E '^VERSION' Makefile | awk '{ print $3 }') echo "Current REPLACES: $current_replaces" echo "Will set REPLACES to: nginx-ingress-operator.v$current_version" sed -i "s|^REPLACES ?= .*|REPLACES ?= nginx-ingress-operator.v$current_version|" Makefile From 62e3c93ac84ca8481fe10b2db40ad7204923ddc3 Mon Sep 17 00:00:00 2001 From: Fran Perea Date: Tue, 11 Nov 2025 16:19:36 +0100 Subject: [PATCH 8/9] Switch sed to printf for compatibility issues Signed-off-by: Fran Perea --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 6c8682b1..9bdf66a3 100644 --- a/Makefile +++ b/Makefile @@ -217,13 +217,13 @@ bundle: kustomize operator-sdk ## Generate bundle manifests and metadata, then v $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) @if [ -n "$(REPLACES)" ]; then \ echo "Adding replaces: $(REPLACES) to ClusterServiceVersion"; \ - sed -i.bak -e '/^ provider:/i\' -e ' replaces: $(REPLACES)' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ + REPLACES_LINE=$$(printf " replaces: %s" "$(REPLACES)"); \ + sed -i.bak "/^ provider:/i\\$${REPLACES_LINE}" bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ rm -f bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml.bak; \ fi @echo "Adding skips: [] to ClusterServiceVersion"; \ - sed -i.bak -e '/^ version:/i\ - skips: [] - ' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ + SKIPS_LINE=$$(printf " skips: []"); \ + sed -i.bak "/^ version:/i\\$${SKIPS_LINE}" bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ rm -f bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml.bak @printf "%s\n" '' 'LABEL com.redhat.openshift.versions="$(OPENSHIFT_VERSION)"' 'LABEL com.redhat.delivery.operator.bundle=true' 'LABEL com.redhat.delivery.backport=true' >> bundle.Dockerfile @printf "%s\n" '' ' # OpenShift annotations.' ' com.redhat.openshift.versions: $(OPENSHIFT_VERSION)' >> bundle/metadata/annotations.yaml From 355480dccb9d77d720075e0f41604e88b1855b2d Mon Sep 17 00:00:00 2001 From: Fran Perea Date: Tue, 11 Nov 2025 17:10:27 +0100 Subject: [PATCH 9/9] Revert change from printf - add options to sed for compatibility Signed-off-by: Fran Perea --- Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 9bdf66a3..2495cda8 100644 --- a/Makefile +++ b/Makefile @@ -217,13 +217,11 @@ bundle: kustomize operator-sdk ## Generate bundle manifests and metadata, then v $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) @if [ -n "$(REPLACES)" ]; then \ echo "Adding replaces: $(REPLACES) to ClusterServiceVersion"; \ - REPLACES_LINE=$$(printf " replaces: %s" "$(REPLACES)"); \ - sed -i.bak "/^ provider:/i\\$${REPLACES_LINE}" bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ + sed -i.bak '/^ provider:/{h;s/.*/ replaces: $(REPLACES)/;p;x;}' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ rm -f bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml.bak; \ fi @echo "Adding skips: [] to ClusterServiceVersion"; \ - SKIPS_LINE=$$(printf " skips: []"); \ - sed -i.bak "/^ version:/i\\$${SKIPS_LINE}" bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ + sed -i.bak '/^ version:/{h;s/.*/ skips: []/;p;x;}' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ rm -f bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml.bak @printf "%s\n" '' 'LABEL com.redhat.openshift.versions="$(OPENSHIFT_VERSION)"' 'LABEL com.redhat.delivery.operator.bundle=true' 'LABEL com.redhat.delivery.backport=true' >> bundle.Dockerfile @printf "%s\n" '' ' # OpenShift annotations.' ' com.redhat.openshift.versions: $(OPENSHIFT_VERSION)' >> bundle/metadata/annotations.yaml