Commit 12d488ff authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Merge branch 'hot-fix-helm-scripts' into 'staging'

Fix variables to allow override of all variables with environment files

See merge request !152
parents 72906303 abdc2e88
Loading
Loading
Loading
Loading
Loading
+31 −18
Original line number Original line Diff line number Diff line
@@ -112,6 +112,34 @@ export VAULT_ACCESS_TOKEN="dev-only-token"
## Only for testing purpouses, configuration of mock-server port
## Only for testing purpouses, configuration of mock-server port
export MOCK_SERVER_PORT="9100"
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 ########
######### POST PROCESSING VARIABLES SET ########
### To deploy in other environment we need to setup urls according to it and also using specific kubeconfig:
### 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
if [ -f "$VAULT_FILE" ] && [ -s "$VAULT_FILE" ]; then
@@ -122,8 +150,7 @@ else
fi
fi
echo "Using value on VAULT_ACCESS_TOKEN=$VAULT_ACCESS_TOKEN"
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 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
if [ "$K8S_IP" == "NONE" ]; then
@@ -166,7 +193,7 @@ if [ -n "$CAPIF_STORAGE_ACCESS_MODE" ]; then
    "
    "
fi
fi


export CAPIF_RUN_AS_USER_CONFIG=""

if [ "$CAPIF_STORAGE_CLASS" == "longhorn" ]; then
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."
    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
    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"
    --set grafana.securityContext.runAsUser=0"
fi
fi


export SED_CMD=sed

if [[ "$OSTYPE" == "darwin"* ]]; then
if [[ "$OSTYPE" == "darwin"* ]]; then
  # Require gnu-sed.
  # Require gnu-sed.
  if ! [ -x "$(command -v gsed)" ]; then
  if ! [ -x "$(command -v gsed)" ]; then
@@ -203,18 +230,4 @@ else
    done
    done
fi
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