File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed
Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,17 @@ metadata:
7788
99hooks :
10+ preup :
11+ posix :
12+ shell : sh
13+ run : chmod u+r+x ./scripts/validate_env_vars.sh; ./scripts/validate_env_vars.sh
14+ interactive : true
15+ continueOnError : false
16+ windows :
17+ shell : pwsh
18+ run : ./scripts/validate_env_vars.ps1
19+ interactive : true
20+ continueOnError : false
1021 preprovision :
1122 posix :
1223 shell : sh
Original file line number Diff line number Diff line change 1+ # Define environment variables and their regex patterns
2+ $envValidationRules = @ {
3+ " AZURE_EXISTING_AIPROJECT_RESOURCE_ID" = ' ^/subscriptions/[0-9a-fA-F-]{36}/resourceGroups/[^/]+/providers/Microsoft\.CognitiveServices/accounts/[^/]+/projects/[^/]+$'
4+ }
5+
6+ $hasError = $false
7+
8+ foreach ($envVar in $envValidationRules.Keys ) {
9+ $pattern = $envValidationRules [$envVar ]
10+ $value = [Environment ]::GetEnvironmentVariable($envVar )
11+
12+ if ($value ) {
13+ if ($value -notmatch $pattern ) {
14+ Write-Host " ❌ Invalid value for '$envVar '. Expected pattern: $pattern "
15+ $hasError = $true
16+ }
17+ }
18+ }
19+
20+ if ($hasError ) {
21+ exit 1
22+ }
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Define environment variables and their regex patterns
4+ declare -A envValidationRules=(
5+ [" AZURE_EXISTING_AIPROJECT_RESOURCE_ID" ]=' ^/subscriptions/[0-9a-fA-F-]{36}/resourceGroups/[^/]+/providers/Microsoft\.CognitiveServices/accounts/[^/]+/projects/[^/]+$'
6+ )
7+
8+ hasError=0
9+
10+ for envVar in " ${! envValidationRules[@]} " ; do
11+ pattern=" ${envValidationRules[$envVar]} "
12+ value=" ${! envVar} "
13+
14+ if [[ -n " $value " ]]; then
15+ if ! echo " $value " | grep -Eq " $pattern " ; then
16+ echo " ❌ Invalid value for '$envVar '. Expected pattern: $pattern " >&2
17+ hasError=1
18+ fi
19+ fi
20+ done
21+
22+ exit $hasError
You can’t perform that action at this time.
0 commit comments