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: Updating manifests/devspaces.csv.yaml #589

Merged
merged 1 commit into from
Jun 5, 2024
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
40 changes: 20 additions & 20 deletions devspaces-operator-bundle/build/scripts/sync-che-olm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,9 @@ UDI_IMAGE="registry.redhat.io/devspaces/udi-rhel8@${UDI_IMAGE_TAG}"
RBAC_PROXY_IMAGE="registry.redhat.io/openshift4/ose-kube-rbac-proxy:${OPENSHIFT_TAG}"
OAUTH_PROXY_IMAGE="registry.redhat.io/openshift4/ose-oauth-proxy:${OPENSHIFT_TAG}"

CODE_IMAGE_VERSION_ZZZ=$(skopeo inspect docker://quay.io/devspaces/code-rhel8:${DS_VERSION} | yq -r '.RepoTags' | sort -uV | grep "${DS_VERSION}-" | grep -E -v "\.[0-9]{10}" | tr -d '", ' | tail -1)
CODE_IMAGE_DIGEST=$(skopeo inspect docker://quay.io/devspaces/code-rhel8:${CODE_IMAGE_VERSION_ZZZ} | yq -r '.Digest')
CODE_IMAGE="registry.redhat.io/devspaces/code-rhel8@${CODE_IMAGE_DIGEST}"
IDEA_IMAGE_VERSION_ZZZ=$(skopeo inspect docker://quay.io/devspaces/idea-rhel8:${DS_VERSION} | yq -r '.RepoTags' | sort -uV | grep "${DS_VERSION}-" | grep -E -v "\.[0-9]{10}" | tr -d '", ' | tail -1)
IDEA_IMAGE_DIGEST=$(skopeo inspect docker://quay.io/devspaces/idea-rhel8:${IDEA_IMAGE_VERSION_ZZZ} | yq -r '.Digest')
IDEA_IMAGE="registry.redhat.io/devspaces/idea-rhel8@${IDEA_IMAGE_DIGEST}"

EDITORS_DEFINITIONS_ENV_VAR="[
{ name: \"RELATED_IMAGE_editor_definition_che_idea_2022_1_idea_rhel8\", value: \"${UDI_IMAGE}\"},
{ name: \"RELATED_IMAGE_editor_definition_che_idea_2022_1_idea_rhel8_injector\", value: \"${IDEA_IMAGE}\"},
{ name: \"RELATED_IMAGE_editor_definition_che_code_latest_che_code_runtime_description\", value: \"${UDI_IMAGE}\"},
{ name: \"RELATED_IMAGE_editor_definition_che_code_latest_che_code_injector\", value: \"${CODE_IMAGE}\"}
]"
UDI_IMAGE_WITH_TAG="${DS_RRIO}/udi-rhel8:${DS_VERSION}"
CODE_IMAGE_WITH_TAG="${DS_RRIO}/code-rhel8:${DS_VERSION}"
IDEA_IMAGE_WITH_TAG="${DS_RRIO}/idea-rhel8:${DS_VERSION}"

# header to reattach to yaml files after yq transform removes it
COPYRIGHT="#
Expand Down Expand Up @@ -364,6 +354,22 @@ for CSVFILE in ${TARGETDIR}/manifests/devspaces.csv.yaml; do
done
echo "Converted (yq #2) ${CSVFILE}"

# Update editors definitions environment variables in csv
# by removing upstream values and inserting downstream ones
# https://github.com/eclipse-che/che/issues/22932
yq -riY "del(.spec.install.spec.deployments[].spec.template.spec.containers[0].env[] | select(.name | test(\"^RELATED_IMAGE_editor_definition_\")))" "${CSVFILE}"
declare -A operator_insertion=(
["RELATED_IMAGE_editor_definition_che_idea_2022_1_idea_rhel8"]="${UDI_IMAGE_WITH_TAG}"
["RELATED_IMAGE_editor_definition_che_idea_2022_1_idea_rhel8_injector"]="${IDEA_IMAGE_WITH_TAG}"
["RELATED_IMAGE_editor_definition_che_code_latest_che_code_runtime_description"]="${UDI_IMAGE_WITH_TAG}"
["RELATED_IMAGE_editor_definition_che_code_latest_che_code_injector"]="${CODE_IMAGE_WITH_TAG}"
)
for updateName in "${!operator_insertion[@]}"; do
env="{name: \"${updateName}\", value: \"${operator_insertion[$updateName]}\"}"
yq -riY "(.spec.install.spec.deployments[].spec.template.spec.containers[0].env ) += [${env}]" "${CSVFILE}"
done
echo "Converted (yq #3) ${CSVFILE}"

# insert replaces: field
declare -A spec_insertions=(
[".spec.replaces"]="devspacesoperator.v${CSV_VERSION_PREV}"
Expand All @@ -377,13 +383,7 @@ for CSVFILE in ${TARGETDIR}/manifests/devspaces.csv.yaml; do
updateVal="${spec_insertions[$updateName]}"
replaceField "${CSVFILE}" "${updateName}" "${updateVal}" "${COPYRIGHT}"
done
echo "Converted (yq #3) ${CSVFILE}"

# https://github.com/eclipse-che/che/issues/22932
# Update editors definitions environment variables in csv
yq -riY "del(.spec.install.spec.deployments[].spec.template.spec.containers[0].env[] | select(.name | test(\"^RELATED_IMAGE_editor_definition_\")))" "${CSVFILE}"
yq -riY "(.spec.install.spec.deployments[].spec.template.spec.containers[0].env ) += [${EDITORS_DEFINITIONS_ENV_VAR}]" "${CSVFILE}"
echo "Converted (yq #3) ${CSVFILE}"
echo "Converted (yq #4) ${CSVFILE}"

# add more RELATED_IMAGE_ fields for the images referenced by the registries
bash -e "${SCRIPTS_DIR}/insert-related-images-to-csv.sh" -v "${CSV_VERSION}" -t "${TARGETDIR}" --ds-branch "${MIDSTM_BRANCH}"
Expand Down
4 changes: 2 additions & 2 deletions devspaces-operator/build/scripts/sync-che-operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ OAUTH_PROXY_IMAGE="registry.redhat.io/openshift4/ose-oauth-proxy:${OPENSHIFT_TAG

CODE_IMAGE_VERSION_ZZZ=$(skopeo inspect docker://quay.io/devspaces/code-rhel8:${DS_VERSION} | yq -r '.RepoTags' | sort -uV | grep -v "source" | grep "${DS_VERSION}-" | grep -E -v "\.[0-9]{10}" | tr -d '", ' | tail -1)
CODE_IMAGE_DIGEST=$(skopeo inspect docker://quay.io/devspaces/code-rhel8:${CODE_IMAGE_VERSION_ZZZ} | yq -r '.Digest')
CODE_IMAGE="registry.redhat.io/devspaces/code-rhel8@${CODE_IMAGE_DIGEST}"
CODE_IMAGE="${DS_RRIO}/code-rhel8@${CODE_IMAGE_DIGEST}"
IDEA_IMAGE_VERSION_ZZZ=$(skopeo inspect docker://quay.io/devspaces/idea-rhel8:${DS_VERSION} | yq -r '.RepoTags' | sort -uV | grep "${DS_VERSION}-" | grep -E -v "\.[0-9]{10}" | tr -d '", ' | tail -1)
IDEA_IMAGE_DIGEST=$(skopeo inspect docker://quay.io/devspaces/idea-rhel8:${IDEA_IMAGE_VERSION_ZZZ} | yq -r '.Digest')
IDEA_IMAGE="registry.redhat.io/devspaces/idea-rhel8@${IDEA_IMAGE_DIGEST}"
IDEA_IMAGE="${DS_RRIO}/idea-rhel8@${IDEA_IMAGE_DIGEST}"

# global / generic changes
pushd "${SOURCEDIR}" >/dev/null
Expand Down