Use env from cm

This commit is contained in:
Nikolai Rodionov 2024-04-03 11:35:54 +02:00
parent 9e2ecb0037
commit 28a3d2a773
Signed by: allanger
GPG Key ID: 0AA46A90E25592AD
3 changed files with 36 additions and 11 deletions

View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
if [[ $1 == "--config" ]] ; then
cat <<EOF
configVersion: v1
kubernetes:
- name: Watch bootstrap configmaps getting removed
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
executeHookOnSynchronization: false
executeHookOnEvent: ["Modified"]
jqFilter: ".status."
labelSelector:
matchExpressions:
- key: "component"
operator: "In"
values: ["bootstrap"]
EOF
else
# -------------------------------------------------------------------
# If status is succeeded, remove pipelinerun
# If failed, print a warning (till we have a notification system)
# -------------------------------------------------------------------
echo todo
fi

View File

@ -17,12 +17,11 @@ kubernetes:
values: ["bootstrap"] values: ["bootstrap"]
EOF EOF
else else
PROVIDER=$(jq -r .[0].object.data.provider $BINDING_CONTEXT_PATH) export $(jq -r .[0].object.data.vars $BINDING_CONTEXT_PATH)
KUBERNETES=$(jq -r .[0].object.data.kubernetes $BINDING_CONTEXT_PATH) echo "running the ${SP_PROVIDER}-cleanup hook"
echo "running the ${PROVIDER}-cleanup hook"
if ! [ -f /tpls/${PROVIDER}-cleanup.yaml ]; then if ! [ -f /tpls/${SP_PROVIDER}-cleanup.yaml ]; then
echo "template not found for ${PROVIDER}-cleanup" echo "template not found for ${SP_PROVIDER}-cleanup"
exit 1 exit 1
fi fi
@ -30,7 +29,7 @@ else
export SP_ENVIRONMENT=$(jq -r .[0].object.metadata.name $BINDING_CONTEXT_PATH) export SP_ENVIRONMENT=$(jq -r .[0].object.metadata.name $BINDING_CONTEXT_PATH)
echo "removing the ${SP_ENVIRONMENT} owned by ${SP_CUSTOMER_ID}" echo "removing the ${SP_ENVIRONMENT} owned by ${SP_CUSTOMER_ID}"
envsubst < /tpls/${PROVIDER}-cleanup.yaml | kubectl create -f - envsubst < /tpls/${SP_PROVIDER}-cleanup.yaml | kubectl create -f -
# -- Removing the finalizer # -- Removing the finalizer
kubectl patch configmap -n ${SP_CUSTOMER_ID} ${SP_ENVIRONMENT} \ kubectl patch configmap -n ${SP_CUSTOMER_ID} ${SP_ENVIRONMENT} \

View File

@ -22,15 +22,14 @@ kubernetes:
values: ["bootstrap"] values: ["bootstrap"]
EOF EOF
else else
PROVIDER=$(jq -r .[0].object.data.provider $BINDING_CONTEXT_PATH) export $(jq -r .[0].object.data.vars $BINDING_CONTEXT_PATH)
KUBERNETES=$(jq -r .[0].object.data.kubernetes $BINDING_CONTEXT_PATH) if ! [ -f /tpls/${SP_PROVIDER}-${SP_KUBERNETES}.yaml ]; then
if ! [ -f /tpls/${PROVIDER}-${KUBERNETES}.yaml ]; then echo "ERROR: template not found for ${SP_PROVIDER}-${SP_KUBERNETES}"
echo "ERROR: template not found for ${PROVIDER}-${KUBERNETES}"
exit 1 exit 1
fi fi
export SP_CUSTOMER_ID=$(jq -r .[0].object.metadata.namespace $BINDING_CONTEXT_PATH) export SP_CUSTOMER_ID=$(jq -r .[0].object.metadata.namespace $BINDING_CONTEXT_PATH)
export SP_ENVIRONMENT=$(jq -r .[0].object.metadata.name $BINDING_CONTEXT_PATH) export SP_ENVIRONMENT=$(jq -r .[0].object.metadata.name $BINDING_CONTEXT_PATH)
envsubst < /tpls/${PROVIDER}-${KUBERNETES}.yaml | kubectl create -f - envsubst < /tpls/${SP_PROVIDER}-${SP_KUBERNETES}.yaml | kubectl create -f -
kubectl patch configmap -n ${SP_CUSTOMER_ID} ${SP_ENVIRONMENT} \ kubectl patch configmap -n ${SP_CUSTOMER_ID} ${SP_ENVIRONMENT} \
-p '{"metadata":{"finalizers":["softplayer.net/bootstrapped"]}}' --type=merge -p '{"metadata":{"finalizers":["softplayer.net/bootstrapped"]}}' --type=merge
fi fi