Skip to content

Commit 9cbc503

Browse files
Update Makefile to handle old versions in OLM (#575)
* Update Makefile to handle old versions in OLM Signed-off-by: Fran Perea <fperea@redhat.com> * Add the REPLACES field to the sync-chart CI file Signed-off-by: Fran Perea <fperea@redhat.com> * Remove yq and allow sed command to run in Linux and MacOS Signed-off-by: Fran Perea <fperea@redhat.com> * 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> * 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> * 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> * 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> * Switch sed to printf for compatibility issues Signed-off-by: Fran Perea <fperea@redhat.com> * Revert change from printf - add options to sed for compatibility Signed-off-by: Fran Perea <fperea@redhat.com> --------- Signed-off-by: Fran Perea <fperea@redhat.com> Signed-off-by: Fran Perea <32894988+fperearodriguez@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 8a54e92 commit 9cbc503

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.github/workflows/sync-chart.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ jobs:
117117
regex: false
118118
exclude: .github/**
119119

120+
- name: Update REPLACES to current version
121+
run: |
122+
current_replaces=$(grep -E '^REPLACES' Makefile | awk -F'=' '{ print $2 }' | xargs)
123+
current_version=$(grep -E '^VERSION' Makefile | awk '{ print $3 }')
124+
echo "Current REPLACES: $current_replaces"
125+
echo "Will set REPLACES to: nginx-ingress-operator.v$current_version"
126+
sed -i "s|^REPLACES ?= .*|REPLACES ?= nginx-ingress-operator.v$current_version|" Makefile
127+
120128
- name: Find and Replace Operator version
121129
uses: jacobtomlinson/gha-find-replace@f1069b438f125e5395d84d1c6fd3b559a7880cb5 # v3.0.5
122130
with:

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
66
VERSION ?= 3.3.1
77

8+
# REPLACES defines the operator version that this version replaces for upgrades (OLM path).
9+
# Set to empty to disable (e.g make bundle REPLACES=)
10+
REPLACES ?= nginx-ingress-operator.v3.2.3
11+
812
# CHANNELS define the bundle channels used in the bundle.
913
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
1014
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
@@ -211,6 +215,14 @@ bundle: kustomize operator-sdk ## Generate bundle manifests and metadata, then v
211215
cd config/default && $(KUSTOMIZE) edit set image kube-rbac-proxy=$(KRP_IMAGE_BASE):$(KRP_IMAGE_VERSION)
212216
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
213217
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
218+
@if [ -n "$(REPLACES)" ]; then \
219+
echo "Adding replaces: $(REPLACES) to ClusterServiceVersion"; \
220+
sed -i.bak '/^ provider:/{h;s/.*/ replaces: $(REPLACES)/;p;x;}' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \
221+
rm -f bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml.bak; \
222+
fi
223+
@echo "Adding skips: [] to ClusterServiceVersion"; \
224+
sed -i.bak '/^ version:/{h;s/.*/ skips: []/;p;x;}' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \
225+
rm -f bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml.bak
214226
@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
215227
@printf "%s\n" '' ' # OpenShift annotations.' ' com.redhat.openshift.versions: $(OPENSHIFT_VERSION)' >> bundle/metadata/annotations.yaml
216228
$(OPERATOR_SDK) bundle validate ./bundle

0 commit comments

Comments
 (0)