function K_EXTEND_TIMER() {
if [ $# -eq 2 ]
then
kubectl get deployments \
-A \
--selector='kubeomatic-io-timebomb=enabled' \
--no-headers \
--output=json | \
jq -r '.items[]|[(.metadata|.namespace,.name),.kind,(.spec.template.metadata.annotations|."kubeomatic-io-timebomb-sku","kubeomatic-io-timebomb-timer",."kubeomatic-io-timebomb-valid",."kubeomatic-io-timebomb-valid-human")]|@csv'| \
while IFS=\" read V{1..15}
do
export RC=$(echo $V8 | grep ^$2 | wc -l | awk '{print $1}')
if [ $RC -eq 1 ]
then
export EPOCH=$(expr $(date +"%s") + $(expr 60 \* $1 ) )
echo Patching $V6 $V2/$V4 SKU=$V8 LABEL=$V10 EPOCH=$V12 CurrentExpire=\"$V14\" Expire=\"$(date -r $EPOCH "+%Y/%m/%d_%H:%M:%S")\"
kubectl \
-n $V2 patch deployment $V4 \
--type='json' \
-p='[
{"op": "replace", "path": "/spec/template/metadata/annotations/kubeomatic-io-timebomb-valid", "value":"'$EPOCH'"},
{"op": "replace", "path": "/spec/template/metadata/annotations/kubeomatic-io-timebomb-valid-human", "value":"'$(date -r $EPOCH "+%Y/%m/%d_%H:%M:%S")'"}]'
fi
done
fi
}
function ADD_DATA() {
export EPOCH=$(expr $(date +"%s") - 10800 )
kubectl -n $1 get deployments --no-headers| \
awk ' {print $1}' | \
while read DP
do
kubectl \
-n $1 patch deployment $DP \
--type='json' \
-p='[
{"op": "add", "path": "/spec/template/metadata/annotations/kubeomatic-io-timebomb-valid", "value":"'$EPOCH'"},
{"op": "add", "path": "/spec/template/metadata/annotations/kubeomatic-io-timebomb-valid-human", "value":"'$(date -r $EPOCH "+%Y/%m/%d_%H:%M:%S")'"},
{"op": "add", "path": "/spec/template/metadata/annotations/kubeomatic-io-timebomb-timer", "value":"1m"},
{"op": "add", "path": "/spec/template/metadata/annotations/kubeomatic-io-timebomb-sku", "value":"/avo/pai/filho"},
{"op": "add", "path": "/spec/template/metadata/labels/kubeomatic-io-timebomb", "value":"enabled"},
{"op": "add", "path": "/metadata/labels/kubeomatic-io-timebomb", "value":"enabled"}]'
done
kubectl \
patch ns $1 \
--type='json' \
-p='[{"op": "add", "path": "/metadata/labels/kubeomatic-io-timebomb", "value":"enabled"}]'
}