Fail fast on variable conflicts with subscription config (#4915)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
Azure SDK Bot 2023-08-25 12:22:14 -07:00 committed by GitHub
parent dd23631119
commit 80b6fc6022
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -109,11 +109,17 @@ function SetSubscriptionConfiguration([object]$subscriptionConfiguration)
# Mark values as secret so we don't print json blobs containing secrets in the logs.
# Prepend underscore to the variable name, so we can still access the variable names via environment
# variables if they get set subsequently.
if ([Environment]::GetEnvironmentVariable($nestedPair.Name)) {
throw "Environment variable '$($nestedPair.Name)' is already set. Check the tests.yml/ci.yml EnvVars parameter does not conflict with the subscription config json"
}
if (ShouldMarkValueAsSecret "AZURE_" $nestedPair.Name $nestedPair.Value) {
Write-Host "##vso[task.setvariable variable=_$($nestedPair.Name);issecret=true;]$($nestedPair.Value)"
}
}
} else {
if ([Environment]::GetEnvironmentVariable($pair.Name)) {
throw "Environment variable '$($pair.Name)' is already set. Check the tests.yml/ci.yml EnvVars parameter does not conflict with the subscription config json"
}
if (ShouldMarkValueAsSecret "AZURE_" $pair.Name $pair.Value) {
Write-Host "##vso[task.setvariable variable=_$($pair.Name);issecret=true;]$($pair.Value)"
}

View File

@ -5,6 +5,10 @@ parameters:
- name: SubscriptionConfigurations
type: object
default: null
# EnvVars is used to help diagnose variable conflict issues early
- name: EnvVars
type: object
default: null
steps:
- ${{ if parameters.SubscriptionConfiguration }}:
@ -16,6 +20,8 @@ steps:
. ./eng/common/TestResources/SubConfig-Helpers.ps1
SetSubscriptionConfiguration $config
displayName: Initialize SubscriptionConfiguration variable
${{ if parameters.EnvVars }}:
env: ${{ parameters.EnvVars }}
- ${{ if parameters.SubscriptionConfigurations }}:
- pwsh: |
@ -36,3 +42,5 @@ steps:
UpdateSubscriptionConfiguration $configBase $config
displayName: Merge Test Resource Configurations
${{ if parameters.EnvVars }}:
env: ${{ parameters.EnvVars }}