Use env from cm
This commit is contained in:
parent
9e2ecb0037
commit
28a3d2a773
27
hooks/cleanup-pipelineruns.sh
Normal file
27
hooks/cleanup-pipelineruns.sh
Normal 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
|
||||
|
@ -17,12 +17,11 @@ kubernetes:
|
||||
values: ["bootstrap"]
|
||||
EOF
|
||||
else
|
||||
PROVIDER=$(jq -r .[0].object.data.provider $BINDING_CONTEXT_PATH)
|
||||
KUBERNETES=$(jq -r .[0].object.data.kubernetes $BINDING_CONTEXT_PATH)
|
||||
echo "running the ${PROVIDER}-cleanup hook"
|
||||
export $(jq -r .[0].object.data.vars $BINDING_CONTEXT_PATH)
|
||||
echo "running the ${SP_PROVIDER}-cleanup hook"
|
||||
|
||||
if ! [ -f /tpls/${PROVIDER}-cleanup.yaml ]; then
|
||||
echo "template not found for ${PROVIDER}-cleanup"
|
||||
if ! [ -f /tpls/${SP_PROVIDER}-cleanup.yaml ]; then
|
||||
echo "template not found for ${SP_PROVIDER}-cleanup"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -30,7 +29,7 @@ else
|
||||
export SP_ENVIRONMENT=$(jq -r .[0].object.metadata.name $BINDING_CONTEXT_PATH)
|
||||
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
|
||||
kubectl patch configmap -n ${SP_CUSTOMER_ID} ${SP_ENVIRONMENT} \
|
||||
|
@ -22,15 +22,14 @@ kubernetes:
|
||||
values: ["bootstrap"]
|
||||
EOF
|
||||
else
|
||||
PROVIDER=$(jq -r .[0].object.data.provider $BINDING_CONTEXT_PATH)
|
||||
KUBERNETES=$(jq -r .[0].object.data.kubernetes $BINDING_CONTEXT_PATH)
|
||||
if ! [ -f /tpls/${PROVIDER}-${KUBERNETES}.yaml ]; then
|
||||
echo "ERROR: template not found for ${PROVIDER}-${KUBERNETES}"
|
||||
export $(jq -r .[0].object.data.vars $BINDING_CONTEXT_PATH)
|
||||
if ! [ -f /tpls/${SP_PROVIDER}-${SP_KUBERNETES}.yaml ]; then
|
||||
echo "ERROR: template not found for ${SP_PROVIDER}-${SP_KUBERNETES}"
|
||||
exit 1
|
||||
fi
|
||||
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)
|
||||
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} \
|
||||
-p '{"metadata":{"finalizers":["softplayer.net/bootstrapped"]}}' --type=merge
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user