Skip to content

Commit f7cfa3a

Browse files
Organize cmdlet spec via module name (#15380)
Co-authored-by: Yunchi Wang <[email protected]>
1 parent ad7f4ec commit f7cfa3a

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

src/CosmosDB/CosmosDB/Az.CosmosDB.psd1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ CmdletsToExport = 'Get-AzCosmosDBSqlContainer',
164164
'Remove-AzCosmosDBSqlRoleAssignment',
165165
'Update-AzCosmosDBSqlRoleDefinition',
166166
'Update-AzCosmosDBSqlRoleAssignment', 'New-AzCosmosDBPermission',
167-
'Remove-AzCosmosDBSqlRoleAssignment',
168167
'New-AzCosmosDBDatabaseToRestore',
169168
'Restore-AzCosmosDBAccount',
170169
'Get-AzCosmosDBRestorableDatabaseAccount',

tools/CreateMappings.ps1

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,25 @@ $results = @{};
1616
$warnings = @();
1717

1818
.($PSScriptRoot + "\PreloadToolDll.ps1")
19+
$RootPath = Resolve-Path $RootPath
20+
$RootPathRegex = [regex]::escape($RootPath) + "\\(\w*)(\\)(.*)"
1921
# Find all cmdlet names by help file names in the repository.
2022
$cmdlets = Get-ChildItem $RootPath -Recurse | Where-Object { $_.FullName -cmatch ".*\\help\\.*-.*.md" -and (-not [Tools.Common.Utilities.ModuleFilter]::IsAzureStackModule($_.FullName)) };
2123

22-
23-
$k = 0;
2424
$cmdlets | ForEach-Object {
2525
$cmdletPath = Split-Path $_.FullName -Parent;
26+
$module = $null;
27+
if($cmdletPath -cmatch $RootPathRegex) {
28+
$module = $Matches.1
29+
}
2630
$cmdlet = $_.BaseName;
2731

32+
$matchedRule = $null;
2833
# First, match to module path.
29-
$matchedRule = @($rules | Where-Object { $cmdletPath -cmatch ".*$($_.Regex).*" })[0];
34+
$matchedRule = @($rules | Where-Object { $_.Regex -ne $null -and $cmdletPath -cmatch ".*$($_.Regex).*" })[0];
3035

3136
# Try to match this cmdlet with at least one rule.
32-
$possibleBetterMatch = @($rules | Where-Object { $cmdlet -cmatch ".*$($_.Regex).*" })[0];
37+
$possibleBetterMatch = @($rules | Where-Object { $_.Regex -ne $null -and $cmdlet -cmatch ".*$($_.Regex).*" })[0];
3338

3439
# Look for the best match.
3540
if(
@@ -41,12 +46,19 @@ $cmdlets | ForEach-Object {
4146
$matchedRule = $possibleBetterMatch;
4247
}
4348

49+
if($matchedRule -ne $null) {
50+
$results[$cmdlet] = $matchedRule.Alias;
51+
}
52+
53+
$matchedModuleRule = @($rules | Where-Object { $_.Module -ne $null -and $module -eq $_.Module })[0];
54+
if($matchedModuleRule -ne $null) {
55+
$results[$cmdlet] = $matchedModuleRule.Alias;
56+
}
57+
4458
# Take note of unmatched cmdlets and write to outputs.
45-
if($matchedRule -eq $null) {
59+
if($matchedRule -eq $null -and $matchedModuleRule -eq $null) {
4660
$warnings += $cmdlet;
4761
$results[$cmdlet] = "Other";
48-
} else {
49-
$results[$cmdlet] = $matchedRule.Alias;
5062
}
5163
};
5264

tools/CreateMappings_rules.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
"alias": "Traffic Manager"
313313
},
314314
{
315-
"regex": "MarketplaceTerms",
315+
"module": "MarketplaceOrdering",
316316
"alias": "Marketplace Ordering"
317317
},
318318
{
@@ -534,15 +534,11 @@
534534
"alias": "Database for PostgreSQL"
535535
},
536536
{
537-
"regex": "SqlVM",
538-
"alias": "SqlVM"
537+
"module": "SqlVirtualMachine",
538+
"alias": "Sql VM"
539539
},
540540
{
541-
"regex": "AvailabilityGroupListener",
542-
"alias": "SqlVM"
543-
},
544-
{
545-
"regex": "Sql",
541+
"module": "Sql",
546542
"alias": "SQL"
547543
},
548544
{
@@ -574,7 +570,7 @@
574570
"alias": "Custom Resource Providers"
575571
},
576572
{
577-
"regex": "MonitorLogAnalytics",
573+
"module": "MonitoringSolutions",
578574
"alias": "Monitoring Solutions"
579575
},
580576
{
@@ -667,15 +663,19 @@
667663
},
668664
{
669665
"alias": "Security Insights",
670-
"regex": "SecurityInsights"
666+
"module": "SecurityInsights"
667+
},
668+
{
669+
"alias": "Private DNS",
670+
"module": "PrivateDns"
671671
},
672672
{
673673
"regex": "ContainerInstance",
674674
"alias": "ContainerInstance"
675675
},
676676
{
677677
"alias": "DiskPool",
678-
"regex": "DiskPool"
678+
"module": "DiskPool"
679679
},
680680
{
681681
"alias": "Datadog",

0 commit comments

Comments
 (0)