Private/Get-AvmModuleLink.ps1
|
function Get-AvmModuleLink { <# .SYNOPSIS Computes deep links to a module's source/registry page and changelog/releases for a given target version, used to make the generated report clickable for reviewers. .DESCRIPTION - Bicep: links to the module's folder in Azure/bicep-registry-modules at the release tag for TargetVersion (tag format 'avm/<category>/<group>/<module>/<version>', as confirmed against the repo's actual tags) and to its CHANGELOG.md at that same ref. - Terraform: links to the module's page on registry.terraform.io at TargetVersion and to the GitHub releases page of its source repository. .PARAMETER Reference A reference/candidate object with ecosystem, category, group, module properties (as produced by Get-AvmModuleReference). .PARAMETER TargetVersion The concrete semver version to link to (not a Terraform constraint string). .OUTPUTS PSCustomObject with: primaryLabel, primaryUrl, secondaryLabel, secondaryUrl. $null if the ecosystem is not recognized or required fields are missing. .EXAMPLE Get-AvmModuleLink -Reference $candidate.reference -TargetVersion $candidate.resolvedVersion #> [CmdletBinding()] [OutputType([PSCustomObject])] param( [Parameter(Mandatory)] [PSCustomObject]$Reference, [Parameter(Mandatory)] [string]$TargetVersion ) if (-not $Reference -or -not $TargetVersion) { return $null } if ($Reference.ecosystem -eq 'bicep') { if (-not $Reference.category -or -not $Reference.group -or -not $Reference.module) { return $null } $tag = "avm/$($Reference.category)/$($Reference.group)/$($Reference.module)/$TargetVersion" $modPath = "avm/$($Reference.category)/$($Reference.group)/$($Reference.module)" return [PSCustomObject]@{ primaryLabel = 'Module' primaryUrl = "https://github.com/Azure/bicep-registry-modules/tree/$tag/$modPath" secondaryLabel = 'CHANGELOG' secondaryUrl = "https://github.com/Azure/bicep-registry-modules/blob/$tag/$modPath/CHANGELOG.md" } } if ($Reference.ecosystem -eq 'terraform') { if (-not $Reference.module) { return $null } $repoName = $Reference.module -replace '^avm-', 'terraform-azurerm-avm-' return [PSCustomObject]@{ primaryLabel = 'Registry' primaryUrl = "https://registry.terraform.io/modules/Azure/$($Reference.module)/azurerm/$TargetVersion" secondaryLabel = 'Releases' secondaryUrl = "https://github.com/Azure/$repoName/releases" } } return $null } |