argocd/argo1/install-crds.sh

59 lines
1.2 KiB
Bash
Raw Normal View History

2023-04-23 16:19:35 +00:00
#!/bin/bash
2023-04-23 23:56:07 +00:00
MAINDIR="$(dirname "$0")"
cd "$MAINDIR"
2023-04-23 16:19:35 +00:00
2023-04-23 23:56:07 +00:00
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
for f in templates/*.yaml
2023-04-23 16:19:35 +00:00
(
set -e
2023-04-23 23:56:07 +00:00
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 -
2023-04-23 16:19:35 +00:00
)
RC=$?
if [ $RC -ne 0 ];then
2023-04-23 23:56:07 +00:00
1>&2 echo "exiting due to error creating Sealed Secrets CRDs"
2023-04-23 16:19:35 +00:00
exit $RC
fi