#!/bin/bash cd "$(dirname "$0")/argo1" TARGETNS="argocd" ORIGNS="$(kubectl config view --minify -o jsonpath='{..namespace}')" all_subapps() { ( for f in templates/*.yaml;do sed -e '1!d' "$f" done ) \ | grep -Eo '^#? *[{][{](- )? *if [(]index [.]Values "[^"]*"[)][.]enabled *( -)?[}][}]' \ | cut -d '"' -f 2 } ( set -e [ x"$TARGETNS" != x"$ORIGNS" ] && kubectl config set-context --current --namespace $TARGETNS ( IFS=$'\n' for app in $(all_subapps);do argocd --core app set argo1 --helm-set "$app".enabled=false done ) sleep 10 argocd --core app wait --sync argo1 helm uninstall -n "$TARGETNS" argo1 bash delete-crds.sh ) [ x"$TARGETNS" != x"$ORIGNS" ] && kubectl config set-context --current --namespace "$ORIGNS"