79
79
fi
80
80
81
81
echo "Gitpod: Generate the base Installer config"
82
+ echo "Gitpod: Create a Helm template directory"
83
+ rm -Rf "${GITPOD_OBJECTS}"
84
+ mkdir -p "${GITPOD_OBJECTS}/templates"
85
+ cat <<EOF >> "${GITPOD_OBJECTS}/Chart.yaml"
86
+ apiVersion: v2
87
+ name: gitpod-kots
88
+ description: Always ready-to-code
89
+ version: "1.0.0"
90
+ appVersion: "$(/app/installer version | yq e '.version' -)"
91
+ EOF
82
92
/app/installer init > "${CONFIG_FILE}"
83
93
84
94
echo "Gitpod: auto-detecting ShiftFS support on host machine"
@@ -174,8 +184,7 @@ spec:
174
184
kubectl create secret docker-registry container-registry \
175
185
--namespace "{{repl Namespace }}" \
176
186
--from-file=.dockerconfigjson=/tmp/container-registry-secret \
177
- -o yaml --dry-run=client | \
178
- kubectl replace --namespace "{{repl Namespace }}" --force -f -
187
+ -o yaml --dry-run=client > "${GITPOD_OBJECTS}/templates/gitpod.yaml"
179
188
180
189
yq e -i ".containerRegistry.inCluster = false" "${CONFIG_FILE}"
181
190
yq e -i ".containerRegistry.external.url = \"{{repl ConfigOption "reg_url" }}\"" "${CONFIG_FILE}"
@@ -298,19 +307,8 @@ spec:
298
307
config=$(cat "${CONFIG_FILE}")
299
308
echo "Gitpod: ${CONFIG_FILE}=${config}"
300
309
301
- echo "Gitpod: Create a Helm template directory"
302
- rm -Rf "${GITPOD_OBJECTS}"
303
- mkdir -p "${GITPOD_OBJECTS}/templates"
304
- cat <<EOF >> "${GITPOD_OBJECTS}/Chart.yaml"
305
- apiVersion: v2
306
- name: gitpod-kots
307
- description: Always ready-to-code
308
- version: "1.0.0"
309
- appVersion: "$(/app/installer version | yq e '.version' -)"
310
- EOF
311
-
312
310
echo "Gitpod: render Kubernetes manifests"
313
- /app/installer render -c "${CONFIG_FILE}" --namespace {{repl Namespace }} --use-experimental-config > "${GITPOD_OBJECTS}/templates/gitpod.yaml"
311
+ /app/installer render -c "${CONFIG_FILE}" --namespace {{repl Namespace }} --use-experimental-config >> "${GITPOD_OBJECTS}/templates/gitpod.yaml"
314
312
315
313
if [ '{{repl ConfigOptionEquals "reg_incluster" "1" }}' = "true" ];
316
314
then
@@ -329,6 +327,33 @@ spec:
329
327
"${GITPOD_OBJECTS}/templates/gitpod.yaml"
330
328
fi
331
329
330
+ # figure out the secret to use
331
+ if [ '{{repl ConfigOptionEquals "reg_incluster" "0" }}' = "true" ];
332
+ then
333
+ export REGISTRY_SECRET_NAME="container-registry"
334
+ else
335
+ export REGISTRY_SECRET_NAME="builtin-registry-auth"
336
+ fi
337
+
338
+ if [ '{{repl ConfigOptionNotEquals "reg_docker_config" "" }}' = "true" ];
339
+ then
340
+ echo "Gitpod: Add given extra docker config json file to ${REGISTRY_SECRET_NAME}"
341
+
342
+ yq eval-all '(select(.kind == "Secret" and .metadata.name == env(REGISTRY_SECRET_NAME)) | .data.".dockerconfigjson")' \
343
+ "${GITPOD_OBJECTS}/templates/gitpod.yaml" \
344
+ | base64 -d \
345
+ > /tmp/currentconfig.json
346
+
347
+ DOCKER_CONFIG='{{repl ConfigOptionData "reg_docker_config" | Base64Encode }}'
348
+ echo "${DOCKER_CONFIG}" | base64 -d > /tmp/userconfig.json
349
+
350
+ export REGISTRY_SECRET=$(jq -s '.[0] * .[1]' /tmp/userconfig.json /tmp/currentconfig.json | base64 -w 0)
351
+
352
+ echo "Gitpod: update the in-cluster registry secret"
353
+ yq eval-all --inplace '(select(.kind == "Secret" and .metadata.name == env(REGISTRY_SECRET_NAME)) | .data.".dockerconfigjson") |= env(REGISTRY_SECRET)' \
354
+ "${GITPOD_OBJECTS}/templates/gitpod.yaml"
355
+ fi
356
+
332
357
echo "Gitpod: Escape any Golang template values"
333
358
sed -i -r 's/(.*\{\{.*)/{{`\1`}}/' "${GITPOD_OBJECTS}/templates/gitpod.yaml"
334
359
0 commit comments