File tree Expand file tree Collapse file tree
eng/common/scripts/Helpers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -297,7 +297,8 @@ function Remove-WormStorageAccounts() {
297297 [CmdletBinding (SupportsShouldProcess = $True )]
298298 param (
299299 [string ]$GroupPrefix ,
300- [switch ]$CI
300+ [switch ]$CI ,
301+ [bool ]$CheckPrefix = $true
301302 )
302303
303304 $ErrorActionPreference = ' Stop'
@@ -306,10 +307,16 @@ function Remove-WormStorageAccounts() {
306307 # DO NOT REMOVE THIS
307308 # We call this script from live test pipelines as well, and a string mismatch/error could blow away
308309 # some static storage accounts we rely on
309- if (! $groupPrefix -or ($CI -and (! $GroupPrefix.StartsWith (' rg-' ) -and ! $GroupPrefix.StartsWith (' SSS3PT_rg-' )))) {
310- throw " The -GroupPrefix parameter must not be empty, or must start with 'rg-' or 'SSS3PT_rg-' in CI contexts"
310+ # Note: Prefix check can be disabled via `-CheckPrefix:$false` for scenarios where the resource group prefix isn't standardized.
311+ if (! $GroupPrefix ) {
312+ throw " The -GroupPrefix parameter must not be empty"
311313 }
312314
315+ if ($CheckPrefix -and $CI -and (! $GroupPrefix.StartsWith (' rg-' ) -and ! $GroupPrefix.StartsWith (' SSS3PT_rg-' ))) {
316+ throw " In CI contexts with -CheckPrefix enabled, -GroupPrefix must start with 'rg-' or 'SSS3PT_rg-'"
317+ }
318+
319+
313320 $groups = Get-AzResourceGroup | Where-Object { $_.ResourceGroupName.StartsWith ($GroupPrefix ) } | Where-Object { $_.ProvisioningState -ne ' Deleting' }
314321
315322 foreach ($group in $groups ) {
You can’t perform that action at this time.
0 commit comments