From 257a63e083b63d6840d017e984e8ac824121d873 Mon Sep 17 00:00:00 2001 From: Valeriy Svydenko Date: Fri, 5 Jul 2024 13:56:24 +0300 Subject: [PATCH 1/2] Cleanup entrypoint.sh Signed-off-by: Valeriy Svydenko --- build.sh | 3 - build/dockerfiles/entrypoint.sh | 125 --------------- build/dockerfiles/test_entrypoint.sh | 225 --------------------------- openvsx-sync.json | 198 ----------------------- 4 files changed, 551 deletions(-) delete mode 100755 build/dockerfiles/test_entrypoint.sh diff --git a/build.sh b/build.sh index 63032cbefe..99b66afef1 100755 --- a/build.sh +++ b/build.sh @@ -90,9 +90,6 @@ echo "Generate artifacts..." eval yarn node "${NODE_BUILD_OPTIONS}" lib/entrypoint.js --output-folder:"${base_dir}/output" "${BUILD_FLAGS_ARRAY[@]}" popd > /dev/null -echo -e "\nTest entrypoint.sh" -"${base_dir}"/build/dockerfiles/test_entrypoint.sh - if [ "${SKIP_OCI_IMAGE}" != "true" ]; then BUILD_COMMAND="build" if [[ -z $BUILDER ]]; then diff --git a/build/dockerfiles/entrypoint.sh b/build/dockerfiles/entrypoint.sh index 660f2d810a..1823b08fab 100755 --- a/build/dockerfiles/entrypoint.sh +++ b/build/dockerfiles/entrypoint.sh @@ -6,44 +6,12 @@ # which is available at https://www.eclipse.org/legal/epl-2.0/ # # SPDX-License-Identifier: EPL-2.0 -# -# Updates plugin runner images to point a registry defined by environment -# variables -# CHE_SIDECAR_CONTAINERS_REGISTRY_URL -# CHE_SIDECAR_CONTAINERS_REGISTRY_ORGANIZATION -# CHE_SIDECAR_CONTAINERS_REGISTRY_TAG -# -# By default, this script will operate on the `/var/www/html/v3` directory. -# This can be overridden by the environment variable $METAS_DIR -# -# Will execute any arguments on completion (`exec $@`) set -e -REGISTRY=${CHE_SIDECAR_CONTAINERS_REGISTRY_URL} -ORGANIZATION=${CHE_SIDECAR_CONTAINERS_REGISTRY_ORGANIZATION} -TAG=${CHE_SIDECAR_CONTAINERS_REGISTRY_TAG} - -DEFAULT_METAS_DIR="/var/www/html/v3" -METAS_DIR="${METAS_DIR:-${DEFAULT_METAS_DIR}}" - -# Regex used to break an image reference into groups: -# \1 - Whitespace and (optional) quotation preceding image reference -# \2 - Registry portion of image, e.g. (quay.io)/che-incubator/che-code:tag -# \3 - Organization portion of image, e.g. quay.io/(eclipse)/che-code:tag -# \4 - Image name portion of image, e.g. quay.io/che-incubator/(che-code):tag -# \5 - Optional image digest identifier (empty for tags), e.g. quay.io/che-incubator/che-code(@sha256):digest -# \6 - Tag of image or digest, e.g. quay.io/che-incubator/che-code:(tag) -# \7 - Optional quotation following image reference -IMAGE_REGEX="([[:space:]>-]*[\r]?[[:space:]]*[\"']?)([._:a-zA-Z0-9-]*)/([._a-zA-Z0-9-]*)/([._a-zA-Z0-9-]*)(@sha256)?:([._a-zA-Z0-9-]*)([\"']?)" - function run_main() { - extract_and_use_related_images_env_variables_with_image_digest_info - - update_container_image_references - # Add current (arbitrary) user to /etc/passwd and /etc/group if ! whoami &> /dev/null; then if [ -w /etc/passwd ]; then @@ -74,99 +42,6 @@ function run_main() { } -function extract_and_use_related_images_env_variables_with_image_digest_info() { - # Extract and use env variables with image digest information. - # Env variable name format: - # RELATED_IMAGES_(Image_name)_(Image_label)_(Encoded_base32_image_tag) - # Where are: - # "Image_name" - image name. Not valid chars for env variable name replaced to '_'. - # "Image_label" - image target, for example 'plugin_registry_image'. - # "Encoded_base32_image_tag_" - original image tag encoded to base32, to avoid invalid for env name chars. base32 alphabet has only - # one invalid character for env name: '='. That's why it was replaced to '_'. - # INFO: "=" for base32 it is pad character. If encoded string contains this char(s), then it is always located at the end of the string. - # Env value it is image with digest to use. - # Example env variable: - # RELATED_IMAGE_che_sidecar_clang_plugin_registry_image_HAWTQM3BMRRDGYIK="quay.io/eclipse/che-sidecar-clang@sha256:1c217f34ca69108fdd1ab844c0bcf960edff92519677bde4f8a5f4841b104745" - if env | grep -q ".*plugin_registry_image.*"; then - declare -A imageMap - readarray -t ENV_IMAGES < <(env | grep ".*plugin_registry_image.*") - for imageEnv in "${ENV_IMAGES[@]}"; do - tagOrDigest=$(echo "${imageEnv}" | sed -e 's;.*registry_image_\(.*\)=.*;\1;' | tr _ = | base32 -d) - if [[ ${tagOrDigest} == *"@"* ]]; then - # Well, image was "freezed", because it already has got digest, so do nothing. - continue - fi - imageWithDigest=${imageEnv#*=}; - if [[ -n "${tagOrDigest}" ]]; then - imageToReplace="${imageWithDigest%@*}:${tagOrDigest}" - else - imageToReplace="${imageWithDigest%@*}" - fi - digest="@${imageWithDigest#*@}" - imageMap["${imageToReplace}"]="${digest}" - done - - echo "--------------------------Digest map--------------------------" - for KEY in "${!imageMap[@]}"; do - echo "Key: $KEY Value: ${imageMap[${KEY}]}" - done - echo "--------------------------------------------------------------" - - readarray -t metas < <(find "${METAS_DIR}" -name 'meta.yaml' -o -name 'devfile.yaml') - for meta in "${metas[@]}"; do - readarray -t images < <(grep "image:" "${meta}" | sed -r "s;.*image:[[:space:]]*'?\"?([._:a-zA-Z0-9-]*/?[._a-zA-Z0-9-]*/[._a-zA-Z0-9-]*(@sha256)?:?[._a-zA-Z0-9-]*)'?\"?[[:space:]]*;\1;") - for image in "${images[@]}"; do - separators="${image//[^\/]}" - # Warning, keep in mind: image without registry name is it possible case. It's mean, that image comes from private registry, where is we have organization name, but no registry name... - digest="${imageMap[${image}]}" - - if [[ -z "${digest}" ]] && [ "${#separators}" == "1" ]; then - imageWithDefaultRegistry="docker.io/${image}" - digest="${imageMap[${imageWithDefaultRegistry}]}" - fi - - if [[ -n "${digest}" ]]; then - if [[ ${image} == *":"* ]]; then - imageWithoutTag="${image%:*}" - tag="${image#*:}" - else - imageWithoutTag=${image} - tag="" - fi - - REGEX="([[:space:]]*\"?'?)(${imageWithoutTag}):?(${tag})(\"?'?)" - sed -i -E "s|image:${REGEX}|image:\1\2${digest}\4|" "$meta" - fi - done - done - fi -} - -function update_container_image_references() { - - # We can't use the `-d` option for readarray because - # registry.centos.org/centos/httpd-24-centos7 ships with Bash 4.2 - # The below command will fail if any path contains whitespace - readarray -t metas < <(find "${METAS_DIR}" -name 'meta.yaml' -o -name 'devfile.yaml') - for meta in "${metas[@]}"; do - echo "Checking meta $meta" - # Need to update each field separately in case they are not defined. - # Defaults don't work because registry and tags may be different. - if [ -n "$REGISTRY" ]; then - echo " Updating image registry to $REGISTRY" - < "$meta" tr '\n' '\r' | sed -E "s|image:$IMAGE_REGEX|image:\1${REGISTRY}/\3/\4\5:\6\7|g" | tr '\r' '\n' > "$meta.tmp" && cat "$meta.tmp" > "$meta" && rm "$meta.tmp" - fi - if [ -n "$ORGANIZATION" ]; then - echo " Updating image organization to $ORGANIZATION" - < "$meta" tr '\n' '\r' | sed -E "s|image:$IMAGE_REGEX|image:\1\2/${ORGANIZATION}/\4\5:\6\7|g" | tr '\r' '\n' > "$meta.tmp" && cat "$meta.tmp" > "$meta" && rm "$meta.tmp" - fi - if [ -n "$TAG" ]; then - echo " Updating image tag to $TAG" - < "$meta" tr '\n' '\r' | sed -E "s|image:$IMAGE_REGEX|image:\1\2/\3/\4:${TAG}\7|g" | tr '\r' '\n' > "$meta.tmp" && cat "$meta.tmp" > "$meta" && rm "$meta.tmp" - fi - done -} - # do not execute the main function in unit tests if [[ "${BASH_SOURCE[0]}" == "${0}" ]] then diff --git a/build/dockerfiles/test_entrypoint.sh b/build/dockerfiles/test_entrypoint.sh deleted file mode 100755 index 7e7226c2e6..0000000000 --- a/build/dockerfiles/test_entrypoint.sh +++ /dev/null @@ -1,225 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2018-2021 Red Hat, Inc. -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# - -script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -METAS_DIR=$(mktemp -d) - -function cleanup() { - rm -rf "${METAS_DIR}"; -} -trap cleanup EXIT - -RED="\e[31m" -GREEN="\e[32m" -RESETSTYLE="\e[0m" -BOLD="\e[1m" -DEFAULT_EMOJI_HEADER="🏃" # could be overiden with EMOJI_HEADER="-" -EMOJI_HEADER=${EMOJI_HEADER:-$DEFAULT_EMOJI_HEADER} -DEFAULT_EMOJI_PASS="✔" # could be overriden with EMOJI_PASS="[PASS]" -EMOJI_PASS=${EMOJI_PASS:-$DEFAULT_EMOJI_PASS} -DEFAULT_EMOJI_FAIL="✘" # could be overriden with EMOJI_FAIL="[FAIL]" -EMOJI_FAIL=${EMOJI_FAIL:-$DEFAULT_EMOJI_FAIL} - -function initTest() { - echo -e "${BOLD}\n${EMOJI_HEADER} ${1}${RESETSTYLE}" - rm -rf "${METAS_DIR:?}"/* -} - -function assertFileContentEquals() { - file=$1 - expected_metayaml=$2 - - if [[ $(cat "${file}") == "${expected_metayaml}" ]]; then - echo -e "${GREEN}${EMOJI_PASS}${RESETSTYLE} Test passed!" - else - echo -e "${RED}${EMOJI_FAIL}${RESETSTYLE} Test failed!" - echo "Result:" - cat "${file}" - echo "Expected:" - echo "${expected_metayaml}" - exit 1 - fi -} -echo -e "${BOLD}\n${EMOJI_HEADER}${EMOJI_HEADER}${EMOJI_HEADER} Running tests for entrypoint.sh: ${BASH_SOURCE[0]}${RESETSTYLE}" - -################################################################# -initTest "Should replace image references in che-code devfile.yaml with RELATED_IMAGE env vars " - -devfileyaml=$(cat <<-END -schemaVersion: 2.1.0 -metadata: - name: che-code -commands: - - id: init-container-command - apply: - component: che-code-injector - - id: init-che-code-command - exec: - component: che-code-runtime-description - commandLine: nohup /checode/entrypoint-volume.sh > /checode/entrypoint-logs.txt 2>&1 & -events: - preStart: - - init-container-command - postStart: - - init-che-code-command -components: - - name: che-code-runtime-description - container: - image: quay.io/devfile/universal-developer-image:2.11 - volumeMounts: - - name: checode - path: /checode - memoryLimit: 1024Mi - memoryRequest: 256Mi - cpuLimit: 500m - cpuRequest: 30m - endpoints: - - name: che-code - attributes: - type: main - cookiesAuthEnabled: true - discoverable: false - urlRewriteSupported: true - targetPort: 3100 - exposure: public - secure: false - protocol: https - - name: code-redirect-1 - attributes: - discoverable: false - urlRewriteSupported: false - targetPort: 13131 - exposure: public - protocol: http - - name: code-redirect-2 - attributes: - discoverable: false - urlRewriteSupported: false - targetPort: 13132 - exposure: public - protocol: http - - name: code-redirect-3 - attributes: - discoverable: false - urlRewriteSupported: false - targetPort: 13133 - exposure: public - protocol: http - attributes: - app.kubernetes.io/component: che-code-runtime - app.kubernetes.io/part-of: che-code.eclipse.org - controller.devfile.io/container-contribution: true - - name: checode - volume: {} - - name: che-code-injector - container: - image: quay.io/che-incubator/che-code:2.11 - command: - - /entrypoint-init-container.sh - volumeMounts: - - name: checode - path: /checode - memoryLimit: 256Mi - memoryRequest: 32Mi - cpuLimit: 500m - cpuRequest: 30m -END -) -expected_devfileyaml=$(cat <<-END -schemaVersion: 2.1.0 -metadata: - name: che-code -commands: - - id: init-container-command - apply: - component: che-code-injector - - id: init-che-code-command - exec: - component: che-code-runtime-description - commandLine: nohup /checode/entrypoint-volume.sh > /checode/entrypoint-logs.txt 2>&1 & -events: - preStart: - - init-container-command - postStart: - - init-che-code-command -components: - - name: che-code-runtime-description - container: - image: quay.io/devfile/universal-developer-image@sha256:80fdd1ae37d3b9e0260d9c66b4ff12e35317c31243eabeea5212d98c537a3ba9 - volumeMounts: - - name: checode - path: /checode - memoryLimit: 1024Mi - memoryRequest: 256Mi - cpuLimit: 500m - cpuRequest: 30m - endpoints: - - name: che-code - attributes: - type: main - cookiesAuthEnabled: true - discoverable: false - urlRewriteSupported: true - targetPort: 3100 - exposure: public - secure: false - protocol: https - - name: code-redirect-1 - attributes: - discoverable: false - urlRewriteSupported: false - targetPort: 13131 - exposure: public - protocol: http - - name: code-redirect-2 - attributes: - discoverable: false - urlRewriteSupported: false - targetPort: 13132 - exposure: public - protocol: http - - name: code-redirect-3 - attributes: - discoverable: false - urlRewriteSupported: false - targetPort: 13133 - exposure: public - protocol: http - attributes: - app.kubernetes.io/component: che-code-runtime - app.kubernetes.io/part-of: che-code.eclipse.org - controller.devfile.io/container-contribution: true - - name: checode - volume: {} - - name: che-code-injector - container: - image: quay.io/che-incubator/che-code@sha256:8fd9eca7c28c59ce93c0b24c7ff0f38080e9a2ac66668274aeabc6b8f3144012 - command: - - /entrypoint-init-container.sh - volumeMounts: - - name: checode - path: /checode - memoryLimit: 256Mi - memoryRequest: 32Mi - cpuLimit: 500m - cpuRequest: 30m -END -) -echo "$devfileyaml" > "${METAS_DIR}/devfile.yaml" -export RELATED_IMAGE_che_code_plugin_registry_image_GIXDCMIK='quay.io/che-incubator/che-code@sha256:8fd9eca7c28c59ce93c0b24c7ff0f38080e9a2ac66668274aeabc6b8f3144012' -export RELATED_IMAGE_universal_developer_image_plugin_registry_image_GIXDCMIK='quay.io/devfile/universal-developer-image@sha256:80fdd1ae37d3b9e0260d9c66b4ff12e35317c31243eabeea5212d98c537a3ba9' - -# shellcheck disable=SC1090 -source "${script_dir}/entrypoint.sh" - -extract_and_use_related_images_env_variables_with_image_digest_info - -assertFileContentEquals "${METAS_DIR}/devfile.yaml" "${expected_devfileyaml}" diff --git a/openvsx-sync.json b/openvsx-sync.json index ffb924eaf7..1a7835909d 100644 --- a/openvsx-sync.json +++ b/openvsx-sync.json @@ -22,203 +22,5 @@ }, { "id": "errata-ai.vale-server" - }, - { - "id": "llvm-vs-code-extensions.vscode-clangd" - }, - { - "id": "eclipse-cdt.cdt-gdb-vscode" - }, - { - "id": "bmewburn.vscode-intelephense-client" - }, - { - "id": "ms-python.python" - }, - { - "id": "asciidoctor.asciidoctor-vscode" - }, - { - "id": "eamodio.gitlens" - }, - { - "id": "golang.Go" - }, - { - "id": "Dart-Code.dart-code" - }, - { - "id": "Dart-Code.flutter" - }, - { - "id": "redhat.vscode-yaml" - }, - { - "id": "ms-kubernetes-tools.vscode-kubernetes-tools" - }, - { - "id": "redhat.java" - }, - { - "id": "vscjava.vscode-java-debug" - }, - { - "id": "vscjava.vscode-java-test" - }, - { - "id": "redhat.vscode-microprofile" - }, - { - "id": "redhat.vscode-apache-camel" - }, - { - "id": "redhat.vscode-camelk" - }, - { - "id": "vscode.html-language-features" - }, - { - "id": "redhat.vscode-quarkus" - }, - { - "id": "redhat.fabric8-analytics" - }, - { - "id": "redhat.vscode-tekton-pipelines" - }, - { - "id": "redhat.vscode-redhat-account" - }, - { - "id": "redhat.vscode-openshift-connector" - }, - { - "id": "felixfbecker.php-debug" - }, - { - "id": "redhat.rhamt-vscode-extension" - }, - { - "id": "redhat.vscode-xml" - }, - { - "id": "redhat.vscode-didact" - }, - { - "id": "rogalmic.bash-debug" - }, - { - "id": "ms-dotnettools.vscode-dotnet-runtime" - }, - { - "id": "muhammad-sammy.csharp" - }, - { - "id": "rust-lang.rust" - }, - { - "id": "scala-lang.scala" - }, - { - "id": "scalameta.metals" - }, - { - "id": "SonarSource.sonarlint-vscode" - }, - { - "id": "vscode.git-base" - }, - { - "id": "vscode.git" - }, - { - "id": "atlassian.atlascode" - }, - { - "id": "BroadcomMFD.cobol-language-support" - }, - { - "id": "BroadcomMFD.debugger-for-mainframe" - }, - { - "id": "BroadcomMFD.hlasm-language-support" - }, - { - "id": "Zowe.vscode-extension-for-zowe" - }, - { - "id": "BroadcomMFD.explorer-for-endevor" - }, - { - "id": "zxh404.vscode-proto3" - }, - { - "id": "timonwong.shellcheck" - }, - { - "id": "grammarcraft.xtend-lang" - }, - { - "id": "castwide.solargraph" - }, - { - "id": "mads-hartmann.bash-ide-vscode" - }, - { - "id": "vscode.npm" - }, - { - "id": "esbenp.prettier-vscode" - }, - { - "id": "dbaeumer.vscode-eslint" - }, - { - "id": "bpruitt-goddard.mermaid-markdown-syntax-highlighting" - }, - { - "id": "jebbs.plantuml" - }, - { - "id": "redhat.vscode-commons" - }, - { - "id": "BroadcomMFD.ccf" - }, - { - "id": "4ops.terraform" - }, - { - "id": "RandomChance.logstash" - }, - { - "id": "fbaligand.vscode-logstash-editor" - }, - { - "id": "stylelint.vscode-stylelint" - }, - { - "id": "JFrog.jfrog-vscode-extension" - }, - { - "id": "SonatypeCommunity.vscode-iq-plugin" - }, - { - "id": "GitLab.gitlab-workflow" - }, - { - "id": "redhat.ansible" - }, - { - "id": "ms-toolsai.jupyter" - }, - { - "id": "ms-toolsai.jupyter-renderers" - }, - { - "id": "ms-toolsai.jupyter-keymap" - }, - { - "id": "cnshenj.vscode-task-manager" } ] From 3f9ca01e487017f4916b840071ec42861e3d4972 Mon Sep 17 00:00:00 2001 From: Valeriy Svydenko Date: Fri, 5 Jul 2024 14:00:24 +0300 Subject: [PATCH 2/2] revert openvsx-sync.json Signed-off-by: Valeriy Svydenko --- openvsx-sync.json | 198 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) diff --git a/openvsx-sync.json b/openvsx-sync.json index 1a7835909d..ffb924eaf7 100644 --- a/openvsx-sync.json +++ b/openvsx-sync.json @@ -22,5 +22,203 @@ }, { "id": "errata-ai.vale-server" + }, + { + "id": "llvm-vs-code-extensions.vscode-clangd" + }, + { + "id": "eclipse-cdt.cdt-gdb-vscode" + }, + { + "id": "bmewburn.vscode-intelephense-client" + }, + { + "id": "ms-python.python" + }, + { + "id": "asciidoctor.asciidoctor-vscode" + }, + { + "id": "eamodio.gitlens" + }, + { + "id": "golang.Go" + }, + { + "id": "Dart-Code.dart-code" + }, + { + "id": "Dart-Code.flutter" + }, + { + "id": "redhat.vscode-yaml" + }, + { + "id": "ms-kubernetes-tools.vscode-kubernetes-tools" + }, + { + "id": "redhat.java" + }, + { + "id": "vscjava.vscode-java-debug" + }, + { + "id": "vscjava.vscode-java-test" + }, + { + "id": "redhat.vscode-microprofile" + }, + { + "id": "redhat.vscode-apache-camel" + }, + { + "id": "redhat.vscode-camelk" + }, + { + "id": "vscode.html-language-features" + }, + { + "id": "redhat.vscode-quarkus" + }, + { + "id": "redhat.fabric8-analytics" + }, + { + "id": "redhat.vscode-tekton-pipelines" + }, + { + "id": "redhat.vscode-redhat-account" + }, + { + "id": "redhat.vscode-openshift-connector" + }, + { + "id": "felixfbecker.php-debug" + }, + { + "id": "redhat.rhamt-vscode-extension" + }, + { + "id": "redhat.vscode-xml" + }, + { + "id": "redhat.vscode-didact" + }, + { + "id": "rogalmic.bash-debug" + }, + { + "id": "ms-dotnettools.vscode-dotnet-runtime" + }, + { + "id": "muhammad-sammy.csharp" + }, + { + "id": "rust-lang.rust" + }, + { + "id": "scala-lang.scala" + }, + { + "id": "scalameta.metals" + }, + { + "id": "SonarSource.sonarlint-vscode" + }, + { + "id": "vscode.git-base" + }, + { + "id": "vscode.git" + }, + { + "id": "atlassian.atlascode" + }, + { + "id": "BroadcomMFD.cobol-language-support" + }, + { + "id": "BroadcomMFD.debugger-for-mainframe" + }, + { + "id": "BroadcomMFD.hlasm-language-support" + }, + { + "id": "Zowe.vscode-extension-for-zowe" + }, + { + "id": "BroadcomMFD.explorer-for-endevor" + }, + { + "id": "zxh404.vscode-proto3" + }, + { + "id": "timonwong.shellcheck" + }, + { + "id": "grammarcraft.xtend-lang" + }, + { + "id": "castwide.solargraph" + }, + { + "id": "mads-hartmann.bash-ide-vscode" + }, + { + "id": "vscode.npm" + }, + { + "id": "esbenp.prettier-vscode" + }, + { + "id": "dbaeumer.vscode-eslint" + }, + { + "id": "bpruitt-goddard.mermaid-markdown-syntax-highlighting" + }, + { + "id": "jebbs.plantuml" + }, + { + "id": "redhat.vscode-commons" + }, + { + "id": "BroadcomMFD.ccf" + }, + { + "id": "4ops.terraform" + }, + { + "id": "RandomChance.logstash" + }, + { + "id": "fbaligand.vscode-logstash-editor" + }, + { + "id": "stylelint.vscode-stylelint" + }, + { + "id": "JFrog.jfrog-vscode-extension" + }, + { + "id": "SonatypeCommunity.vscode-iq-plugin" + }, + { + "id": "GitLab.gitlab-workflow" + }, + { + "id": "redhat.ansible" + }, + { + "id": "ms-toolsai.jupyter" + }, + { + "id": "ms-toolsai.jupyter-renderers" + }, + { + "id": "ms-toolsai.jupyter-keymap" + }, + { + "id": "cnshenj.vscode-task-manager" } ]