forked from crc-org/snc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrc-pullsecret.sh
More file actions
32 lines (24 loc) · 1.03 KB
/
Copy pathcrc-pullsecret.sh
File metadata and controls
32 lines (24 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
set -o pipefail
set -o errexit
set -o nounset
set -o errtrace
set -x
source /usr/local/bin/crc-systemd-common.sh
export KUBECONFIG="/opt/kubeconfig"
wait_for_resource secret
set +x # disable the logging to avoid leaking the pull secrets
# check if existing pull-secret is valid if not add the one from /opt/crc/pull-secret
existingPsB64=$(oc get secret pull-secret -n openshift-config -o jsonpath="{['data']['\.dockerconfigjson']}")
existingPs=$(echo "${existingPsB64}" | base64 -d)
# check if the .auths field is there
if echo "${existingPs}" | jq -e 'has("auths")' >/dev/null 2>&1; then
echo "Cluster already has the pull secrets, nothing to do"
exit 0
fi
echo "Cluster doesn't have the pull secrets. Setting them from /opt/crc/pull-secret ..."
pullSecretB64=$(base64 -w0 < /opt/crc/pull-secret)
# Create the JSON patch in memory and pipe it to the oc command
printf '{"data":{".dockerconfigjson": "%s"}}' "${pullSecretB64}" | \
oc patch secret pull-secret -n openshift-config --type merge --patch-file=/dev/stdin
exit 0