Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove previous RELATED_IMAGES before adding new ones #967

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
mmorhun marked this conversation as resolved.
Show resolved Hide resolved
yq -riY 'del(.spec.template.spec.containers[0].env['${i}'])' ${OPERATOR_FILE}
i=$((i-1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I'd remove this decrement and put the following increment into else block.
  2. Shouldn't you change the total number of env vars too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I've thought about it but this approach sounds more explicit
  2. It does not matter, there are no errors, yq returns null as a string

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I have opposite opinion, but ok.
  2. That's logically wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It is not a c++ or java. We have to processed all records, other doesn't matter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a source of errors. If yq behavior changes or someone add another line that doesn't tolerate index error... but up to you...

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