Skip to content
New issue

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

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

Already on GitHub? # to your account

[Fixes] Implement fixes to correctly identify resource type & pipeline #3980

Merged
merged 6 commits into from
Sep 15, 2023
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
2 changes: 1 addition & 1 deletion modules/cache/redis/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Redis Cache `[Microsoft.Cache/Redis]`
# Redis Cache `[Microsoft.Cache/redis]`

This module deploys a Redis Cache.

Expand Down
2 changes: 1 addition & 1 deletion modules/insights/private-link-scope/README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
19 changes: 16 additions & 3 deletions utilities/tools/Set-ModuleReadMe.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 |',
Expand Down Expand Up @@ -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,
''
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion utilities/tools/helper/Get-PipelineFileName.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}