diff --git a/argo1/templates/haproxy-ingress.yaml b/argo1/templates/haproxy-ingress.yaml index 6033224..ed55e13 100644 --- a/argo1/templates/haproxy-ingress.yaml +++ b/argo1/templates/haproxy-ingress.yaml @@ -1,4 +1,4 @@ -# {{ if (index .Values "haproxy-ingress").enabled -}} +# {{ if (index .Values "haproxy-ingress").enabled }} --- apiVersion: argoproj.io/v1alpha1 kind: Application @@ -14,7 +14,8 @@ spec: repoURL: https://haproxy-ingress.github.io/charts targetRevision: 0.14.2 helm: - values: |-{{ (index .Values "haproxy-ingress").values | nindent 8 }} + values: |- + {{ (index .Values "haproxy-ingress").values | nindent 8 }} releaseName: haproxy-ingress destination: server: "https://kubernetes.default.svc" diff --git a/argo1/templates/sealed-secrets.yaml b/argo1/templates/sealed-secrets.yaml index 0ccf93e..3b662ec 100644 --- a/argo1/templates/sealed-secrets.yaml +++ b/argo1/templates/sealed-secrets.yaml @@ -1,4 +1,4 @@ -# {{ if (index .Values "sealed-secrets").enabled -}} +# {{ if (index .Values "sealed-secrets").enabled }} --- apiVersion: argoproj.io/v1alpha1 kind: Application diff --git a/argo1/templates/secrets.yaml b/argo1/templates/secrets.yaml index 5fe6cb6..192316e 100644 --- a/argo1/templates/secrets.yaml +++ b/argo1/templates/secrets.yaml @@ -1,4 +1,4 @@ -{{ if (index .Values "secrets").enabled -}} +# {{ if (index .Values "secrets").enabled }} apiVersion: argoproj.io/v1alpha1 kind: Application metadata: @@ -30,4 +30,4 @@ spec: duration: 5s factor: 2 maxDuration: 3m0s -{{- end }} +# {{- end }} diff --git a/uninstall.sh b/uninstall.sh index 7ee2670..87c080d 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -5,12 +5,28 @@ 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 - argocd --core app set argo1 --helm-set sealed-secrets.enabled=false --helm-set secrets.enabled=false - argocd --core app sync argo1 || argocd --core app wait --sync argo1 + ( + 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 )