Skip to content

Organize cmdlet spec via module name #15380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/CosmosDB/CosmosDB/Az.CosmosDB.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ CmdletsToExport = 'Get-AzCosmosDBSqlContainer',
'Remove-AzCosmosDBSqlRoleAssignment',
'Update-AzCosmosDBSqlRoleDefinition',
'Update-AzCosmosDBSqlRoleAssignment', 'New-AzCosmosDBPermission',
'Remove-AzCosmosDBSqlRoleAssignment',
'New-AzCosmosDBDatabaseToRestore',
'Restore-AzCosmosDBAccount',
'Get-AzCosmosDBRestorableDatabaseAccount',
Expand Down
26 changes: 19 additions & 7 deletions tools/CreateMappings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,25 @@ $results = @{};
$warnings = @();

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


$k = 0;
$cmdlets | ForEach-Object {
$cmdletPath = Split-Path $_.FullName -Parent;
$module = $null;
if($cmdletPath -cmatch $RootPathRegex) {
$module = $Matches.1
}
$cmdlet = $_.BaseName;

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

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

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

if($matchedRule -ne $null) {
$results[$cmdlet] = $matchedRule.Alias;
}

$matchedModuleRule = @($rules | Where-Object { $_.Module -ne $null -and $module -eq $_.Module })[0];
if($matchedModuleRule -ne $null) {
$results[$cmdlet] = $matchedModuleRule.Alias;
}

# Take note of unmatched cmdlets and write to outputs.
if($matchedRule -eq $null) {
if($matchedRule -eq $null -and $matchedModuleRule -eq $null) {
$warnings += $cmdlet;
$results[$cmdlet] = "Other";
} else {
$results[$cmdlet] = $matchedRule.Alias;
}
};

Expand Down
22 changes: 11 additions & 11 deletions tools/CreateMappings_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
"alias": "Traffic Manager"
},
{
"regex": "MarketplaceTerms",
"module": "MarketplaceOrdering",
"alias": "Marketplace Ordering"
},
{
Expand Down Expand Up @@ -534,15 +534,11 @@
"alias": "Database for PostgreSQL"
},
{
"regex": "SqlVM",
"alias": "SqlVM"
"module": "SqlVirtualMachine",
"alias": "Sql VM"
},
{
"regex": "AvailabilityGroupListener",
"alias": "SqlVM"
},
{
"regex": "Sql",
"module": "Sql",
"alias": "SQL"
},
{
Expand Down Expand Up @@ -574,7 +570,7 @@
"alias": "Custom Resource Providers"
},
{
"regex": "MonitorLogAnalytics",
"module": "MonitoringSolutions",
"alias": "Monitoring Solutions"
},
{
Expand Down Expand Up @@ -667,15 +663,19 @@
},
{
"alias": "Security Insights",
"regex": "SecurityInsights"
"module": "SecurityInsights"
},
{
"alias": "Private DNS",
"module": "PrivateDns"
},
{
"regex": "ContainerInstance",
"alias": "ContainerInstance"
},
{
"alias": "DiskPool",
"regex": "DiskPool"
"module": "DiskPool"
},
{
"alias": "Datadog",
Expand Down