From 60dbbdca338a4195a53c6e680f264680559fa431 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Wed, 13 Sep 2023 18:56:04 +0200 Subject: [PATCH 1/6] Update to latest --- utilities/tools/helper/Get-PipelineFileName.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/tools/helper/Get-PipelineFileName.ps1 b/utilities/tools/helper/Get-PipelineFileName.ps1 index 0b1aa3e3a0..032a14d5d9 100644 --- a/utilities/tools/helper/Get-PipelineFileName.ps1 +++ b/utilities/tools/helper/Get-PipelineFileName.ps1 @@ -32,7 +32,7 @@ function Get-PipelineFileName { $provider, $parentType, $childTypeString = $ResourceIdentifier -split '[\/|\\]', 3 $parentResourceIdentifier = $provider, $parentType -join '/' $formattedParentResourceType = Get-SpecsAlignedResourceName -ResourceIdentifier $parentResourceIdentifier - $pipelineFileName = '{0}.yml' -f $formattedParentResourceType.Replace('Microsoft.', 'ms.').Replace('/', '.').ToLower() + $pipelineFileName = '{0}.yml' -f (($formattedParentResourceType -replace 'Microsoft\.', 'ms.') -replace '\/', '.').ToLower() return $pipelineFileName } From fb5c18f7a198ebb2c2154657c5776d930cdd6194 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Wed, 13 Sep 2023 19:08:01 +0200 Subject: [PATCH 2/6] Added casing to provider namespace --- utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 index 7cfab64e1d..112abef63b 100644 --- a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 +++ b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 @@ -117,6 +117,9 @@ function Get-SpecsAlignedResourceName { } } + # Format provider namespace as some are inconsistely formatted + $providerNamespace = (Get-Culture -Name 'en-US').TextInfo.ToTitleCase($providerNamespace) + # Build result return "$providerNamespace/$resourceType" } From 721ad77c1cd504f72998d9e98f79864c7553a887 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Wed, 13 Sep 2023 22:33:50 +0200 Subject: [PATCH 3/6] Undid incorrect fix --- utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 | 3 --- 1 file changed, 3 deletions(-) diff --git a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 index 112abef63b..7cfab64e1d 100644 --- a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 +++ b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 @@ -117,9 +117,6 @@ function Get-SpecsAlignedResourceName { } } - # Format provider namespace as some are inconsistely formatted - $providerNamespace = (Get-Culture -Name 'en-US').TextInfo.ToTitleCase($providerNamespace) - # Build result return "$providerNamespace/$resourceType" } From a129671950d7be906c6eef93015bbf9f4840ae30 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Wed, 13 Sep 2023 23:00:22 +0200 Subject: [PATCH 4/6] Alternative proposal --- modules/insights/private-link-scope/README.md | 2 +- utilities/tools/Set-ModuleReadMe.ps1 | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/insights/private-link-scope/README.md b/modules/insights/private-link-scope/README.md index 66beb33f99..9104b7f967 100644 --- a/modules/insights/private-link-scope/README.md +++ b/modules/insights/private-link-scope/README.md @@ -1,4 +1,4 @@ -# Azure Monitor Private Link Scopes `[Microsoft.Insights/privateLinkScopes]` +# Azure Monitor Private Link Scopes `[microsoft.insights/privateLinkScopes]` This module deploys an Azure Monitor Private Link Scope. diff --git a/utilities/tools/Set-ModuleReadMe.ps1 b/utilities/tools/Set-ModuleReadMe.ps1 index fd32b00ae5..41505fac5d 100644 --- a/utilities/tools/Set-ModuleReadMe.ps1 +++ b/utilities/tools/Set-ModuleReadMe.ps1 @@ -1417,15 +1417,21 @@ function Initialize-ReadMe { ) . (Join-Path $PSScriptRoot 'helper' 'Get-SpecsAlignedResourceName.ps1') + . (Join-Path (Split-Path $PSScriptRoot -Parent) 'pipelines' 'sharedScripts' 'Get-NestedResourceList.ps1') + $moduleName = $TemplateFileContent.metadata.name $moduleDescription = $TemplateFileContent.metadata.description $formattedResourceType = Get-SpecsAlignedResourceName -ResourceIdentifier $FullModuleIdentifier + $inTemplateResourceType = (Get-NestedResourceList $TemplateFileContent).type | Where-Object { + $_ -match "^$formattedResourceType$" + } + if (-not (Test-Path $ReadMeFilePath) -or ([String]::IsNullOrEmpty((Get-Content $ReadMeFilePath -Raw)))) { $initialContent = @( - "# $moduleName ``[$formattedResourceType]``", + "# $moduleName ``[$inTemplateResourceType]``", '', $moduleDescription, '' @@ -1438,7 +1444,7 @@ function Initialize-ReadMe { $readMeFileContent = $initialContent } else { $readMeFileContent = Get-Content -Path $ReadMeFilePath -Encoding 'utf8' - $readMeFileContent[0] = "# $moduleName ``[$formattedResourceType]``" + $readMeFileContent[0] = "# $moduleName ``[$inTemplateResourceType]``" # We want to inject the description right below the header and before the [Resource Types] section @@ -1557,7 +1563,6 @@ function Set-ModuleReadMe { # Load external functions . (Join-Path $PSScriptRoot 'helper' 'Merge-FileWithNewContent.ps1') - . (Join-Path (Split-Path $PSScriptRoot -Parent) 'pipelines' 'sharedScripts' 'Get-NestedResourceList.ps1') # Check template & make full path $TemplateFilePath = Resolve-Path -Path $TemplateFilePath -ErrorAction Stop From 4ec5dcb11abd5c081d62ee96bccffd907c435098 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Wed, 13 Sep 2023 23:02:07 +0200 Subject: [PATCH 5/6] Added missing ref --- utilities/tools/Set-ModuleReadMe.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utilities/tools/Set-ModuleReadMe.ps1 b/utilities/tools/Set-ModuleReadMe.ps1 index 41505fac5d..192173e528 100644 --- a/utilities/tools/Set-ModuleReadMe.ps1 +++ b/utilities/tools/Set-ModuleReadMe.ps1 @@ -44,6 +44,9 @@ function Set-ResourceTypesSection { [string[]] $ResourceTypesToExclude = @('Microsoft.Resources/deployments') ) + # Loading used functions + . (Join-Path (Split-Path $PSScriptRoot -Parent) 'pipelines' 'sharedScripts' 'Get-NestedResourceList.ps1') + # Process content $SectionContent = [System.Collections.ArrayList]@( '| Resource Type | API Version |', From 23a008c896769dc6a9f2a5ce660caa8d86074cb9 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Wed, 13 Sep 2023 23:53:46 +0200 Subject: [PATCH 6/6] Updated all readmes --- modules/cache/redis/README.md | 2 +- utilities/tools/Set-ModuleReadMe.ps1 | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/cache/redis/README.md b/modules/cache/redis/README.md index 713fbd99f7..485905aa10 100644 --- a/modules/cache/redis/README.md +++ b/modules/cache/redis/README.md @@ -1,4 +1,4 @@ -# Redis Cache `[Microsoft.Cache/Redis]` +# Redis Cache `[Microsoft.Cache/redis]` This module deploys a Redis Cache. diff --git a/utilities/tools/Set-ModuleReadMe.ps1 b/utilities/tools/Set-ModuleReadMe.ps1 index 192173e528..8a5e6ff165 100644 --- a/utilities/tools/Set-ModuleReadMe.ps1 +++ b/utilities/tools/Set-ModuleReadMe.ps1 @@ -1427,10 +1427,15 @@ function Initialize-ReadMe { $moduleDescription = $TemplateFileContent.metadata.description $formattedResourceType = Get-SpecsAlignedResourceName -ResourceIdentifier $FullModuleIdentifier - $inTemplateResourceType = (Get-NestedResourceList $TemplateFileContent).type | Where-Object { + $inTemplateResourceType = (Get-NestedResourceList $TemplateFileContent).type | Select-Object -Unique | Where-Object { $_ -match "^$formattedResourceType$" } + if (-not $inTemplateResourceType) { + Write-Warning "No resource type like [$formattedResourceType] found in template. Falling back to it as identifier." + $inTemplateResourceType = $formattedResourceType + } + if (-not (Test-Path $ReadMeFilePath) -or ([String]::IsNullOrEmpty((Get-Content $ReadMeFilePath -Raw)))) { $initialContent = @(