argo1/argo1/install-crds.sh
2023-04-23 21:56:38 -05:00

57 lines
1.2 KiB
Bash

#!/bin/bash
MAINDIR="$(dirname "$0")"
cd "$MAINDIR"
application_chart_info() {
F="$1"
yq -o json . "$F" | jq -r '
.spec.source
| (
@sh "CHART=\(.chart)",
@sh "VERSION=\(.targetRevision)",
@sh "REPO=\(.repoURL)"
)
'
}
dependency_chart_info() {
F="${1:-"$MAINDIR"/Chart.yaml}"
DEP="${2:-0}"
yq -o json . "$F" | jq -r --argjson d "$DEP" '
.dependencies[$d]
| (
@sh "CHART=\(.name)",
@sh "VERSION=\(.version)",
@sh "REPO=\(.repository)"
)
'
}
(
set -e
eval "$(dependency_chart_info)"
set -x
helm template argocd-crds --include-crds "$CHART" --repo "$REPO" --version "$VERSION" | yq 'select(.kind == "CustomResourceDefinition")' | kubectl apply -f -
)
RC=$?
if [ $RC -ne 0 ];then
1>&2 echo "exiting due to error creating ArgoCD CRDs"
exit $RC
fi
(
set -e
eval "$(application_chart_info templates/sealed-secrets.yaml)"
set -x
helm template sealed-secrets-crds --include-crds "$CHART" --repo "$REPO" --version "$VERSION" | yq 'select(.kind == "CustomResourceDefinition")' | kubectl apply -f -
)
RC=$?
if [ $RC -ne 0 ];then
1>&2 echo "exiting due to error creating Sealed Secrets CRDs"
exit $RC
fi