From 4b38598077f1327eebaf378ddb7549dfc7a688f0 Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Tue, 21 May 2024 14:31:35 -0700 Subject: [PATCH 1/7] Add static file secret-less sub-config support --- eng/common/TestResources/New-TestResources.ps1 | 2 +- eng/common/TestResources/New-TestResources.ps1.md | 6 +++--- eng/common/TestResources/Remove-TestResources.ps1 | 4 ++-- eng/common/TestResources/Remove-TestResources.ps1.md | 8 ++++---- eng/common/TestResources/deploy-test-resources.yml | 7 +++++++ eng/common/TestResources/remove-test-resources.yml | 7 +++++++ 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index ea2987f115e4..64e075c57049 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -52,7 +52,7 @@ param ( [ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')] [string] $ProvisionerApplicationOid, - [Parameter(ParameterSetName = 'Provisioner', Mandatory = $true)] + [Parameter(ParameterSetName = 'Provisioner')] [string] $ProvisionerApplicationSecret, [Parameter()] diff --git a/eng/common/TestResources/New-TestResources.ps1.md b/eng/common/TestResources/New-TestResources.ps1.md index 55f791ea1a6e..b0811e1e687e 100644 --- a/eng/common/TestResources/New-TestResources.ps1.md +++ b/eng/common/TestResources/New-TestResources.ps1.md @@ -29,7 +29,7 @@ New-TestResources.ps1 [-BaseName ] [-ResourceGroupName ] [-Servi [-TestResourcesDirectory ] [-TestApplicationId ] [-TestApplicationSecret ] [-TestApplicationOid ] -TenantId [-SubscriptionId ] -ProvisionerApplicationId [-ProvisionerApplicationOid ] - -ProvisionerApplicationSecret [-DeleteAfterHours ] [-Location ] + [-ProvisionerApplicationSecret ] [-DeleteAfterHours ] [-Location ] [-Environment ] [-ResourceType ] [-ArmTemplateParameters ] [-AdditionalParameters ] [-EnvironmentVariables ] [-CI] [-Force] [-OutFile] [-SuppressVsoCommands] [-ServicePrincipalAuth] [-NewTestResourcesRemainingArguments ] @@ -426,7 +426,7 @@ Type: String Parameter Sets: Provisioner Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -712,7 +712,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/eng/common/TestResources/Remove-TestResources.ps1 b/eng/common/TestResources/Remove-TestResources.ps1 index 4d28acc7d099..490b41b8ebe9 100644 --- a/eng/common/TestResources/Remove-TestResources.ps1 +++ b/eng/common/TestResources/Remove-TestResources.ps1 @@ -34,8 +34,8 @@ param ( [ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')] [string] $ProvisionerApplicationId, - [Parameter(ParameterSetName = 'Default+Provisioner', Mandatory = $true)] - [Parameter(ParameterSetName = 'ResourceGroup+Provisioner', Mandatory = $true)] + [Parameter(ParameterSetName = 'Default+Provisioner')] + [Parameter(ParameterSetName = 'ResourceGroup+Provisioner')] [string] $ProvisionerApplicationSecret, [Parameter(ParameterSetName = 'Default', Position = 0)] diff --git a/eng/common/TestResources/Remove-TestResources.ps1.md b/eng/common/TestResources/Remove-TestResources.ps1.md index 15ac14ea87e9..d89de83b7851 100644 --- a/eng/common/TestResources/Remove-TestResources.ps1.md +++ b/eng/common/TestResources/Remove-TestResources.ps1.md @@ -23,7 +23,7 @@ Remove-TestResources.ps1 [-BaseName ] [-SubscriptionId ] [[-Serv ### Default+Provisioner ``` Remove-TestResources.ps1 -BaseName -TenantId [-SubscriptionId ] - -ProvisionerApplicationId -ProvisionerApplicationSecret [[-ServiceDirectory] ] + -ProvisionerApplicationId [-ProvisionerApplicationSecret ] [[-ServiceDirectory] ] [-Environment ] [-ResourceType ] [-ServicePrincipalAuth] [-Force] [-RemoveTestResourcesRemainingArguments ] [-ProgressAction ] [-WhatIf] [-Confirm] [] @@ -32,7 +32,7 @@ Remove-TestResources.ps1 -BaseName -TenantId [-SubscriptionId ### ResourceGroup+Provisioner ``` Remove-TestResources.ps1 [-ResourceGroupName ] -TenantId [-SubscriptionId ] - -ProvisionerApplicationId -ProvisionerApplicationSecret [[-ServiceDirectory] ] + -ProvisionerApplicationId [-ProvisionerApplicationSecret ] [[-ServiceDirectory] ] [-Environment ] [-CI] [-ResourceType ] [-ServicePrincipalAuth] [-Force] [-RemoveTestResourcesRemainingArguments ] [-ProgressAction ] [-WhatIf] [-Confirm] [] @@ -184,7 +184,7 @@ Type: String Parameter Sets: Default+Provisioner, ResourceGroup+Provisioner Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -347,7 +347,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/eng/common/TestResources/deploy-test-resources.yml b/eng/common/TestResources/deploy-test-resources.yml index 5b1b080979a2..23e68d94ecd7 100644 --- a/eng/common/TestResources/deploy-test-resources.yml +++ b/eng/common/TestResources/deploy-test-resources.yml @@ -7,6 +7,7 @@ parameters: ServiceConnection: not-specified ResourceType: test UseFederatedAuth: false + SubscriptionConfigurationFilePath: '' # SubscriptionConfiguration will be splatted into the parameters of the test @@ -58,6 +59,12 @@ steps: ${{ parameters.SubscriptionConfiguration }} '@ | ConvertFrom-Json -AsHashtable; + if ('${{ parameters.SubscriptionConfigurationFilePath }}' -ne '') { + $subscriptionConfiguration = ` + Get-Content '${{ parameters.SubscriptionConfigurationFilePath }}' ` + | ConvertFrom-Json -AsHashtable; + } + # The subscriptionConfiguration may have ArmTemplateParameters defined, so # pass those in via the ArmTemplateParameters flag, and handle any # additional parameters from the pipelines via AdditionalParameters diff --git a/eng/common/TestResources/remove-test-resources.yml b/eng/common/TestResources/remove-test-resources.yml index 121f6b3dda4d..9e4b39aa299d 100644 --- a/eng/common/TestResources/remove-test-resources.yml +++ b/eng/common/TestResources/remove-test-resources.yml @@ -7,6 +7,7 @@ parameters: ServiceConnection: not-specified ResourceType: test UseFederatedAuth: false + SubscriptionConfigurationFilePath: '' # SubscriptionConfiguration will be splat into the parameters of the test # resources script. It should be JSON in the form: @@ -40,6 +41,12 @@ steps: ${{ parameters.SubscriptionConfiguration }} "@ | ConvertFrom-Json -AsHashtable; + if ('${{ parameters.SubscriptionConfigurationFilePath }}' -ne '') { + $subscriptionConfiguration = ` + Get-Content '${{ parameters.SubscriptionConfigurationFilePath }}' ` + | ConvertFrom-Json -AsHashtable; + } + eng/common/TestResources/Remove-TestResources.ps1 ` @subscriptionConfiguration ` -ResourceType '${{ parameters.ResourceType }}' ` From a31ced56ba1c04d410cb8c00b995bd59201ef260 Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Wed, 22 May 2024 10:16:58 -0700 Subject: [PATCH 2/7] Review feedback: if/else --- eng/common/TestResources/deploy-test-resources.yml | 10 +++++++--- eng/common/TestResources/remove-test-resources.yml | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/eng/common/TestResources/deploy-test-resources.yml b/eng/common/TestResources/deploy-test-resources.yml index 23e68d94ecd7..1607a9067239 100644 --- a/eng/common/TestResources/deploy-test-resources.yml +++ b/eng/common/TestResources/deploy-test-resources.yml @@ -55,14 +55,18 @@ steps: Inline: | eng/common/scripts/Import-AzModules.ps1 - $subscriptionConfiguration = @' - ${{ parameters.SubscriptionConfiguration }} - '@ | ConvertFrom-Json -AsHashtable; + 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 }} + '@ | ConvertFrom-Json -AsHashtable; } # The subscriptionConfiguration may have ArmTemplateParameters defined, so diff --git a/eng/common/TestResources/remove-test-resources.yml b/eng/common/TestResources/remove-test-resources.yml index 9e4b39aa299d..89aa7d825e48 100644 --- a/eng/common/TestResources/remove-test-resources.yml +++ b/eng/common/TestResources/remove-test-resources.yml @@ -37,14 +37,18 @@ steps: Inline: | eng/common/scripts/Import-AzModules.ps1 - $subscriptionConfiguration = @" - ${{ parameters.SubscriptionConfiguration }} - "@ | ConvertFrom-Json -AsHashtable; 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 }} + "@ | ConvertFrom-Json -AsHashtable; + } eng/common/TestResources/Remove-TestResources.ps1 ` From 9856b1c9e2fddd293772024f30baca2e2b426449 Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Wed, 22 May 2024 10:37:47 -0700 Subject: [PATCH 3/7] http -> https --- eng/common/TestResources/New-TestResources.ps1.md | 2 +- eng/common/TestResources/Remove-TestResources.ps1.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/TestResources/New-TestResources.ps1.md b/eng/common/TestResources/New-TestResources.ps1.md index b0811e1e687e..f44feb1ab432 100644 --- a/eng/common/TestResources/New-TestResources.ps1.md +++ b/eng/common/TestResources/New-TestResources.ps1.md @@ -712,7 +712,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/eng/common/TestResources/Remove-TestResources.ps1.md b/eng/common/TestResources/Remove-TestResources.ps1.md index d89de83b7851..62b9e4f987b2 100644 --- a/eng/common/TestResources/Remove-TestResources.ps1.md +++ b/eng/common/TestResources/Remove-TestResources.ps1.md @@ -347,7 +347,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS From a0f6cd1e00110f5967d0ae46e15401a6311928e5 Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Wed, 22 May 2024 10:43:02 -0700 Subject: [PATCH 4/7] Update eng/common/TestResources/deploy-test-resources.yml --- eng/common/TestResources/deploy-test-resources.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/eng/common/TestResources/deploy-test-resources.yml b/eng/common/TestResources/deploy-test-resources.yml index 1607a9067239..04369b9876ab 100644 --- a/eng/common/TestResources/deploy-test-resources.yml +++ b/eng/common/TestResources/deploy-test-resources.yml @@ -56,7 +56,6 @@ steps: eng/common/scripts/Import-AzModules.ps1 - if ('${{ parameters.SubscriptionConfigurationFilePath }}' -ne '') { $subscriptionConfiguration = ` Get-Content '${{ parameters.SubscriptionConfigurationFilePath }}' ` From d90bd8d33638e0a7daf4c59c0dc94e578d343066 Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Wed, 22 May 2024 13:50:57 -0700 Subject: [PATCH 5/7] Space cleanup --- eng/common/TestResources/deploy-test-resources.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/eng/common/TestResources/deploy-test-resources.yml b/eng/common/TestResources/deploy-test-resources.yml index 04369b9876ab..b4197dc236d9 100644 --- a/eng/common/TestResources/deploy-test-resources.yml +++ b/eng/common/TestResources/deploy-test-resources.yml @@ -55,7 +55,6 @@ steps: Inline: | eng/common/scripts/Import-AzModules.ps1 - if ('${{ parameters.SubscriptionConfigurationFilePath }}' -ne '') { $subscriptionConfiguration = ` Get-Content '${{ parameters.SubscriptionConfigurationFilePath }}' ` From 5169abf25c1d3cdd82659cff9712ae80e5805d35 Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Tue, 28 May 2024 11:29:49 -0700 Subject: [PATCH 6/7] Add AzurePublicMsft.json --- .../TestResources/sub-config/AzurePublicMsft.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 eng/common/TestResources/sub-config/AzurePublicMsft.json diff --git a/eng/common/TestResources/sub-config/AzurePublicMsft.json b/eng/common/TestResources/sub-config/AzurePublicMsft.json new file mode 100644 index 000000000000..162d14da4e41 --- /dev/null +++ b/eng/common/TestResources/sub-config/AzurePublicMsft.json @@ -0,0 +1,11 @@ +{ + "SubscriptionId": "2cd617ea-1866-46b1-90e3-fffb087ebf9b", + "TenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "TestApplicationId": "f850650c-1fcf-4489-b46f-71af2e30d360", + "TestApplicationOid": "30511c9d-ba1a-4c7b-b422-5b543da11b3f", + "ProvisionerApplicationId": "f850650c-1fcf-4489-b46f-71af2e30d360", + "ProvisionerApplicationOid": "30511c9d-ba1a-4c7b-b422-5b543da11b3f", + "Environment": "AzureCloud", + "AzureSubscription": "Azure SDK Test Resources", + "EnvironmentVariables": {} +} \ No newline at end of file From d391cbf99c1f5726395e52e32bec9d9fcb98039d Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Tue, 28 May 2024 13:24:09 -0700 Subject: [PATCH 7/7] Remove EnvironmentVariables --- eng/common/TestResources/sub-config/AzurePublicMsft.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eng/common/TestResources/sub-config/AzurePublicMsft.json b/eng/common/TestResources/sub-config/AzurePublicMsft.json index 162d14da4e41..78d8a782c26f 100644 --- a/eng/common/TestResources/sub-config/AzurePublicMsft.json +++ b/eng/common/TestResources/sub-config/AzurePublicMsft.json @@ -6,6 +6,5 @@ "ProvisionerApplicationId": "f850650c-1fcf-4489-b46f-71af2e30d360", "ProvisionerApplicationOid": "30511c9d-ba1a-4c7b-b422-5b543da11b3f", "Environment": "AzureCloud", - "AzureSubscription": "Azure SDK Test Resources", - "EnvironmentVariables": {} + "AzureSubscription": "Azure SDK Test Resources" } \ No newline at end of file