From 317ebe44030cd9b0ac606480a16eae2562c4a810 Mon Sep 17 00:00:00 2001 From: Jonas Juselius Date: Wed, 5 Jun 2024 10:16:00 +0200 Subject: [PATCH] feat: improved helm chart and repo support --- argo/kustomize-helm-with-rewrite/Dockerfile | 2 +- argo/kustomize-helm-with-rewrite/generate.sh | 15 +++++++-------- argo/kustomize-helm-with-rewrite/get-values.sh | 2 ++ .../init-helm-repos.sh | 16 ++++++++++++++++ argo/kustomize-helm-with-rewrite/init.sh | 18 +++++++----------- 5 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 argo/kustomize-helm-with-rewrite/init-helm-repos.sh diff --git a/argo/kustomize-helm-with-rewrite/Dockerfile b/argo/kustomize-helm-with-rewrite/Dockerfile index 8a2ffbdf..3b77b027 100644 --- a/argo/kustomize-helm-with-rewrite/Dockerfile +++ b/argo/kustomize-helm-with-rewrite/Dockerfile @@ -4,4 +4,4 @@ RUN mkdir -p /home/argocd/cmp-server/config/ COPY plugin.yaml /home/argocd/cmp-server/config/ WORKDIR /plugin -COPY init.sh get-values.sh generate.sh ./ +COPY init-helm-repos.sh init.sh get-values.sh generate.sh ./ diff --git a/argo/kustomize-helm-with-rewrite/generate.sh b/argo/kustomize-helm-with-rewrite/generate.sh index 6d6c7cdd..ac2fb4da 100644 --- a/argo/kustomize-helm-with-rewrite/generate.sh +++ b/argo/kustomize-helm-with-rewrite/generate.sh @@ -1,25 +1,24 @@ #!/bin/sh -export HOME=/tmp +export HOME=/helm-working-dir env > /tmp/$ARGOCD_APP_NAME.env echo "$ARGOCD_APP_PARAMETERS" | jq '.[] | select(.name == "helm-parameters") | .map' | yq -P -oy > parameters.yaml cp parameters.yaml /tmp/$ARGOCD_APP_NAME-parameters.yaml -if [ -d chart ]; then - CHART=chart -elif [ -f chart -o "$PARAM_CHART" = "." ]; then - CHART=$(cat chart) - helm show values $CHART > values-base.yaml -elif [ -n "$PARAM_CHART" ]; then +if [ -n "$PARAM_CHART" -a "$PARAM_CHART" != "." ]; then CHART=$PARAM_CHART +elif [ -d chart ]; then + CHART=chart +elif [ -f chart ]; then + CHART=$(cat chart) else CHART="." fi [ -f chart/values.yaml ] && VALUES="-f chart/values.yaml" -[ -f values-base.yaml ] && VALUES="$VALUES -f values-base.yaml" +[ -f values-chart.yaml ] && VALUES="$VALUES -f values-chart.yaml" [ -f values.yaml ] && VALUES="$VALUES -f values.yaml" [ -f values-$PARAM_ENV.yaml ] && VALUES="$VALUES -f values-$PARAM_ENV.yaml" VALUES="$VALUES -f parameters.yaml" diff --git a/argo/kustomize-helm-with-rewrite/get-values.sh b/argo/kustomize-helm-with-rewrite/get-values.sh index 33338063..738905f5 100644 --- a/argo/kustomize-helm-with-rewrite/get-values.sh +++ b/argo/kustomize-helm-with-rewrite/get-values.sh @@ -2,6 +2,8 @@ if [ -f values.yaml ]; then VALUES="values.yaml" +elif [ -f values-chart.yaml ]; then + VALUES="values-chart.yaml" elif [ -f chart/values.yaml ]; then VALUES="chart/values.yaml" else diff --git a/argo/kustomize-helm-with-rewrite/init-helm-repos.sh b/argo/kustomize-helm-with-rewrite/init-helm-repos.sh new file mode 100644 index 00000000..39a036c6 --- /dev/null +++ b/argo/kustomize-helm-with-rewrite/init-helm-repos.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +export HOME=/helm-working-dir + +helm repo add --username argocd-helm --password "$OCEANBOX_HELM_ACCESS_TOKEN" oceanbox \ + https://gitlab.com/api/v4/projects/54396343/packages/helm/stable + +helm repo add bitnami https://charts.bitnami.com/bitnami +helm repo add cerbos https://download.cerbos.dev/helm-charts +helm repo add dapr https://dapr.github.io/helm-charts/ +helm repo add ncsa https://opensource.ncsa.illinois.edu/charts +helm repo add dex https://charts.dexidp.io + +helm repo update + + diff --git a/argo/kustomize-helm-with-rewrite/init.sh b/argo/kustomize-helm-with-rewrite/init.sh index 99be1a0c..2d92f9be 100644 --- a/argo/kustomize-helm-with-rewrite/init.sh +++ b/argo/kustomize-helm-with-rewrite/init.sh @@ -1,14 +1,10 @@ #!/bin/sh -export HOME=/tmp - -helm repo add oceanbox --password $OCEANBOX_HELM_ACCESS_TOKEN oceanbox https://gitlab.com/api/v4/projects/54396343/packages/helm/stabl - -helm repo add bitnami https://charts.bitnami.com/bitnami -helm repo add cerbos https://download.cerbos.dev/helm-charts -helm repo add dapr https://dapr.github.io/helm-charts/ -helm repo add ncsa https://opensource.ncsa.illinois.edu/charts -helm repo add dex https://charts.dexidp.io - -helm repo update +export HOME=/helm-working-dir +if [ -n "$PARAM_CHART" -a "$PARAM_CHART" != "." ]; then + helm show values $PARAM_CHART > values-chart.yaml +elif [ -f chart ]; then + CHART=$(cat chart) + helm show values $CHART > values-chart.yaml +fi