Skip to content

Commit 80e8d00

Browse files
azure-sdkbenbp
andauthored
Sync eng/common directory with azure-sdk-tools for PR 8902 (Azure#37229)
* Add descriptive error when variable groups are not added to pipeline * Add emoji to deploy step title to make it easier to find * Move yaml json checking into powershell script * Fix base sub config empty/string checking --------- Co-authored-by: Ben Broderick Phillips <[email protected]>
1 parent acb9247 commit 80e8d00

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

eng/common/TestResources/SubConfig-Helpers.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,26 @@ function UpdateSubscriptionConfigurationWithFiles([object]$baseSubConfig, [strin
196196
# Helper function for processing stringified json sub configs from pipeline parameter data
197197
function BuildAndSetSubscriptionConfig([string]$baseSubConfigJson, [string]$additionalSubConfigsJson, [string]$subConfigFilesJson) {
198198
$finalConfig = @{}
199-
if ($baseSubConfigJson) {
199+
200+
if ($baseSubConfigJson -and $baseSubConfigJson -ne '""') {
201+
# When variable groups are not added to the pipeline, secret references like
202+
# $(<my secret>) are passed as a string literal instead of being replaced by the keyvault secret value
203+
if ($baseSubConfigJson -notlike '{*') {
204+
throw "Expected a json dictionary object but found '$baseSubConfigJson'. This probably means a subscription config secret was not downloaded. The pipeline is likely missing a variable group."
205+
}
200206
$baseSubConfig = $baseSubConfigJson | ConvertFrom-Json -AsHashtable
201207

202208
Write-Host "Setting base sub config"
203209
$finalConfig = SetSubscriptionConfiguration $baseSubConfig
204210
}
205211

206-
if ($additionalSubConfigsJson) {
212+
if ($additionalSubConfigsJson -and $additionalSubConfigsJson -ne '""') {
207213
$subConfigs = $additionalSubConfigsJson | ConvertFrom-Json -AsHashtable
208214

209215
foreach ($subConfig in $subConfigs) {
216+
if ($subConfig -isnot [hashtable]) {
217+
throw "Expected a json dictionary object but found '$subConfig'. This probably means a subscription config secret was not downloaded. The pipeline is likely missing a variable group."
218+
}
210219
Write-Host "Merging sub config from list"
211220
$finalConfig = UpdateSubscriptionConfiguration $finalConfig $subConfig
212221
}

eng/common/TestResources/deploy-test-resources.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ steps:
4343

4444
- ${{ if eq('true', parameters.UseFederatedAuth) }}:
4545
- task: AzurePowerShell@5
46-
displayName: Deploy test resources
46+
displayName: 🚀 Deploy test resources
4747
env:
4848
TEMP: $(Agent.TempDirectory)
4949
PoolSubnet: $(PoolSubnet)
@@ -96,7 +96,7 @@ steps:
9696
-ServicePrincipalAuth `
9797
-Force `
9898
-Verbose | Out-Null
99-
displayName: Deploy test resources
99+
displayName: 🚀 Deploy test resources
100100
env:
101101
TEMP: $(Agent.TempDirectory)
102102
PoolSubnet: $(PoolSubnet)

0 commit comments

Comments
 (0)