From 47433c12d954281a1ea3d336b35daea519c7ebf6 Mon Sep 17 00:00:00 2001 From: Toby Bellwood Date: Mon, 2 May 2022 10:36:33 +1000 Subject: [PATCH] more explicit controller robot actions --- .../kubectl-build-deploy-dind/build-deploy.sh | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/images/kubectl-build-deploy-dind/build-deploy.sh b/images/kubectl-build-deploy-dind/build-deploy.sh index 292924c705..e3225c3b24 100755 --- a/images/kubectl-build-deploy-dind/build-deploy.sh +++ b/images/kubectl-build-deploy-dind/build-deploy.sh @@ -58,14 +58,25 @@ kubectl config set-cluster kubernetes.default.svc --server=https://kubernetes.de kubectl config set-context default/lagoon/kubernetes.default.svc --user=lagoon/kubernetes.default.svc --namespace="${NAMESPACE}" --cluster=kubernetes.default.svc kubectl config use-context default/lagoon/kubernetes.default.svc -if [ ! -z ${INTERNAL_REGISTRY_URL} ] && [ ! -z ${INTERNAL_REGISTRY_USERNAME} ] && [ ! -z ${INTERNAL_REGISTRY_PASSWORD} ] ; then - echo "docker login -u '${INTERNAL_REGISTRY_USERNAME}' -p '${INTERNAL_REGISTRY_PASSWORD}' ${INTERNAL_REGISTRY_URL}" | /bin/bash - # create lagoon-internal-registry-secret if it does not exist yet - if ! kubectl -n ${NAMESPACE} get secret lagoon-internal-registry-secret &> /dev/null; then - kubectl create secret docker-registry lagoon-internal-registry-secret --docker-server=${INTERNAL_REGISTRY_URL} --docker-username=${INTERNAL_REGISTRY_USERNAME} --docker-password=${INTERNAL_REGISTRY_PASSWORD} --dry-run -o yaml | kubectl apply -f - +if [ ! -z ${INTERNAL_REGISTRY_URL} ] ; then + echo "Creating secret for internal registry access" + if [ ! -z ${INTERNAL_REGISTRY_USERNAME} ] && [ ! -z ${INTERNAL_REGISTRY_PASSWORD} ] ; then + echo "docker login -u '${INTERNAL_REGISTRY_USERNAME}' -p '${INTERNAL_REGISTRY_PASSWORD}' ${INTERNAL_REGISTRY_URL}" | /bin/bash + # create lagoon-internal-registry-secret if it does not exist yet + if ! kubectl -n ${NAMESPACE} get secret lagoon-internal-registry-secret &> /dev/null; then + kubectl create secret docker-registry lagoon-internal-registry-secret --docker-server=${INTERNAL_REGISTRY_URL} --docker-username=${INTERNAL_REGISTRY_USERNAME} --docker-password=${INTERNAL_REGISTRY_PASSWORD} --dry-run -o yaml | kubectl apply -f - + fi + REGISTRY_SECRETS+=("lagoon-internal-registry-secret") + REGISTRY=$INTERNAL_REGISTRY_URL # This will handle pointing Lagoon at the correct registry for non local builds + echo "Set internal registry secrets for token ${INTERNAL_REGISTRY_USERNAME} in ${REGISTRY}" + else + if [ ! $INTERNAL_REGISTRY_USERNAME ]; then + echo "No token created for registry ${INTERNAL_REGISTRY_URL}"; exit 1; + fi + if [ ! $INTERNAL_REGISTRY_PASSWORD ]; then + echo "No password retrieved for token ${INTERNAL_REGISTRY_USERNAME} in registry ${INTERNAL_REGISTRY_URL}"; exit 1; + fi fi - REGISTRY_SECRETS+=("lagoon-internal-registry-secret") - REGISTRY=$INTERNAL_REGISTRY_URL # This will handle pointing Lagoon at the correct registry for non local builds fi ##############################################