From adb4e61801cd35f06247bbeafd101c70eed7aa0b Mon Sep 17 00:00:00 2001 From: Hari Sekhon Date: Wed, 10 May 2023 03:46:37 +0100 Subject: [PATCH] updated kustomize_install_helm_charts.sh --- kubernetes/kustomize_install_helm_charts.sh | 53 +++++++++++---------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/kubernetes/kustomize_install_helm_charts.sh b/kubernetes/kustomize_install_helm_charts.sh index 782b9171..8a4a3b83 100755 --- a/kubernetes/kustomize_install_helm_charts.sh +++ b/kubernetes/kustomize_install_helm_charts.sh @@ -56,29 +56,34 @@ if [ -n "${SKIP_EXISTING_HELM_INSTALLATIONS:-}" ]; then helm_installations="$(helm ls -A -o json | jq -r '.[].name')" fi -"$srcdir/kustomize_parse_helm_charts.sh" "$@" | -while read -r repo_url name version values_file; do - if [ -n "${SKIP_EXISTING_HELM_INSTALLATIONS:-}" ]; then - if grep -Fxq "$name" <<< "$helm_installations"; then - timestamp "Skipping existing Helm installation: $name" - continue +for kustomization in "$@"; do + pushd "$(dirname "$kustomization")" >/dev/null + kustomization="${kustomization##*/}" + "$srcdir/kustomize_parse_helm_charts.sh" "$kustomization" | + while read -r repo_url name version values_file; do + if [ -n "${SKIP_EXISTING_HELM_INSTALLATIONS:-}" ]; then + if grep -Fxq "$name" <<< "$helm_installations"; then + timestamp "Skipping existing Helm installation: $name" + continue + fi fi - fi - if [ "$values_file" = null ]; then - values_file="" - fi - if ! grep -Eq "^${name}[[:space:]]+${repo_url}[[:space:]]*$" <<< "$helm_repos"; then - timestamp "Adding Helm repo '$repo_url' as name '$name'" - # might fail here if you've already installed a repo with this name, in which case, fix your repos, we don't want to remove/modify your existing repos - helm repo add "$name" "$repo_url" - fi - timestamp "Installing Helm chart '$name' version '$version' from '$repo_url'" - if [ -n "${SKIP_ERRORS:-}" ]; then - set +e - fi - helm install "$name" "$name/$name" --version "$version" --create-namespace --namespace "$name" ${values_file:+--values "$values_file"} - if [ -n "${SKIP_ERRORS:-}" ]; then - set -e - fi - echo + if [ "$values_file" = null ]; then + values_file="" + fi + if ! grep -Eq "^${name}[[:space:]]+${repo_url}[[:space:]]*$" <<< "$helm_repos"; then + timestamp "Adding Helm repo '$repo_url' as name '$name'" + # might fail here if you've already installed a repo with this name, in which case, fix your repos, we don't want to remove/modify your existing repos + helm repo add "$name" "$repo_url" + fi + timestamp "Installing Helm chart '$name' version '$version' from '$repo_url'" + if [ -n "${SKIP_ERRORS:-}" ]; then + set +e + fi + helm install "$name" "$name/$name" --version "$version" --create-namespace --namespace "$name" ${values_file:+--values "$values_file"} + if [ -n "${SKIP_ERRORS:-}" ]; then + set -e + fi + echo + done + popd >/dev/null done