Skip to content

Commit

Permalink
fix: Remove previous RELATED_IMAGES before adding new ones (#967)
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha authored Jul 26, 2021
1 parent 2e41ee4 commit 833b3aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion olm/addDigests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,22 @@ yq -riY "( .spec.relatedImages ) += [${RELATED_IMAGES}]" ${CSV_FILE}
yq -riY "( .spec.install.spec.deployments[0].spec.template.spec.containers[0].env ) += [${RELATED_IMAGES_ENV}]" ${CSV_FILE}
sed -i "${CSV_FILE}" -r -e "s|tag: |# tag: |"
echo -e "$(cat ${SCRIPTS_DIR}/license.txt)\n$(cat ${CSV_FILE})" > ${CSV_FILE}

echo "[INFO] CSV updated: ${CSV_FILE}"

if [[ ${OPERATOR_FILE} ]]; then
# delete previous `RELATED_IMAGES`
envVarLength=$(cat "${OPERATOR_FILE}" | yq -r ".spec.template.spec.containers[0].env | length")
i=0
while [ "${i}" -lt "${envVarLength}" ]; do
envVarName=$(cat "${OPERATOR_FILE}" | yq -r '.spec.template.spec.containers[0].env['${i}'].name')
if [[ ${envVarName} =~ plugin_registry_image ]] || [[ ${envVarName} =~ devfile_registry_image ]]; then
yq -riY 'del(.spec.template.spec.containers[0].env['${i}'])' ${OPERATOR_FILE}
i=$((i-1))
fi
i=$((i+1))
done

# add new `RELATED_IMAGES`
yq -riY "( .spec.template.spec.containers[0].env ) += [${RELATED_IMAGES_ENV}]" ${OPERATOR_FILE}
echo -e "$(cat ${SCRIPTS_DIR}/license.txt)\n$(cat ${OPERATOR_FILE})" > ${OPERATOR_FILE}
echo "[INFO] Operator deployment file updated: ${OPERATOR_FILE}"
Expand Down
2 changes: 1 addition & 1 deletion olm/release-olm-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ do
source ${BASE_DIR}/addDigests.sh -w ${BASE_DIR} \
-t "${RELEASE}" \
-s "${STABLE_BUNDLE_PATH}/manifests/che-operator.clusterserviceversion.yaml" \
-o "${OPERATOR_DIR}/deploy/operator.yaml"
-o "${OPERATOR_DIR}/config/manager/manager.yaml"

popd || true

Expand Down

0 comments on commit 833b3aa

Please sign in to comment.