From 22071927a0d141a8d533d94faccf0c675c620724 Mon Sep 17 00:00:00 2001 From: ties Date: Thu, 29 Aug 2024 11:20:02 +0000 Subject: [PATCH] Add createServiceAccount.sh --- createServiceAccount.sh | 119 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 createServiceAccount.sh diff --git a/createServiceAccount.sh b/createServiceAccount.sh new file mode 100644 index 0000000..742eee5 --- /dev/null +++ b/createServiceAccount.sh @@ -0,0 +1,119 @@ +#!/bin/bash + +# Extract namespace from values.yaml using yq +NAMESPACE=$(yq e '.namespace' values.yaml) + +# Set the ServiceAccount, Role, and RoleBinding names based on the namespace +SA_NAME="${NAMESPACE}-cicd" + +# Capture Helm template output directly with dynamic subchartData +HELM_OUTPUT=$(helm template -g --set-json="subchartData=$(yq '.dependencies[0]' Chart.yaml -ojson | jq -rc)" .) + +# Extract unique apiVersion and kind pairs using yq and jq +resources=$(echo "$HELM_OUTPUT" | yq -o=json | jq -rc '{apiVersion, kind}' | sort | uniq) + +cat <