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

feat: Use editors definitions configmaps #575

Merged
merged 7 commits 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# insert RELATED_IMAGE_ fields for images referenced by the plugin and devfile registries
# insert RELATED_IMAGE_ fields for images referenced by the devfile registry

tmpfile=$(mktemp)
echo ${image} | sed -r \
`# for plugin & devfile registries, use internal Brew versions` \
-e "s|registry.redhat.io/devspaces/(pluginregistry-rhel8:.+)|registry-proxy.engineering.redhat.com/rh-osbs/devspaces-\1|g" \
`# for devfile registry, use internal Brew versions` \
-e "s|registry.redhat.io/devspaces/(devfileregistry-rhel8:.+)|registry-proxy.engineering.redhat.com/rh-osbs/devspaces-\1|g" \
`# in all other cases (including operator) use published quay images to compute digests` \
-e "s|registry.redhat.io/devspaces/(.+)|quay.io/devspaces/\\1|g" \
Expand Down
2 changes: 0 additions & 2 deletions devspaces-operator-bundle/build/scripts/digestExcludeList
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
quay.io/eclipse/che-sidecar-workspace-data-sync:latest
quay.io/eclipse/che-machine-exec:nightly
9 changes: 1 addition & 8 deletions devspaces-operator-bundle/build/scripts/images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,11 @@ setOperatorImage() {
OPERATOR_IMAGE=$(yq -r '.spec.install.spec.deployments[].spec.template.spec.containers[].image' "${CSV}")
}

setPluginRegistryList() {
registry=$(yq -r '.spec.install.spec.deployments[].spec.template.spec.containers[].env[] | select(.name | test("RELATED_IMAGE_.*plugin_registry"; "g")) | .value' "${CSV}")
setRegistryImages "${registry}"

PLUGIN_REGISTRY_LIST=${registryImages}
}

setDevfileRegistryList() {
registry=$(yq -r '.spec.install.spec.deployments[].spec.template.spec.containers[].env[] | select(.name | test("RELATED_IMAGE_.*devfile_registry"; "g")) | .value' "${CSV}")

setRegistryImages "${registry}"
DEVFILE_REGISTRY_LIST=${registryImages}
DEVFILE_REGISTRY_LIST=${registryImages}
}

setRegistryImages() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# insert RELATED_IMAGE_ fields for images referenced by the plugin and devfile registries
# insert RELATED_IMAGE_ fields for images referenced by the devfile registry

set -e
# SCRIPTS_DIR=$(cd "$(dirname "$0")"; pwd)
Expand Down Expand Up @@ -51,28 +51,22 @@ if [[ ! -x $PODMAN ]]; then
fi
fi

PLUGIN_REGISTRY_CONTAINERS=""
DEVFILE_REGISTRY_CONTAINERS=""
tmpdir=$(mktemp -d); mkdir -p $tmpdir; pushd $tmpdir >/dev/null
# extract registry containers to get external_images.txt
curl -sSLO https://raw.githubusercontent.com/redhat-developer/devspaces/devspaces-3-rhel-8/product/containerExtract.sh && chmod +x containerExtract.sh
./containerExtract.sh quay.io/devspaces/devfileregistry-rhel8:${DS_VERSION} --tar-flags var/www/html/*/external_images.txt --delete-before &
./containerExtract.sh quay.io/devspaces/pluginregistry-rhel8:${DS_VERSION} --tar-flags var/www/html/*/external_images.txt --delete-before &
wait

