From abdc2e88cb85b7f2acbf60f559879858f8b5cb89 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Thu, 2 Oct 2025 16:49:38 +0200 Subject: [PATCH] Fix variables to allow override of all variables with environment files --- helm/scripts/variables.sh | 49 +++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/helm/scripts/variables.sh b/helm/scripts/variables.sh index 70929e2..26e4c71 100755 --- a/helm/scripts/variables.sh +++ b/helm/scripts/variables.sh @@ -112,6 +112,34 @@ export VAULT_ACCESS_TOKEN="dev-only-token" ## Only for testing purpouses, configuration of mock-server port export MOCK_SERVER_PORT="9100" +# special configuration for capif deployment + +## Setup KUBECONFIG +export KUBECONFIG=$CUSTOM_KUBECONFIG + +## If CAPIF_STORAGE_CLASS is longhorn, then we need to set runAsUser to 0 in some deployments to allow write on PVC +export CAPIF_RUN_AS_USER_CONFIG="" + +## SED command, in MacOS sed is different and need gnu-sed (gsed) +export SED_CMD=sed + +# Load environment variables from file +## Directory for environment variables +ENV_DIR="$SCRIPTS_DIR/envs" + +## Environment selection (default: dev) +ENVIRONMENT="${1:-dev}" +ENV_FILE="$ENV_DIR/$ENVIRONMENT.env" + +if [ -f "$ENV_FILE" ]; then + echo "Loading environment configuration: $ENVIRONMENT" + set -a + source "$ENV_FILE" + set +a +else + echo "Environment file not found: $ENV_FILE. Using default values." +fi + ######### POST PROCESSING VARIABLES SET ######## ### To deploy in other environment we need to setup urls according to it and also using specific kubeconfig: if [ -f "$VAULT_FILE" ] && [ -s "$VAULT_FILE" ]; then @@ -122,8 +150,7 @@ else fi echo "Using value on VAULT_ACCESS_TOKEN=$VAULT_ACCESS_TOKEN" -## Setup KUBECONFIG -export KUBECONFIG=$CUSTOM_KUBECONFIG + ### If K8S_IP is empty, then script will try to get ingress-nginx-controller NodePort to grant DNS resolution for register to connect locally to CAPIF nginx if [ "$K8S_IP" == "NONE" ]; then @@ -166,7 +193,7 @@ if [ -n "$CAPIF_STORAGE_ACCESS_MODE" ]; then " fi -export CAPIF_RUN_AS_USER_CONFIG="" + if [ "$CAPIF_STORAGE_CLASS" == "longhorn" ]; then echo "$CAPIF_STORAGE_CLASS needs to configure runAsUser at mongo, mongo-register and grafana to 0, in order to allow write con PVC created." CAPIF_RUN_AS_USER_CONFIG="--set mongo.securityContext.runAsUser=0 @@ -174,7 +201,7 @@ if [ "$CAPIF_STORAGE_CLASS" == "longhorn" ]; then --set grafana.securityContext.runAsUser=0" fi -export SED_CMD=sed + if [[ "$OSTYPE" == "darwin"* ]]; then # Require gnu-sed. if ! [ -x "$(command -v gsed)" ]; then @@ -203,18 +230,4 @@ else done fi -# Directory for environment variables -ENV_DIR="$SCRIPTS_DIR/envs" - -# Environment selection (default: dev) -ENVIRONMENT="${1:-dev}" -ENV_FILE="$ENV_DIR/$ENVIRONMENT.env" -if [ -f "$ENV_FILE" ]; then - echo "Loading environment configuration: $ENVIRONMENT" - set -a - source "$ENV_FILE" - set +a -else - echo "Environment file not found: $ENV_FILE. Using default values." -fi -- GitLab