From cfcfac67f7228b7b4a2dfe46fc8a007557cb843a Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:04:41 -0700 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools for PR 8902 (#5965) * 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 --- eng/common/TestResources/SubConfig-Helpers.ps1 | 13 +++++++++++-- eng/common/TestResources/deploy-test-resources.yml | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/eng/common/TestResources/SubConfig-Helpers.ps1 b/eng/common/TestResources/SubConfig-Helpers.ps1 index 8df6440fe..ab2344283 100644 --- a/eng/common/TestResources/SubConfig-Helpers.ps1 +++ b/eng/common/TestResources/SubConfig-Helpers.ps1 @@ -196,17 +196,26 @@ function UpdateSubscriptionConfigurationWithFiles([object]$baseSubConfig, [strin # Helper function for processing stringified json sub configs from pipeline parameter data function BuildAndSetSubscriptionConfig([string]$baseSubConfigJson, [string]$additionalSubConfigsJson, [string]$subConfigFilesJson) { $finalConfig = @{} - if ($baseSubConfigJson) { + + if ($baseSubConfigJson -and $baseSubConfigJson -ne '""') { + # When variable groups are not added to the pipeline, secret references like + # $() are passed as a string literal instead of being replaced by the keyvault secret value + if ($baseSubConfigJson -notlike '{*') { + 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." + } $baseSubConfig = $baseSubConfigJson | ConvertFrom-Json -AsHashtable Write-Host "Setting base sub config" $finalConfig = SetSubscriptionConfiguration $baseSubConfig } - if ($additionalSubConfigsJson) { + if ($additionalSubConfigsJson -and $additionalSubConfigsJson -ne '""') { $subConfigs = $additionalSubConfigsJson | ConvertFrom-Json -AsHashtable foreach ($subConfig in $subConfigs) { + if ($subConfig -isnot [hashtable]) { + 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." + } Write-Host "Merging sub config from list" $finalConfig = UpdateSubscriptionConfiguration $finalConfig $subConfig } diff --git a/eng/common/TestResources/deploy-test-resources.yml b/eng/common/TestResources/deploy-test-resources.yml index d5fd1d353..840acfd9e 100644 --- a/eng/common/TestResources/deploy-test-resources.yml +++ b/eng/common/TestResources/deploy-test-resources.yml @@ -43,7 +43,7 @@ steps: - ${{ if eq('true', parameters.UseFederatedAuth) }}: - task: AzurePowerShell@5 - displayName: Deploy test resources + displayName: 🚀 Deploy test resources env: TEMP: $(Agent.TempDirectory) PoolSubnet: $(PoolSubnet) @@ -96,7 +96,7 @@ steps: -ServicePrincipalAuth ` -Force ` -Verbose | Out-Null - displayName: Deploy test resources + displayName: 🚀 Deploy test resources env: TEMP: $(Agent.TempDirectory) PoolSubnet: $(PoolSubnet)