2024-04-02 15:21:21 +00:00
|
|
|
#!/usr/bin/env bash
|
2024-04-02 16:23:10 +00:00
|
|
|
|
2024-04-02 15:21:21 +00:00
|
|
|
if [[ $1 == "--config" ]] ; then
|
|
|
|
cat <<EOF
|
|
|
|
configVersion: v1
|
|
|
|
kubernetes:
|
2024-04-02 16:23:10 +00:00
|
|
|
- name: Watch bootstrap configmaps getting removed
|
2024-04-02 16:18:41 +00:00
|
|
|
apiVersion: v1
|
|
|
|
kind: ConfigMap
|
|
|
|
executeHookOnEvent: ["Deleted"]
|
|
|
|
labelSelector:
|
|
|
|
matchExpressions:
|
|
|
|
- key: "component"
|
|
|
|
operator: "In"
|
|
|
|
values: ["bootstrap"]
|
2024-04-02 15:21:21 +00:00
|
|
|
EOF
|
|
|
|
else
|
2024-04-02 16:18:41 +00:00
|
|
|
PROVIDER=$(jq -r .[0].objects.[0].object.data.provider $BINDING_CONTEXT_PATH)
|
|
|
|
KUBERNETES=$(jq -r .[0].objects.[0].object.data.kubernetes $BINDING_CONTEXT_PATH)
|
|
|
|
if ! [ -f /tpls/${PROVIDER}-cleanup.yaml ]; then
|
|
|
|
echo "ERROR: template not found for ${PROVIDER}-cleanup"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
export SP_CUSTOMER_ID=$(jq -r .[0].objects.[0].object.metadata.namespace $BINDING_CONTEXT_PATH)
|
|
|
|
export SP_ENVIRONMENT=$(jq -r .[0].objects.[0].object.metadata.name $BINDING_CONTEXT_PATH)
|
|
|
|
envsubst < /tpls/${PROVIDER}-cleanup.yaml | kubectl create -f -
|
2024-04-02 16:39:10 +00:00
|
|
|
kubectl patch configmap -n ${SP_CUSTOMER_ID} ${SP_ENVIRONMENT} \
|
|
|
|
-p '{"metadata":{"finalizers":null}}' --type=merge
|
2024-04-02 15:21:21 +00:00
|
|
|
fi
|
|
|
|
|