Skip to content

Commit

Permalink
Merge subscription configuration file values with the supplied subscr…
Browse files Browse the repository at this point in the history
…iption config
  • Loading branch information
danieljurek authored and azure-sdk committed Jun 11, 2024
1 parent cd2a02e commit 5cda8d3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
16 changes: 16 additions & 0 deletions eng/common/TestResources/build-test-resource-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ parameters:
- name: EnvVars
type: object
default: null
- name: SubscriptionConfigurationFilePath
type: string
default: ''

steps:
- ${{ if parameters.SubscriptionConfiguration }}:
Expand Down Expand Up @@ -44,3 +47,16 @@ steps:
displayName: Merge Test Resource Configurations
${{ if parameters.EnvVars }}:
env: ${{ parameters.EnvVars }}
- ${{ if ne(parameters.SubscriptionConfigurationFilePath, '') }}:
- pwsh: |
$configBase = @'
$(SubscriptionConfiguration)
'@ | ConvertFrom-Json -AsHashtable
$config = Get-Content '${{ parameters.SubscriptionConfigurationFilePath }}' `
| ConvertFrom-Json -AsHashtable
. ./eng/common/TestResources/SubConfig-Helpers.ps1
UpdateSubscriptionConfiguration $configBase $config
displayName: Merge in Subscription Configuration File Path
${{ if parameters.EnvVars }}:
env: ${{ parameters.EnvVars }}
16 changes: 2 additions & 14 deletions eng/common/TestResources/deploy-test-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ parameters:
ServiceConnection: not-specified
ResourceType: test
UseFederatedAuth: false
SubscriptionConfigurationFilePath: ''


# SubscriptionConfiguration will be splatted into the parameters of the test
# resources script. It should be JSON in the form:
Expand Down Expand Up @@ -56,18 +54,9 @@ steps:
ScriptType: InlineScript
Inline: |
eng/common/scripts/Import-AzModules.ps1
if ('${{ parameters.SubscriptionConfigurationFilePath }}' -ne '') {
$subscriptionConfiguration = `
Get-Content '${{ parameters.SubscriptionConfigurationFilePath }}' `
| ConvertFrom-Json -AsHashtable;
} else {
# Multiline string termination ('@) needs to be at the beginning
# of the line
$subscriptionConfiguration = @'
${{ parameters.SubscriptionConfiguration }}
$subscriptionConfiguration = @'
${{ parameters.SubscriptionConfiguration }}
'@ | ConvertFrom-Json -AsHashtable;
}
# The subscriptionConfiguration may have ArmTemplateParameters defined, so
# pass those in via the ArmTemplateParameters flag, and handle any
Expand All @@ -86,7 +75,6 @@ steps:
- ${{ else }}:
- pwsh: |
eng/common/scripts/Import-AzModules.ps1
$subscriptionConfiguration = @'
${{ parameters.SubscriptionConfiguration }}
'@ | ConvertFrom-Json -AsHashtable;
Expand Down
2 changes: 2 additions & 0 deletions eng/common/TestResources/sub-config/AzurePublicMsft.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"SubscriptionId": "2cd617ea-1866-46b1-90e3-fffb087ebf9b",
"TenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47",
"TestApplicationId": "f850650c-1fcf-4489-b46f-71af2e30d360",
"TestApplicationSecret": "",
"TestApplicationOid": "30511c9d-ba1a-4c7b-b422-5b543da11b3f",
"ProvisionerApplicationId": "f850650c-1fcf-4489-b46f-71af2e30d360",
"ProvisionerApplicationSecret": "",
"ProvisionerApplicationOid": "30511c9d-ba1a-4c7b-b422-5b543da11b3f",
"Environment": "AzureCloud",
"AzureSubscription": "Azure SDK Test Resources"
Expand Down

0 comments on commit 5cda8d3

Please sign in to comment.