Skip to content

Commit 777741b

Browse files
azure-sdk-automation[bot]msalamanCopilot
authored
Sync eng/common directory with azure-sdk-tools for PR 16342 (#48074)
* make prefix check optional * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Marcos Salamanca <masalama@microsoft.com> Co-authored-by: msalaman <Marcossalamanca97@hotmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent ebe3b5e commit 777741b

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

eng/common/scripts/Helpers/Resource-Helpers.ps1

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff 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) {

0 commit comments

Comments
 (0)