Skip to content

Commit 4f5da66

Browse files
committed
Cleaning up powershell names
1 parent 875f10f commit 4f5da66

4 files changed

Lines changed: 26 additions & 17 deletions

File tree

tests/integration/all-resource-types/Deploy-SourceApim.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ $apiopsLogLevel = Get-ApiopsLogLevelLocal -ScriptLogLevel $LogLevel
7272
# Destroy path
7373
# ---------------------------------------------------------------------------
7474
if ($Destroy) {
75-
Write-Host "🗑️ Deleting resource group '$(Protect-Identifier -Value $ResourceGroupName)'..." -ForegroundColor Yellow
75+
Write-Host "🗑️ Deleting resource group '$(Protect-ResourceGroupName -Value $ResourceGroupName)'..." -ForegroundColor Yellow
7676
az group delete --name $ResourceGroupName --yes --no-wait
7777
Write-Host "✅ Deletion initiated (async). Resource group will be removed shortly." -ForegroundColor Green
7878
exit 0
@@ -141,7 +141,7 @@ if (-not $allRegistered) {
141141
Write-Host " ✅ Resource providers ready" -ForegroundColor Green
142142

143143
# Create resource group if needed
144-
Write-Host "📦 Ensuring resource group '$(Protect-Identifier -Value $ResourceGroupName)' exists in '$Location'..." -ForegroundColor Cyan
144+
Write-Host "📦 Ensuring resource group '$(Protect-ResourceGroupName -Value $ResourceGroupName)' exists in '$Location'..." -ForegroundColor Cyan
145145
az group create --name $ResourceGroupName --location $Location --output none
146146

147147
# Deploy Bicep template
@@ -161,7 +161,7 @@ switch ($LogLevel) {
161161

162162
$azReplacements = @{
163163
$subscriptionId = Protect-SubscriptionId -Value $subscriptionId
164-
$ResourceGroupName = Protect-Identifier -Value $ResourceGroupName
164+
$ResourceGroupName = Protect-ResourceGroupName -Value $ResourceGroupName
165165
}
166166

167167
$raw = Invoke-MaskedAzCommand -Replacements $azReplacements -Command {
@@ -192,7 +192,7 @@ Write-Host "APIOps CLI extract command:" -ForegroundColor Cyan
192192
Write-Host ""
193193
Write-Host " npx apiops extract \"
194194
Write-Host " --subscription-id $(Protect-SubscriptionId -Value $outputs.subscriptionId.value) \"
195-
Write-Host " --resource-group $(Protect-Identifier -Value $outputs.resourceGroupName.value) \"
195+
Write-Host " --resource-group $(Protect-ResourceGroupName -Value $outputs.resourceGroupName.value) \"
196196
Write-Host " --service-name $($outputs.apimServiceName.value) \"
197197
Write-Host " --output-dir ./extracted \"
198198
Write-Host " --log-level $apiopsLogLevel"

tests/integration/all-resource-types/Deploy-TargetApim.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ $subscriptionId = $account.id
5656

5757
Write-Host "Starting target APIM deployment..."
5858
Write-Host "Subscription: $($account.name) ($(Protect-SubscriptionId -Value $subscriptionId))"
59-
Write-Host "Resource Group: $(Protect-Identifier -Value $ResourceGroupName)"
59+
Write-Host "Resource Group: $(Protect-ResourceGroupName -Value $ResourceGroupName)"
6060
Write-Host "SKU: $SkuName"
6161
Write-Host "Location: $Location"
6262
Write-Host "Log Level: $LogLevel"
@@ -76,7 +76,7 @@ switch ($LogLevel) {
7676

7777
$azReplacements = @{
7878
$subscriptionId = Protect-SubscriptionId -Value $subscriptionId
79-
$ResourceGroupName = Protect-Identifier -Value $ResourceGroupName
79+
$ResourceGroupName = Protect-ResourceGroupName -Value $ResourceGroupName
8080
}
8181

8282
$raw = Invoke-MaskedAzCommand -Replacements $azReplacements -Command {

tests/integration/all-resource-types/MaskingHelpers.psm1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,15 @@ function Protect-Identifier {
3333

3434
function Protect-SubscriptionId {
3535
param([string]$Value)
36-
return Protect-Identifier -Value $Value -Prefix 8 -Suffix 4
36+
return Protect-Identifier -Value $Value -Prefix 3 -Suffix 0
37+
}
38+
39+
# Resource group names follow the convention `bvt-<timestamp>-<rand>-(src|tgt)-rg`.
40+
# Reveal the last 7 characters so the role suffix (`-src-rg` / `-tgt-rg`) is
41+
# visible in logs while the unique id stays masked.
42+
function Protect-ResourceGroupName {
43+
param([string]$Value)
44+
return Protect-Identifier -Value $Value -Prefix 3 -Suffix 7
3745
}
3846

3947
function Protect-LogLine {
@@ -100,6 +108,7 @@ function Invoke-MaskedAzCommand {
100108
Export-ModuleMember -Function `
101109
Protect-Identifier, `
102110
Protect-SubscriptionId, `
111+
Protect-ResourceGroupName, `
103112
Protect-LogLine, `
104113
Invoke-MaskedApiopsCommand, `
105114
Invoke-MaskedAzCommand

tests/integration/all-resource-types/run-roundtrip-test.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ if (-not $TargetResourceGroup) {
9999
$TargetResourceGroup = "bvt-$UniqueId-tgt-rg"
100100
}
101101

102-
Write-Host " Source RG: $(Protect-Identifier -Value $SourceResourceGroup)"
103-
Write-Host " Target RG: $(Protect-Identifier -Value $TargetResourceGroup)"
102+
Write-Host " Source RG: $(Protect-ResourceGroupName -Value $SourceResourceGroup)"
103+
Write-Host " Target RG: $(Protect-ResourceGroupName -Value $TargetResourceGroup)"
104104

105105
# ---------------------------------------------------------------------------
106106
# Helpers
@@ -159,9 +159,9 @@ function Invoke-Teardown {
159159
}
160160
}
161161

162-
Write-Host " Deleting $(Protect-Identifier -Value $SourceResourceGroup)..."
162+
Write-Host " Deleting $(Protect-ResourceGroupName -Value $SourceResourceGroup)..."
163163
az group delete --name $SourceResourceGroup --yes --no-wait 2>$null
164-
Write-Host " Deleting $(Protect-Identifier -Value $TargetResourceGroup)..."
164+
Write-Host " Deleting $(Protect-ResourceGroupName -Value $TargetResourceGroup)..."
165165
az group delete --name $TargetResourceGroup --yes --no-wait 2>$null
166166

167167
if ($HardDelete) {
@@ -432,7 +432,7 @@ try {
432432
# Query APIM instance from resource group
433433
$apimName = az apim list --resource-group $SourceResourceGroup --query "[0].name" -o tsv 2>$null
434434
if (-not $apimName) {
435-
Write-Host "❌ No APIM instance found in resource group $(Protect-Identifier -Value $SourceResourceGroup)"
435+
Write-Host "❌ No APIM instance found in resource group $(Protect-ResourceGroupName -Value $SourceResourceGroup)"
436436
exit 2
437437
}
438438
$apimName
@@ -445,7 +445,7 @@ try {
445445
# Query APIM instance from resource group
446446
$apimName = az apim list --resource-group $TargetResourceGroup --query "[0].name" -o tsv 2>$null
447447
if (-not $apimName) {
448-
Write-Host "❌ No APIM instance found in resource group $(Protect-Identifier -Value $TargetResourceGroup)"
448+
Write-Host "❌ No APIM instance found in resource group $(Protect-ResourceGroupName -Value $TargetResourceGroup)"
449449
exit 2
450450
}
451451
$apimName
@@ -463,14 +463,14 @@ try {
463463
Write-Host " Cleaned previous extract output"
464464
}
465465

466-
Write-Host " Source: $sourceName (sub: $(Protect-SubscriptionId -Value $sourceSubId), rg: $(Protect-Identifier -Value $sourceRg))"
466+
Write-Host " Source: $sourceName (sub: $(Protect-SubscriptionId -Value $sourceSubId), rg: $(Protect-ResourceGroupName -Value $sourceRg))"
467467
Write-Host " Output: $ExtractOutputDir"
468468

469469
$apiopsLogLevel = Get-ApiopsLogLevel -ScriptLogLevel $LogLevel
470470

471471
$extractExitCode = Invoke-MaskedApiopsCommand -Replacements @{
472472
$sourceSubId = Protect-SubscriptionId -Value $sourceSubId
473-
$sourceRg = Protect-Identifier -Value $sourceRg
473+
$sourceRg = Protect-ResourceGroupName -Value $sourceRg
474474
} -Command {
475475
npx apiops extract `
476476
--subscription-id $sourceSubId `
@@ -600,12 +600,12 @@ loggers:
600600
Write-Phase "📤" "PHASE 3 — Publish to target APIM"
601601
$publishTimer = [System.Diagnostics.Stopwatch]::StartNew()
602602

603-
Write-Host " Target: $targetName (sub: $(Protect-SubscriptionId -Value $targetSubId), rg: $(Protect-Identifier -Value $targetRg))"
603+
Write-Host " Target: $targetName (sub: $(Protect-SubscriptionId -Value $targetSubId), rg: $(Protect-ResourceGroupName -Value $targetRg))"
604604
Write-Host " Input: $ExtractOutputDir"
605605

606606
$publishExitCode = Invoke-MaskedApiopsCommand -Replacements @{
607607
$targetSubId = Protect-SubscriptionId -Value $targetSubId
608-
$targetRg = Protect-Identifier -Value $targetRg
608+
$targetRg = Protect-ResourceGroupName -Value $targetRg
609609
} -Command {
610610
npx apiops publish `
611611
--subscription-id $targetSubId `

0 commit comments

Comments
 (0)