-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate if all required env vars are supplied. (#12879)
* Decouple crib config from cl-cluster helm chart * Validate required env vars Validate if all required env vars are supplied * explain how to fix missing vars * add info about example
- Loading branch information
1 parent
f78f0b5
commit 0f28e36
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# List of required environment variables | ||
required_vars=( | ||
"DEVSPACE_IMAGE" | ||
"DEVSPACE_INGRESS_CIDRS" | ||
"DEVSPACE_INGRESS_BASE_DOMAIN" | ||
"DEVSPACE_INGRESS_CERT_ARN" | ||
"DEVSPACE_K8S_POD_WAIT_TIMEOUT" | ||
"NS_TTL" | ||
) | ||
|
||
missing_vars=0 # Counter for missing variables | ||
|
||
# Check each variable | ||
for var in "${required_vars[@]}"; do | ||
if [ -z "${!var}" ]; then # If variable is unset or empty | ||
echo "Error: Environment variable $var is not set." | ||
missing_vars=$((missing_vars + 1)) | ||
fi | ||
done | ||
|
||
# Exit with an error if any variables were missing | ||
if [ $missing_vars -ne 0 ]; then | ||
echo "Total missing environment variables: $missing_vars" | ||
echo "To fix it, add missing variables in the \"crib/.env\" file." | ||
echo "you can find example of the .env config in the \"crib/.env.example\"" | ||
exit 1 | ||
else | ||
echo "All required environment variables are set." | ||
fi |