File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change 11#! /bin/bash
22
3+ set -o pipefail
4+ set -o errexit
5+ set -o nounset
6+ set -o errtrace
37set -x
48
59source /usr/local/bin/crc-systemd-common.sh
610export KUBECONFIG=" /opt/kubeconfig"
711
812wait_for_resource secret
913
14+ set +x # disable the logging to avoid leaking the pull secrets
15+
1016# check if existing pull-secret is valid if not add the one from /opt/crc/pull-secret
1117existingPsB64=$( oc get secret pull-secret -n openshift-config -o jsonpath=" {['data']['\.dockerconfigjson']}" )
1218existingPs=$( echo " ${existingPsB64} " | base64 -d)
1319
14- echo " ${existingPs} " | jq -e ' .auths'
15-
16- if [[ $? != 0 ]]; then
17- pullSecretB64=$( base64 -w0 < /opt/crc/pull-secret)
18- oc patch secret pull-secret -n openshift-config --type merge -p " {\" data\" :{\" .dockerconfigjson\" :\" ${pullSecretB64} \" }}"
20+ # check if the .auths field is there
21+ if echo " ${existingPs} " | jq -e ' has("auths")' > /dev/null 2>&1 ; then
22+ echo " Cluster already has the pull secrets, nothing to do"
23+ exit 0
1924fi
2025
26+ echo " Cluster doesn't have the pull secrets. Setting them from /opt/crc/pull-secret ..."
27+ pullSecretB64=$( base64 -w0 < /opt/crc/pull-secret)
28+ # Create the JSON patch in memory and pipe it to the oc command
29+ printf ' {"data":{".dockerconfigjson": "%s"}}' " ${pullSecretB64} " | \
30+ oc patch secret pull-secret -n openshift-config --type merge --patch-file=/dev/stdin
31+
32+ exit 0
You can’t perform that action at this time.
0 commit comments