Skip to content

Commit

Permalink
Merge pull request #2896 from uselagoon/lagoon-yaml-configmap
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybellwood authored Nov 2, 2021
2 parents 64c4b0c + 72ec072 commit 5478cf8
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions images/kubectl-build-deploy-dind/build-deploy-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,30 @@ function featureFlag() {
echo "${!defaultFlagVar}"
}

##############################################
### PUSH the latest .lagoon.yml into lagoon-yaml configmap as a pre-deploy field
##############################################

set +x
echo "Updating lagoon-yaml configmap with a pre-deploy version of the .lagoon.yml file"
if kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get configmap lagoon-yaml &> /dev/null; then
# replace it
# if the environment has already been deployed with an existing configmap that had the file in the key `.lagoon.yml`
# just nuke the entire configmap and replace it with our new key and file
LAGOON_YML_CM=$(kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get configmap lagoon-yaml -o json)
if [ $(echo ${LAGOON_YML_CM} | jq -r '.data.".lagoon.yml" // false') == false ]; then
# if the key doesn't exist, then just update the pre-deploy yaml only
kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get configmap lagoon-yaml -o json | jq --arg add "`cat .lagoon.yml`" '.data."pre-deploy" = $add' | kubectl apply -f -
else
# if the key does exist, then nuke it and put the new key
kubectl --insecure-skip-tls-verify -n ${NAMESPACE} create configmap lagoon-yaml --from-file=pre-deploy=.lagoon.yml -o yaml --dry-run | kubectl replace -f -
fi
else
# create it
kubectl --insecure-skip-tls-verify -n ${NAMESPACE} create configmap lagoon-yaml --from-file=pre-deploy=.lagoon.yml
fi
set -x

##############################################
### PREPARATION
##############################################
Expand Down Expand Up @@ -1960,10 +1984,13 @@ fi
### PUSH the latest .lagoon.yml into lagoon-yaml configmap
##############################################

set +x
echo "Updating lagoon-yaml configmap with a post-deploy version of the .lagoon.yml file"
if kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get configmap lagoon-yaml &> /dev/null; then
# replace it
kubectl --insecure-skip-tls-verify -n ${NAMESPACE} create configmap lagoon-yaml --from-file=.lagoon.yml -o yaml --dry-run | kubectl replace -f -
else
# replace it, no need to check if the key is different, as that will happen in the pre-deploy phase
kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get configmap lagoon-yaml -o json | jq --arg add "`cat .lagoon.yml`" '.data."post-deploy" = $add' | kubectl apply -f -
else
# create it
kubectl --insecure-skip-tls-verify -n ${NAMESPACE} create configmap lagoon-yaml --from-file=.lagoon.yml
kubectl --insecure-skip-tls-verify -n ${NAMESPACE} create configmap lagoon-yaml --from-file=post-deploy=.lagoon.yml
fi
set -x

0 comments on commit 5478cf8

Please sign in to comment.