# CRW-3432 fail if we can't find the external_images.txt files
if [[ ! $(cat /tmp/quay.io-devspaces-devfileregistry-rhel8-${DS_VERSION}*/var/www/html/*/external_images.txt) ]]; then
echo "[ERROR] Cannot resolve devfileregistry external_images.txt!"
exit 2
fi
if [[ ! $(cat /tmp/quay.io-devspaces-pluginregistry-rhel8-${DS_VERSION}*/var/www/html/*/external_images.txt) ]]; then
echo "[ERROR] Cannot resolve pluginregistry external_images.txt!"
exit 3
fi

# CRW-3177, CRW-3178 sort uniquely; replace quay refs with RHEC refs
# remove ghcr.io/ansible/ansible-workspace-env-reference from EXTERNAL_IMAGES
EXTERNAL_IMAGES=$(cat /tmp/quay.io-devspaces-{devfile,plugin}registry-rhel8-${DS_VERSION}*/var/www/html/*/external_images.txt | \
EXTERNAL_IMAGES=$(cat /tmp/quay.io-devspaces-devfileregistry-rhel8-${DS_VERSION}*/var/www/html/*/external_images.txt | \
sed -r -e '/^ghcr\.io\/ansible\/ansible-workspace-env-reference/d' \
-e "s#quay.io/devspaces/#registry.redhat.io/devspaces/#g" | sort -uV)

Expand All @@ -82,11 +76,10 @@ tmpdir=$(mktemp -d); mkdir -p $tmpdir; pushd $tmpdir >/dev/null
echo "${EXTERNAL_IMAGES[@]}"
popd >/dev/null
# cleanup
rm -fr $tmpdir /tmp/quay.io-devspaces-{devfile,plugin}registry-rhel8-${DS_VERSION}*/
$PODMAN rmi -f quay.io/devspaces/pluginregistry-rhel8:${DS_VERSION} quay.io/devspaces/devfileregistry-rhel8:${DS_VERSION} || true
rm -fr $tmpdir /tmp/quay.io-devspaces-devfileregistry-rhel8-${DS_VERSION}*/
$PODMAN rmi -f quay.io/devspaces/devfileregistry-rhel8:${DS_VERSION} || true
# convert strings to arrays
DEVFILE_REGISTRY_CONTAINERS=(${EXTERNAL_IMAGES})
PLUGIN_REGISTRY_CONTAINERS=(${EXTERNAL_IMAGES})

# same method used in both insert-related-images-to-csv.sh and sync-che-olm.sh
insertEnvVar()
Expand All @@ -100,7 +93,6 @@ insertEnvVar()
CSVFILE=${TARGETDIR}/manifests/devspaces.csv.yaml

# The updated name should be like:
# RELATED_IMAGE_devspaces_udi_plugin_registry_image_GIXDCMQK
# RELATED_IMAGE_devspaces_udi_devfile_registry_image_GIXDCMQK
# RELATED_IMAGE_jboss_eap_7_eap73_openjdk8_openshift_rhel7_devfile_registry_image_G4XDGLRWBI______
updateRelatedImageName() {
Expand All @@ -121,7 +113,6 @@ updateRelatedImageName() {
done
}

updateRelatedImageName "plugin_registry_image" "${PLUGIN_REGISTRY_CONTAINERS[@]}"
updateRelatedImageName "devfile_registry_image" "${DEVFILE_REGISTRY_CONTAINERS[@]}"

# replace external devspaces refs with internal ones, and quay refs (from v2 devfiles) with RHEC ones
Expand Down
23 changes: 23 additions & 0 deletions devspaces-operator-bundle/build/scripts/sync-che-olm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ 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}\"}
]"

# header to reattach to yaml files after yq transform removes it
COPYRIGHT="#
# Copyright (c) 2018-$(date +%Y) Red Hat, Inc.
Expand Down Expand Up @@ -272,10 +286,13 @@ for CSVFILE in ${TARGETDIR}/manifests/devspaces.csv.yaml; do
V1_EXAMPLE=$(echo "$ALM_EXAMPLES" | yq '(.[] | select(.apiVersion=="org.eclipse.che/v1"))')
V2_EXAMPLE=$(echo "$ALM_EXAMPLES" | yq '(.[] | select(.apiVersion=="org.eclipse.che/v2"))')
FIXED_V2_EXAMPLE=$(echo "$V2_EXAMPLE" | \
yq 'del(.spec.components.pluginRegistry.disableInternalRegistry)' | \
yq 'del(.spec.components.pluginRegistry | select(length == 0))' | \
yq 'del(.spec.components.devfileRegistry.disableInternalRegistry)' | \
yq 'del(.spec.components.devfileRegistry.externalDevfileRegistries)'| \
yq 'del(.spec.components.devfileRegistry | select(length == 0))')
FIXED_V1_EXAMPLE=$(echo "$V1_EXAMPLE" | \
yq 'del(.spec.server.externalPluginRegistry)' | \
yq 'del(.spec.server.externalDevfileRegistry)' | \
yq 'del(.spec.server.devfileRegistryUrl)'| \
yq 'del(.spec.server.externalDevfileRegistries)'| \
Expand Down Expand Up @@ -362,6 +379,12 @@ for CSVFILE in ${TARGETDIR}/manifests/devspaces.csv.yaml; do
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}"

# 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}"
RETURN_CODE=$?
Expand Down
1 change: 1 addition & 0 deletions devspaces-operator-bundle/build/scripts/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ api/
build/
config/
controllers/
editors-definitions/
Dependencies.md
devfile.yaml
devfiles.yaml
Expand Down
145 changes: 0 additions & 145 deletions devspaces-operator-bundle/editors-definitions/che-code-insiders.yaml

This file was deleted.

Loading