Skip to content

Commit

Permalink
Automation to add the 'spec.replaces' annotation (#1748)
Browse files Browse the repository at this point in the history
This allows to have an update graph in Openshift Marketplace Operator updates

Signed-off-by: pjuarezd <pjuarezd@users.noreply.github.com>
  • Loading branch information
pjuarezd authored Aug 31, 2023
1 parent e276f38 commit b552d64
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions olm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ for catalog in "${redhatCatalogs[@]}"; do
yq -i ".spec.install.spec.deployments[0].spec.template.spec.containers[0].image |= (\"${operatorImageDigest}\")" bundles/$catalog/$RELEASE/manifests/$package.clusterserviceversion.yaml
yq -i ".spec.install.spec.deployments[1].spec.template.spec.containers[0].image |= (\"${operatorImageDigest}\")" bundles/$catalog/$RELEASE/manifests/$package.clusterserviceversion.yaml

# To provide channel for upgrade where we tell what versions can be replaced by the new version we offer
# You can read the documentation at link below:
# https://access.redhat.com/documentation/en-us/openshift_container_platform/4.2/html/operators/understanding-the-operator-lifecycle-manager-olm#olm-upgrades_olm-understanding-olm
echo "To provide replacement for upgrading Operator..."
PREV_VERSION=$(curl -s "https://catalog.redhat.com/api/containers/v1/operators/bundles?channel_name=stable&package=${package}&organization=${catalog}&include=data.version,data.csv_name,data.ocp_version" | jq '.data | max_by(.version).csv_name' -r)
echo "replaces: $PREV_VERSION"
yq -i e ".spec.replaces |= \"${PREV_VERSION}\"" bundles/$catalog/$RELEASE/manifests/$package.clusterserviceversion.yaml

# Now promote the latest release to the root of the repository
rm -Rf manifests
rm -Rf metadata
Expand Down

0 comments on commit b552d64

Please sign in to comment.