From 039ca579ac7d4e7f9ff466b225a1aa3d538434b9 Mon Sep 17 00:00:00 2001 From: Valeri GOLUBEV Date: Mon, 5 Feb 2024 13:07:59 +0100 Subject: [PATCH] Add support for optional skip of passing versions of k8s and APIs from command line --- src/argo-cd-helmfile.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/argo-cd-helmfile.sh b/src/argo-cd-helmfile.sh index 2d148c3..c4850fb 100755 --- a/src/argo-cd-helmfile.sh +++ b/src/argo-cd-helmfile.sh @@ -14,6 +14,7 @@ # HELMFILE_REPO_CACHE_TIMEOUT - seconds to cache the repo update process # HELMFILE_USE_CONTEXT_NAMESPACE - do not set helmfile namespace to ARGOCD_APP_NAMESPACE (for multi-namespace apps) # HELMFILE_DISCOVERY_RESPONSE - truthy value for forced response +# HELMFILE_PASS_VERSIONS - pass the K8s and API versions as command-line args # HELM_HOME - perform variable expansion # HELM_CACHE_HOME - perform variable expansion # HELM_CONFIG_HOME - perform variable expansion @@ -185,6 +186,10 @@ fi # immediately correct PATH if necessary export PATH=$(variable_expansion "${PATH}") +# pass k8s and api versions to helm as command-line args if set to true +# maybe set to false for some edge cases like working with OCI registry + : ${HELMFILE_PASS_VERSIONS:=true} + # expand nested variables if [[ "${HELMFILE_GLOBAL_OPTIONS}" ]]; then HELMFILE_GLOBAL_OPTIONS=$(variable_expansion "${HELMFILE_GLOBAL_OPTIONS}") @@ -385,17 +390,17 @@ case $phase in # --no-hooks prevent hooks from running during install # --skip-crds if set, no CRDs will be installed. By default, CRDs are installed if not already present - if [[ ${helm_major_version} -eq 2 && "${KUBE_VERSION}" ]]; then + if truthy_test "${HELMFILE_PASS_VERSIONS}" && [[ ${helm_major_version} -eq 2 && "${KUBE_VERSION}" ]]; then INTERNAL_HELM_TEMPLATE_OPTIONS="${INTERNAL_HELM_TEMPLATE_OPTIONS} --kube-version=${KUBE_VERSION}" fi # support added for --kube-version in 3.6 # https://github.com/helm/helm/pull/9040 - if [[ ${helm_major_version} -eq 3 && ${helm_minor_version} -ge 6 && "${KUBE_VERSION}" ]]; then + if truthy_test "${HELMFILE_PASS_VERSIONS}" && [[ ${helm_major_version} -eq 3 && ${helm_minor_version} -ge 6 && "${KUBE_VERSION}" ]]; then INTERNAL_HELM_TEMPLATE_OPTIONS="${INTERNAL_HELM_TEMPLATE_OPTIONS} --kube-version=${KUBE_VERSION}" fi - if [[ ${helm_major_version} -eq 3 && "${KUBE_API_VERSIONS}" ]]; then + if truthy_test "${HELMFILE_PASS_VERSIONS}" && [[ ${helm_major_version} -eq 3 && "${KUBE_API_VERSIONS}" ]]; then INTERNAL_HELM_API_VERSIONS="" for v in ${KUBE_API_VERSIONS//,/ }; do INTERNAL_HELM_API_VERSIONS="${INTERNAL_HELM_API_VERSIONS} --api-versions=$v"