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/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..8a5e6ff165 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 |', @@ -1417,15 +1420,26 @@ 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 | 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 = @( - "# $moduleName ``[$formattedResourceType]``", + "# $moduleName ``[$inTemplateResourceType]``", '', $moduleDescription, '' @@ -1438,7 +1452,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 +1571,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 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 }