Skip to content

Commit

Permalink
add ide configmap patch
Browse files Browse the repository at this point in the history
  • Loading branch information
iQQBot committed Apr 24, 2024
1 parent fa2e00d commit 3420bf9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 12 deletions.
21 changes: 9 additions & 12 deletions dev/preview/workflow/preview/deploy-gitpod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ source "$(realpath "${SCRIPT_PATH}/../lib/common.sh")"
# shellcheck source=../lib/k8s-util.sh
source "$(realpath "${SCRIPT_PATH}/../lib/k8s-util.sh")"

DEV_KUBE_PATH="${DEV_KUBE_PATH:-/home/gitpod/.kube/config}"
DEV_KUBE_CONTEXT="${DEV_KUBE_CONTEXT:-dev}"

PREVIEW_NAME="${PREVIEW_NAME:-$(previewctl get name)}"
PREVIEW_K3S_KUBE_PATH="${PREVIEW_K3S_KUBECONFIG_PATH:-/home/gitpod/.kube/config}"
PREVIEW_K3S_KUBE_CONTEXT="${PREVIEW_K3S_KUBE_CONTEXT:-$PREVIEW_NAME}"
Expand All @@ -31,15 +28,15 @@ GITPOD_WITH_DEDICATED_EMU="${GITPOD_WITH_DEDICATED_EMU:-false}"
PREVIEW_GCP_PROJECT="gitpod-dev-preview"


# if [[ "${VERSION:-}" == "" ]]; then
# if [[ ! -f /tmp/local-dev-version ]]; then
# log_error "VERSION is not set and no fallback version exists in /tmp/local-dev-version."
# log_info "Please run leeway run dev/preview:build or set VERSION"
# exit 1
# fi
# VERSION="$(cat /tmp/local-dev-version)"
# log_info "VERSION is not set - using value from /tmp/local-dev-version which is $VERSION"
# fi
if [[ "${VERSION:-}" == "" ]]; then
if [[ ! -f /tmp/local-dev-version ]]; then
log_error "VERSION is not set and no fallback version exists in /tmp/local-dev-version."
log_info "Please run leeway run dev/preview:build or set VERSION"
exit 1
fi
VERSION="$(cat /tmp/local-dev-version)"
log_info "VERSION is not set - using value from /tmp/local-dev-version which is $VERSION"
fi

INSTALLER_CONFIG_PATH="${INSTALLER_CONFIG_PATH:-$(mktemp "/tmp/XXXXXX.gitpod.config.yaml")}"
INSTALLER_RENDER_PATH="k8s.yaml" # k8s.yaml is hardcoded in post-prcess.sh - we can fix that later.
Expand Down
29 changes: 29 additions & 0 deletions dev/preview/workflow/preview/patch-ide-configmap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const fs = require("fs");
let json = JSON.parse(fs.readFileSync(process.argv[2]).toString());

function replaceImage(image) {
return image.replace("gitpod-dev-artifact", "gitpod-core-dev");
}

for (let ide in json.ideOptions.options) {
if (["clion", "goland", "intellij", "phpstorm", "pycharm", "rider", "rubymine", "webstorm"].includes(ide)) {
json.ideOptions.options[ide].latestImage = replaceImage(json.ideOptions.options[ide].latestImage);
json.ideOptions.options[ide].versions = json.ideOptions.options[ide].versions?.map((version) => {
version.image = replaceImage(version.image);
return version;
});
}
if (["code", "code1_85"].includes(ide)) {
json.ideOptions.options[ide].image = replaceImage(json.ideOptions.options[ide].image);
json.ideOptions.options[ide].versions = json.ideOptions.options[ide].versions?.map((version) => {
version.image = replaceImage(version.image);
return version;
});
}
if (["intellij-previous"].includes(ide)) {
json.ideOptions.options[ide].image = replaceImage(json.ideOptions.options[ide].image);
json.ideOptions.options[ide].imageLayers = json.ideOptions.options[ide].imageLayers.map((i) => replaceImage(i));
}
}

fs.writeFileSync(process.argv[2], JSON.stringify(json));
15 changes: 15 additions & 0 deletions dev/preview/workflow/preview/post-process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ REG_DAEMON_PORT="31750"
DEV_BRANCH=$1
SMITH_TOKEN=$2

SCRIPT_PATH=$(realpath "$(dirname "$0")")

if [[ -z ${REG_DAEMON_PORT} ]] || [[ -z ${DEV_BRANCH} ]] || [[ -z ${SMITH_TOKEN} ]]; then
echo "One or more input params were invalid: ${REG_DAEMON_PORT} ${DEV_BRANCH} ${SMITH_TOKEN}"
exit 1
Expand Down Expand Up @@ -143,6 +145,19 @@ while [ "$documentIndex" -le "$DOCS" ]; do
yq m -x -i k8s.yaml -d "$documentIndex" /tmp/"$NAME"overrides.yaml
fi

# overrides for ide-config configmap
if [[ "ide-config" == "$NAME" ]] && [[ "$KIND" == "ConfigMap" ]]; then
WORK="overrides for $NAME $KIND"
echo "$WORK"
touch /tmp/"$NAME"-overrides.yaml

yq r k8s.yaml -d "$documentIndex" data | yq prefix - data > /tmp/"$NAME"-overrides.yaml
yq r /tmp/"$NAME"-overrides.yaml 'data.[config.json]' > /tmp/"$NAME"-overrides.json
node "$SCRIPT_PATH/patch-ide-configmap.js" /tmp/"$NAME"-overrides.json
yq w -i /tmp/"$NAME"-overrides.yaml "data.[config.json]" -- "$(< /tmp/"$NAME"-overrides.json)"
yq m -x -i k8s.yaml -d "$documentIndex" /tmp/"$NAME"-overrides.yaml
fi

# override details for Minio
if [[ "minio" == "$NAME" ]] && [[ "$KIND" == "Deployment" ]]; then
WORK="overrides for $NAME $KIND"
Expand Down

0 comments on commit 3420bf9

Please sign in to comment.