From 3b46cc14fbb76d46fc6c75b1356ee5122753fc24 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 12:47:34 +0200 Subject: [PATCH 01/31] Simplified specs resource type identification --- .../Get-PrivateRegistryRepositoryName.ps1 | 22 +++++++-- .../resourcePublish/Get-TemplateSpecsName.ps1 | 10 +++- .../Get-UniversalArtifactsName.ps1 | 10 +++- .../helper/Get-SpecsAlignedResourceName.ps1 | 49 +++++-------------- 4 files changed, 49 insertions(+), 42 deletions(-) diff --git a/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 b/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 index 7b93cb8ca0..a419650413 100644 --- a/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 @@ -8,6 +8,11 @@ Convert the given template file path into a valid Container Registry repository .PARAMETER TemplateFilePath Mandatory. The template file path to convert +.PARAMETER UseApiAlignedName +Optional. If set to true, the returned name will be aligned with the Azure API naming. If not, the one aligned with the module's folder path. See the following examples: +- True: bicep/modules/microsoft.keyvault.vaults.secrets +- False: bicep/modules/key-vault.vault.secret + .EXAMPLE Get-PrivateRegistryRepositoryName -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' @@ -17,12 +22,23 @@ function Get-PrivateRegistryRepositoryName { [CmdletBinding()] param ( - [Parameter(Mandatory)] - [string] $TemplateFilePath + [Parameter(Mandatory = $true)] + [string] $TemplateFilePath, + + [Parameter(Mandatory = $false)] + [bool] $UseApiAlignedName = $false ) + # Load helper scripts + . (Join-Path (Get-Item -Path $PSScriptRoot).Parent.Parent 'tools' 'helper' 'Get-SpecsAlignedResourceName.ps1') + $moduleIdentifier = (Split-Path $TemplateFilePath -Parent).Replace('\', '/').Split('/modules/')[1] - $moduleRegistryIdentifier = 'bicep/modules/{0}' -f $moduleIdentifier.Replace('\', '/').Replace('/', '.').ToLower() + + if ($UseApiAlignedName) { + $moduleRegistryIdentifier = 'bicep/modules/{0}' -f $moduleIdentifier.Replace('\', '/').Replace('/', '.').ToLower() + } else { + $moduleRegistryIdentifier = 'bicep/modules/{0}' -f $moduleIdentifier.Replace('\', '/').Replace('/', '.').ToLower() + } return $moduleRegistryIdentifier } diff --git a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 index e69d30cd3e..26ee1ce050 100644 --- a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 @@ -8,6 +8,11 @@ Convert the given template file path into a valid Template Specs repository name .PARAMETER TemplateFilePath Mandatory. The template file path to convert +.PARAMETER UseApiAlignedName +Optional. If set to true, the returned name will be aligned with the Azure API naming. If not, the one aligned with the module's folder path. See the following examples: +- True: microsoft.keyvault.vaults.secrets +- False: key-vault.vault.secret + .EXAMPLE Get-TemplateSpecsName -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' @@ -18,7 +23,10 @@ function Get-TemplateSpecsName { [CmdletBinding()] param ( [Parameter(Mandatory)] - [string] $TemplateFilePath + [string] $TemplateFilePath, + + [Parameter(Mandatory = $false)] + [bool] $UseApiAlignedName = $false ) $moduleIdentifier = (Split-Path $TemplateFilePath -Parent).Replace('\', '/').Split('/modules/')[1] diff --git a/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 b/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 index 95dc5a6a31..211cd8b98d 100644 --- a/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 @@ -9,6 +9,11 @@ Must be lowercase alphanumerics, dashes, dots or underscores, under 256 characte .PARAMETER TemplateFilePath Mandatory. The template file path to convert +.PARAMETER UseApiAlignedName +Optional. If set to true, the returned name will be aligned with the Azure API naming. If not, the one aligned with the module's folder path. See the following examples: +- True: microsoft.keyvault.vaults.secrets +- False: key-vault.vault.secret + .EXAMPLE Get-UniversalArtifactsName -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' @@ -19,7 +24,10 @@ function Get-UniversalArtifactsName { [CmdletBinding()] param ( [Parameter(Mandatory)] - [string] $TemplateFilePath + [string] $TemplateFilePath, + + [Parameter(Mandatory = $false)] + [bool] $UseApiAlignedName = $false ) $ModuleFolderPath = Split-Path $TemplateFilePath -Parent diff --git a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 index 820a478fa6..9fe61ae9c4 100644 --- a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 +++ b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 @@ -69,6 +69,7 @@ function Get-SpecsAlignedResourceName { $rawProviderNamespace, $rawResourceType = $reducedResourceIdentifier -Split '[\/|\\]', 2 # e.g. 'keyvault' & 'vaults/keys' + # Find provider namespace $foundProviderNamespaceMatches = ($specs.Keys | Sort-Object) | Where-Object { $_ -like "Microsoft.$rawProviderNamespace*" } if (-not $foundProviderNamespaceMatches) { @@ -78,44 +79,18 @@ function Get-SpecsAlignedResourceName { $providerNamespace = ($foundProviderNamespaceMatches.Count -eq 1) ? $foundProviderNamespaceMatches : $foundProviderNamespaceMatches[0] } + # Find resource type $innerResourceTypes = $specs[$providerNamespace].Keys | Sort-Object - $rawResourceTypeReduced = Get-ReducedWordString -StringToReduce $rawResourceType - $foundResourceTypeMatches = $innerResourceTypes | Where-Object { $_ -like "$rawResourceTypeReduced*" } - - if (-not $foundResourceTypeMatches) { - $resourceType = $reducedResourceIdentifier.Split('/')[1] - Write-Warning "Failed to identify resource type [$rawResourceType] in provider namespace [$providerNamespace]. Fallback to [$resourceType]." - } elseif ($foundResourceTypeMatches.Count -eq 1) { - $resourceType = $foundResourceTypeMatches - } else { - # If more than one specs resource type matches the input resource type core string, get all specs core strings and check exact match - # This is to avoid that e.g. web/connection falls to Microsoft.Web/connectionGateways instead of Microsoft.Web/connections - foreach ($foundResourceTypeMatch in $foundResourceTypeMatches) { - $foundResourceTypeMatchReduced = Get-ReducedWordString -StringToReduce $foundResourceTypeMatch - if ($rawResourceTypeReduced -eq $foundResourceTypeMatchReduced) { - $resourceType = $foundResourceTypeMatch - break - } - } - - if (-not $resourceType) { - # Try removing last split of each match, then reduce to core and compare - # This is needed to deal cases such as Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers where backupFabrics does not exist on its own - foreach ($foundResourceTypeMatch in $foundResourceTypeMatches) { - $foundResourceTypeMatch = $foundResourceTypeMatch.SubString(0, $foundResourceTypeMatch.LastIndexOf('/')) - $foundResourceTypeMatchReduced = Get-ReducedWordString -StringToReduce $foundResourceTypeMatch - if ($rawResourceTypeReduced -eq $foundResourceTypeMatchReduced) { - $resourceType = $foundResourceTypeMatch - break - } - } - # Finally fallback to first match in the list - if (-not $resourceType) { - $resourceType = $foundResourceTypeMatches[0] - Write-Warning "Failed to find exact match between core matched resource types and [$rawResourceTypeReduced]. Fallback to first ResourceType in the match list [$resourceType]." - } - } - } + $reducedResourceType = Get-ReducedWordString -StringToReduce $rawResourceType + + $reducedResourceTypeElements = $reducedResourceType -split '[\/|\\]' + + ## We built a regex that matches the resource type, but also the plural and singular form of it along its entire path. For example ^vault(y|ii|e|ys|ies|es|s|)(\/|$)key(y|ii|e|ys|ies|es|s|)(\/|$)$ + ### (y|ii|e|ys|ies|es|s|) = Singular or plural form + ### (\/|$) = End of string or another resource type level + $resourceTypeRegex = '^{0}(y|ii|e|ys|ies|es|s|)(\/|$)$' -f ($reducedResourceTypeElements -join '(y|ii|e|ys|ies|es|s|)(\/|$)') + $resourceType = $innerResourceTypes | Where-Object { $_ -match $resourceTypeRegex } + # Build result return "$providerNamespace/$resourceType" } From fba9f9e9708fc0fedc98e1fea002ab4e2a416abe Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 13:28:31 +0200 Subject: [PATCH 02/31] Updated tempalte spec name handling --- .../Get-PrivateRegistryRepositoryName.ps1 | 11 +++++----- .../resourcePublish/Get-TemplateSpecsName.ps1 | 22 +++++++++++++++++-- .../Get-UniversalArtifactsName.ps1 | 7 ++++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 b/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 index a419650413..32ff1a5da0 100644 --- a/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 @@ -29,16 +29,15 @@ function Get-PrivateRegistryRepositoryName { [bool] $UseApiAlignedName = $false ) - # Load helper scripts - . (Join-Path (Get-Item -Path $PSScriptRoot).Parent.Parent 'tools' 'helper' 'Get-SpecsAlignedResourceName.ps1') - $moduleIdentifier = (Split-Path $TemplateFilePath -Parent).Replace('\', '/').Split('/modules/')[1] if ($UseApiAlignedName) { - $moduleRegistryIdentifier = 'bicep/modules/{0}' -f $moduleIdentifier.Replace('\', '/').Replace('/', '.').ToLower() - } else { - $moduleRegistryIdentifier = 'bicep/modules/{0}' -f $moduleIdentifier.Replace('\', '/').Replace('/', '.').ToLower() + # Load helper script + . (Join-Path (Get-Item -Path $PSScriptRoot).Parent.Parent 'tools' 'helper' 'Get-SpecsAlignedResourceName.ps1') + $moduleIdentifier = Get-SpecsAlignedResourceName -ResourceIdentifier $moduleIdentifier } + $moduleRegistryIdentifier = 'bicep/modules/{0}' -f $moduleIdentifier.Replace('\', '/').Replace('/', '.').ToLower() + return $moduleRegistryIdentifier } diff --git a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 index 26ee1ce050..7ccb99e09a 100644 --- a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 @@ -30,6 +30,13 @@ function Get-TemplateSpecsName { ) $moduleIdentifier = (Split-Path $TemplateFilePath -Parent).Replace('\', '/').Split('/modules/')[1] + + if ($UseApiAlignedName) { + # Load helper script + . (Join-Path (Get-Item -Path $PSScriptRoot).Parent.Parent 'tools' 'helper' 'Get-SpecsAlignedResourceName.ps1') + $moduleIdentifier = Get-SpecsAlignedResourceName -ResourceIdentifier $moduleIdentifier + } + $templateSpecIdentifier = $moduleIdentifier.Replace('\', '/').Replace('/', '.').ToLower() # Shorten the name @@ -44,8 +51,19 @@ function Get-TemplateSpecsName { $stringToCheck = $nameElems[($index + 1)] # If a name is replicated in a path, it is usually plural in the parent, and singular in the child path. - if ($stringToCheck.StartsWith($stringToRemove)) { - $nameElems[($index + 1)] = $stringToCheck -replace "$stringToRemove-" + # For example: /virtualNetworks/ (plural) & /virtualNetworks/virtualNetworkPeerings/ (singular) + # In this case we want to remove the singular version from the subsequent string & format it accordingly + if ($stringToRemove.EndsWith('s') -and $stringToCheck.StartsWith($stringToRemove.Substring(0, $stringToRemove.length - 1))) { + $singularString = $stringToRemove.Substring(0, $stringToRemove.length - 1) + $rest = $stringToCheck.length - $singularString.Length + $shortenedString = $stringToCheck.Substring($singularString.length, $rest) + $camelCaseString = [Regex]::Replace($shortenedString , '\b.', { $args[0].Value.Tolower() }) + $nameElems[($index + 1)] = $camelCaseString + } elseif ($stringToCheck.StartsWith($stringToRemove)) { + # If the subsequent string starts with the current string, we want to remove the current string from the subsequent string. + # So we take the index of the end of the current string, caculate the length until the end of the string and reduce. If a `-` was in between the 2 elements, we also want to trim it from the front. + # For example 'replication-protection-container' & 'replication-protection-container-mapping' shiuld become 'mapping' + $nameElems[($index + 1)] = $stringToCheck.Substring($stringToRemove.length, $stringToCheck.length - $stringToRemove.length).TrimStart('-') } } } diff --git a/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 b/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 index 211cd8b98d..3458e1c459 100644 --- a/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 @@ -32,6 +32,13 @@ function Get-UniversalArtifactsName { $ModuleFolderPath = Split-Path $TemplateFilePath -Parent $universalPackageModuleName = $ModuleFolderPath.Replace('\', '/').Split('/modules/')[1] + + if ($UseApiAlignedName) { + # Load helper script + . (Join-Path (Get-Item -Path $PSScriptRoot).Parent.Parent 'tools' 'helper' 'Get-SpecsAlignedResourceName.ps1') + $universalPackageModuleName = Get-SpecsAlignedResourceName -ResourceIdentifier $universalPackageModuleName + } + $universalPackageModuleName = $universalPackageModuleName.Replace('\', '.').Replace('/', '.').toLower() return $universalPackageModuleName From 126d4eb1a124a013b43e00a4ca41dae36fad608c Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 13:53:18 +0200 Subject: [PATCH 03/31] Added a switch to control the name used for publishing via the settings.yml --- .../pipelineTemplates/jobs.publishModule.yml | 7 +++- .../templates/publishModule/action.yml | 37 +++++++++++-------- .github/workflows/template.module.yml | 1 + settings.yml | 1 + .../Publish-ModuleToPrivateBicepRegistry.ps1 | 12 +++++- .../Publish-ModuleToTemplateSpecsRG.ps1 | 12 +++++- ...Publish-ModuleToUniversalArtifactsFeed.ps1 | 12 +++++- 7 files changed, 60 insertions(+), 22 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.publishModule.yml b/.azuredevops/pipelineTemplates/jobs.publishModule.yml index df9df5bc86..4466d17325 100644 --- a/.azuredevops/pipelineTemplates/jobs.publishModule.yml +++ b/.azuredevops/pipelineTemplates/jobs.publishModule.yml @@ -27,7 +27,8 @@ ## | vmImage | '$(vmImage)' | You can provide either a [poolname] or [vmImage] to run the job on | 'ubuntu20.04' | ## | defaultJobTimeoutInMinutes | 120 | The timeout for the job in this pipeline | 120 | ## | modulePath | '$(modulePath)' | The path to the module to deploy. E.g. [c:/KeyVault] | 'c:/KeyVault' | -## | publishLatest | '$(publishLatest)' | Flag to indicate whether or not to publish a "latest" version to Bicep Registry and Template Specs | true | +## | publishLatest | '$(publishLatest)' | Flag to indicate whether or not to publish a "latest" version to Bicep Registry and Template Specs | true | +## | publishUsingApiAlignedName | '$(publishUsingApiAlignedName)' | Flag to indicate whether or not to publish module using their REST API, or their folder path name | true | ## | templateSpecsRGName | '$(templateSpecsRGName)' | Required to publish to template spec. ResourceGroup of the template spec to publish to | 'mgmt-rg' | ## | templateSpecsRGLocation | '$(templateSpecsRGLocation)' | Required to publish to template spec. Location of the template spec resource group | 'West Europe' | ## | templateSpecsDescription | '$(templateSpecsDescription)' | Required to publish to template spec. Description of the template spec to publish to | 'IaCs module' | @@ -60,6 +61,7 @@ parameters: # Shared publishLatest: '$(publishLatest)' + publishUsingApiAlignedName: '$(publishUsingApiAlignedName)' ## TemplateSpec-related templateSpecsDoPublish: '$(templateSpecsDoPublish)' @@ -194,6 +196,7 @@ jobs: VstsFeedProject = '${{ parameters.vstsFeedProject }}' VstsFeedName = '${{ parameters.vstsFeedName }}' ModuleVersion = $moduleToPublish.Version + UseApiAlignedName = '${{ parameters.publishUsingApiAlignedName }}' } Write-Verbose "Invoke Publish-ModuleToUniversalArtifactsFeed with" -Verbose @@ -287,6 +290,7 @@ jobs: TemplateSpecsRgLocation = '${{ parameters.templateSpecsRgLocation }}' TemplateSpecsDescription = '${{ parameters.templateSpecsDescription }}' ModuleVersion = $moduleToPublish.Version + UseApiAlignedName = '${{ parameters.publishUsingApiAlignedName }}' } Write-Verbose "Invoke Publish-ModuleToTemplateSpecsRG with" -Verbose @@ -382,6 +386,7 @@ jobs: BicepRegistryRgName = '${{ parameters.bicepRegistryRgName }}' BicepRegistryRgLocation = '${{ parameters.bicepRegistryRgLocation }}' ModuleVersion = $moduleToPublish.Version + UseApiAlignedName = '${{ parameters.publishUsingApiAlignedName }}' } Write-Verbose "Invoke Publish-ModuleToPrivateBicepRegistry with" -Verbose diff --git a/.github/actions/templates/publishModule/action.yml b/.github/actions/templates/publishModule/action.yml index 49d8241f57..81c645f3ed 100644 --- a/.github/actions/templates/publishModule/action.yml +++ b/.github/actions/templates/publishModule/action.yml @@ -12,21 +12,22 @@ ## ACTION PARAMETERS ## ##-------------------------------------------## ## -## |===========================================================================================================================================================================================================| -## | Parameter | Required | Default | Description | Example | -## |--------------------------|----------|---------|--------------------------------------------------------------------------------------------------|--------------------------------------------------------| -## | templateFilePath | true | '' | The path to the template file to publish | 'modules/api-management/service/main.bicep' | -## | subscriptionId | false | '' | The ID of the subscription to publish to | '11111111-1111-1111-1111-111111111111' | -## | templateSpecsRgName | false | '' | Required to publish to template spec. ResourceGroup of the template spec to publish to | 'artifacts-rg' | -## | templateSpecsRgLocation | false | '' | Required to publish to template spec. Location of the template spec resource group | 'WestEurope' | -## | templateSpecsDescription | false | '' | Required to publish to template spec. Description of the template spec to publish to | 'This is an API-Management service template' | -## | templateSpecsDoPublish | false | 'false' | Flag to indicate whether or not to publish to template specs | 'true' | -## | bicepRegistryName | false | '' | Required to publish to private bicep registry. Name of the container registry to publish to | 'myacr' | -## | bicepRegistryRgName | false | '' | Required to publish to private bicep registry. Name of the container registry resource group | 'artifacts-rg' | -## | bicepRegistryRgLocation | false | '' | Required to publish to private bicep registry. Location of the container registry resource group | 'WestEurope' | -## | bicepRegistryDoPublish | false | 'false' | Flag to indicate whether or not to publish to the private bicep registry | 'true' | -## | publishLatest | false | 'true' | Flag to indicate whether or not to publish a "latest" version | 'true' | -## |===========================================================================================================================================================================================================| +## |==============================================================================================================================================================================================================| +## | Parameter | Required | Default | Description | Example | +## |----------------------------|----------|---------|---------------------------------------------------------------------------------------------------|--------------------------------------------------------| +## | templateFilePath | true | '' | The path to the template file to publish | 'modules/api-management/service/main.bicep' | +## | subscriptionId | false | '' | The ID of the subscription to publish to | '11111111-1111-1111-1111-111111111111' | +## | templateSpecsRgName | false | '' | Required to publish to template spec. ResourceGroup of the template spec to publish to | 'artifacts-rg' | +## | templateSpecsRgLocation | false | '' | Required to publish to template spec. Location of the template spec resource group | 'WestEurope' | +## | templateSpecsDescription | false | '' | Required to publish to template spec. Description of the template spec to publish to | 'This is an API-Management service template' | +## | templateSpecsDoPublish | false | 'false' | Flag to indicate whether or not to publish to template specs | 'true' | +## | bicepRegistryName | false | '' | Required to publish to private bicep registry. Name of the container registry to publish to | 'myacr' | +## | bicepRegistryRgName | false | '' | Required to publish to private bicep registry. Name of the container registry resource group | 'artifacts-rg' | +## | bicepRegistryRgLocation | false | '' | Required to publish to private bicep registry. Location of the container registry resource group | 'WestEurope' | +## | bicepRegistryDoPublish | false | 'false' | Flag to indicate whether or not to publish to the private bicep registry | 'true' | +## | publishLatest | false | 'true' | Flag to indicate whether or not to publish a "latest" version | 'true' | +## | publishUsingApiAlignedName | false | 'false' | Flag to indicate whether or not to publish module using their REST API, or their folder path name | 'true' | +## |==============================================================================================================================================================================================================| ## ##---------------------------------------------## name: 'Publishing' @@ -69,6 +70,10 @@ inputs: description: 'Flag to indicate whether or not to publish a "latest" version' default: 'true' required: false + publishUsingApiAlignedName: + description: 'Flag to indicate whether or not to publish module using their REST API, or their folder path name' + default: 'false' + required: false runs: using: 'composite' @@ -149,6 +154,7 @@ runs: TemplateSpecsRgLocation = '${{ inputs.templateSpecsRgLocation }}' TemplateSpecsDescription = '${{ inputs.templateSpecsDescription }}' ModuleVersion = $moduleToPublish.Version + UseApiAlignedName = '${{ inputs.publishUsingApiAlignedName }}' } Write-Verbose "Invoke task with" -Verbose @@ -229,6 +235,7 @@ runs: BicepRegistryRgName = '${{ inputs.bicepRegistryRgName }}' BicepRegistryRgLocation = '${{ inputs.bicepRegistryRgLocation }}' ModuleVersion = $moduleToPublish.Version + UseApiAlignedName = '${{ inputs.publishUsingApiAlignedName }}' } Write-Verbose "Invoke task with" -Verbose diff --git a/.github/workflows/template.module.yml b/.github/workflows/template.module.yml index 180935b1b8..6e547e19ec 100644 --- a/.github/workflows/template.module.yml +++ b/.github/workflows/template.module.yml @@ -140,3 +140,4 @@ jobs: bicepRegistryRgLocation: '${{ env.bicepRegistryRgLocation }}' bicepRegistryDoPublish: '${{ env.bicepRegistryDoPublish }}' publishLatest: '${{ env.publishLatest }}' + publishUsingApiAlignedName: '${{ env.publishUsingApiAlignedName }}' diff --git a/settings.yml b/settings.yml index 04bdbab53d..9f43ef6ba1 100644 --- a/settings.yml +++ b/settings.yml @@ -54,6 +54,7 @@ variables: # --------------- # publishLatest: true # [Only for Template-Specs & Bicep Registry] Publish an absolute latest version. Note: This version may include breaking changes and is not recommended for production environments + publishUsingApiAlignedName: false # Publish a module not using its folder path, but the matching name in the REST API (i.e., the classic naming). For example: `bicep/modules/microsoft.keyvault.vaults.secrets` instead of `bicep/modules/key-vault.vault.secret` # Template-Spec settings # # ---------------------- # diff --git a/utilities/pipelines/resourcePublish/Publish-ModuleToPrivateBicepRegistry.ps1 b/utilities/pipelines/resourcePublish/Publish-ModuleToPrivateBicepRegistry.ps1 index cc5b29b846..8b018f6be8 100644 --- a/utilities/pipelines/resourcePublish/Publish-ModuleToPrivateBicepRegistry.ps1 +++ b/utilities/pipelines/resourcePublish/Publish-ModuleToPrivateBicepRegistry.ps1 @@ -25,6 +25,11 @@ Example: 'artifacts-rg' Optional. The location of the resourceGroup the private bicep registry is deployed to. Required if the resource group is not yet existing. Example: 'West Europe' +.PARAMETER UseApiAlignedName +Optional. If set to true, the module will be published with a name that is aligned with the Azure API naming. If not, one aligned with the module's folder path. See the following examples: +- True: bicep/modules/microsoft.keyvault.vaults.secrets +- False: bicep/modules/key-vault.vault.secret + .EXAMPLE Publish-ModuleToPrivateBicepRegistry -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' -ModuleVersion '3.0.0-alpha' -BicepRegistryName 'adpsxxazacrx001' -BicepRegistryRgName 'artifacts-rg' @@ -47,7 +52,10 @@ function Publish-ModuleToPrivateBicepRegistry { [string] $BicepRegistryRgName, [Parameter(Mandatory = $false)] - [string] $BicepRegistryRgLocation + [string] $BicepRegistryRgLocation, + + [Parameter(Mandatory = $false)] + [bool] $UseApiAlignedName = $false ) begin { @@ -80,7 +88,7 @@ function Publish-ModuleToPrivateBicepRegistry { } # Get a valid Container Registry name - $moduleRegistryIdentifier = Get-PrivateRegistryRepositoryName -TemplateFilePath $TemplateFilePath + $moduleRegistryIdentifier = Get-PrivateRegistryRepositoryName -TemplateFilePath $TemplateFilePath -UseApiAlignedName $UseApiAlignedName ############################################# ## Publish to private bicep registry ## diff --git a/utilities/pipelines/resourcePublish/Publish-ModuleToTemplateSpecsRG.ps1 b/utilities/pipelines/resourcePublish/Publish-ModuleToTemplateSpecsRG.ps1 index f3a2c1191d..868302881c 100644 --- a/utilities/pipelines/resourcePublish/Publish-ModuleToTemplateSpecsRG.ps1 +++ b/utilities/pipelines/resourcePublish/Publish-ModuleToTemplateSpecsRG.ps1 @@ -26,6 +26,11 @@ Example: 'West Europe' Mandatory. The description of the parent template spec. Example: 'iacs key vault' +.PARAMETER UseApiAlignedName +Optional. If set to true, the module will be published with a name that is aligned with the Azure API naming. If not, one aligned with the module's folder path. See the following examples: +- True: microsoft.keyvault.vaults.secrets +- False: key-vault.vault.secret + .EXAMPLE Publish-ModuleToTemplateSpecsRG -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' -ModuleVersion '3.0.0-alpha' -TemplateSpecsRgName 'artifacts-rg' -TemplateSpecsRgLocation 'West Europe' -TemplateSpecsDescription 'iacs key vault' @@ -48,7 +53,10 @@ function Publish-ModuleToTemplateSpecsRG { [string] $TemplateSpecsRgLocation, [Parameter(Mandatory)] - [string] $TemplateSpecsDescription + [string] $TemplateSpecsDescription, + + [Parameter(Mandatory = $false)] + [bool] $UseApiAlignedName = $false ) begin { @@ -69,7 +77,7 @@ function Publish-ModuleToTemplateSpecsRG { } # Get a valid Template Specs name - $templateSpecIdentifier = Get-TemplateSpecsName -TemplateFilePath $TemplateFilePath + $templateSpecIdentifier = Get-TemplateSpecsName -TemplateFilePath $TemplateFilePath -UseApiAlignedName $UseApiAlignedName ################################ ## Create template spec ## diff --git a/utilities/pipelines/resourcePublish/Publish-ModuleToUniversalArtifactsFeed.ps1 b/utilities/pipelines/resourcePublish/Publish-ModuleToUniversalArtifactsFeed.ps1 index a2e79cf3b7..7d095a4169 100644 --- a/utilities/pipelines/resourcePublish/Publish-ModuleToUniversalArtifactsFeed.ps1 +++ b/utilities/pipelines/resourcePublish/Publish-ModuleToUniversalArtifactsFeed.ps1 @@ -59,6 +59,11 @@ Example: 'Artifacts'. .PARAMETER BearerToken Optional. The bearer token to use to authenticate the request. If not provided it MUST be existing in your environment as `$env:TOKEN` +.PARAMETER UseApiAlignedName +Optional. If set to true, the module will be published with a name that is aligned with the Azure API naming. If not, one aligned with the module's folder path. See the following examples: +- True: microsoft.keyvault.vaults.secrets +- False: key-vault.vault.secret + .EXAMPLE Publish-ModuleToUniversalArtifactsFeed -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' -ModuleVersion '3.0.0-alpha' -vstsOrganizationUri 'https://dev.azure.com/fabrikam' -VstsProject 'IaC' -VstsFeedName 'Artifacts' @@ -84,7 +89,10 @@ function Publish-ModuleToUniversalArtifactsFeed { [string] $BearerToken = $env:TOKEN, [Parameter(Mandatory)] - [string] $ModuleVersion + [string] $ModuleVersion, + + [Parameter(Mandatory = $false)] + [bool] $UseApiAlignedName = $false ) begin { @@ -103,7 +111,7 @@ function Publish-ModuleToUniversalArtifactsFeed { ################################# ## Generate package name ## ################################# - $universalPackageModuleName = Get-UniversalArtifactsName -TemplateFilePath $TemplateFilePath + $universalPackageModuleName = Get-UniversalArtifactsName -TemplateFilePath $TemplateFilePath -UseApiAlignedName $UseApiAlignedName ########################### ## Find feed scope ## From 97d4c95b402cf8b441d03f8f80cd74d2afc04950 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 13:58:47 +0200 Subject: [PATCH 04/31] Temp switching setting to use classic name for testing --- settings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.yml b/settings.yml index 9f43ef6ba1..40a0042a3d 100644 --- a/settings.yml +++ b/settings.yml @@ -54,7 +54,7 @@ variables: # --------------- # publishLatest: true # [Only for Template-Specs & Bicep Registry] Publish an absolute latest version. Note: This version may include breaking changes and is not recommended for production environments - publishUsingApiAlignedName: false # Publish a module not using its folder path, but the matching name in the REST API (i.e., the classic naming). For example: `bicep/modules/microsoft.keyvault.vaults.secrets` instead of `bicep/modules/key-vault.vault.secret` + publishUsingApiAlignedName: true # Publish a module not using its folder path, but the matching name in the REST API (i.e., the classic naming). For example: `bicep/modules/microsoft.keyvault.vaults.secrets` instead of `bicep/modules/key-vault.vault.secret` # Template-Spec settings # # ---------------------- # From b6936f0972f0daac2e2b08d99dda7a1eebd0f688 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 14:35:28 +0200 Subject: [PATCH 05/31] Removed apparently redundant function --- utilities/tools/Set-ModuleReadMe.ps1 | 6 +- .../helper/ConvertTo-ModuleResourceType.ps1 | 57 ------------------- 2 files changed, 3 insertions(+), 60 deletions(-) delete mode 100644 utilities/tools/helper/ConvertTo-ModuleResourceType.ps1 diff --git a/utilities/tools/Set-ModuleReadMe.ps1 b/utilities/tools/Set-ModuleReadMe.ps1 index 9f55b4cca6..ca0f04a51b 100644 --- a/utilities/tools/Set-ModuleReadMe.ps1 +++ b/utilities/tools/Set-ModuleReadMe.ps1 @@ -1400,7 +1400,7 @@ Initialize the readme of the 'sql/managed-instance/administrator' module #> function Initialize-ReadMe { - [CmdletBinding(SupportsShouldProcess)] + [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string] $ReadMeFilePath, @@ -1412,11 +1412,11 @@ function Initialize-ReadMe { [hashtable] $TemplateFileContent ) - . (Join-Path $PSScriptRoot 'helper' 'ConvertTo-ModuleResourceType.ps1') + . (Join-Path $PSScriptRoot 'helper' 'Get-SpecsAlignedResourceName.ps1') $moduleName = $TemplateFileContent.metadata.name $moduleDescription = $TemplateFileContent.metadata.description - $formattedResourceType = ConvertTo-ModuleResourceType -ResourceIdentifier $FullModuleIdentifier + $formattedResourceType = Get-SpecsAlignedResourceName -ResourceIdentifier $FullModuleIdentifier if (-not (Test-Path $ReadMeFilePath) -or ([String]::IsNullOrEmpty((Get-Content $ReadMeFilePath -Raw)))) { diff --git a/utilities/tools/helper/ConvertTo-ModuleResourceType.ps1 b/utilities/tools/helper/ConvertTo-ModuleResourceType.ps1 deleted file mode 100644 index e18892fc21..0000000000 --- a/utilities/tools/helper/ConvertTo-ModuleResourceType.ps1 +++ /dev/null @@ -1,57 +0,0 @@ -<# -.SYNOPSIS -Converts a parent or child module folder path to the corresponding resource type. - -.DESCRIPTION -Converts a parent or child module folder path to the corresponding resource type. - -.PARAMETER ResourceIdentifier -Mandatory. The resource identifier to search for, i.e. the relative module file path starting from the resource provider folder. - -.EXAMPLE -ConvertTo-ModuleResourceType -ResourceIdentifier 'storage/storage-account'. - -Returns 'Microsoft.Storage/storageAccounts'. - -.EXAMPLE -ConvertTo-ModuleResourceType -ResourceIdentifier 'storage/storage-account/blob-service/container/immutability-policy'. - -Returns 'Microsoft.Storage/storageAccounts/blobServices/containers/immutabilityPolicies'. -#> -function ConvertTo-ModuleResourceType { - - [CmdletBinding()] - param ( - [Parameter(Mandatory = $true)] - [string] $ResourceIdentifier - ) - - . (Join-Path $PSScriptRoot 'Get-SpecsAlignedResourceName.ps1') - - $provider, $parentType, $childTypeString = $ResourceIdentifier -Split '[\/|\\]', 3 - $parentResourceIdentifier = $provider, $parentType -join '/' - - $fullParentResourceType = Get-SpecsAlignedResourceName -ResourceIdentifier $parentResourceIdentifier - - if (-not $childTypeString) { - $fullResourceType = $fullParentResourceType - } else { - $childTypeArray = $childTypeString -split '\/' - - $innerResourceType = $fullParentResourceType - foreach ($childType in $childTypeArray) { - # Additional check for child types non existing on their own (e.g. sites/hybridConnectionNamespaces does not exist, sites/hybridConnectionNamespaces/relays does) - $innerResourceTypeLeafReduced = Get-ReducedWordString -StringToReduce ($innerResourceType -Split '[\/|\\]')[-1] - $childTypeReduced = Get-ReducedWordString -StringToReduce $childType - if ($innerResourceTypeLeafReduced -eq $childTypeReduced) { - break - } - - $innerResourceType = $innerResourceType.Replace('Microsoft.', '', 'OrdinalIgnoreCase'), $childType -join '/' - $fullResourceType = Get-SpecsAlignedResourceName -ResourceIdentifier $innerResourceType - $innerResourceType = $fullResourceType - } - } - - return $fullResourceType -} From 8cc12293b8689a37a3bf0d96462fa7c14d6cd247 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 14:42:16 +0200 Subject: [PATCH 06/31] Introduced temp change --- modules/key-vault/vault/key/main.bicep | 2 +- .../replication-protection-container-mapping/main.bicep | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/key-vault/vault/key/main.bicep b/modules/key-vault/vault/key/main.bicep index 5db4a3ebf3..7cc9dea2a5 100644 --- a/modules/key-vault/vault/key/main.bicep +++ b/modules/key-vault/vault/key/main.bicep @@ -1,5 +1,5 @@ metadata name = 'Key Vault Keys' -metadata description = 'This module deploys a Key Vault Key.' +metadata description = 'This module deploys a Key Vault Key. ' metadata owner = 'Azure/module-maintainers' @description('Conditional. The name of the parent key vault. Required if the template is used in a standalone deployment.') diff --git a/modules/recovery-services/vault/replication-fabric/replication-protection-container/replication-protection-container-mapping/main.bicep b/modules/recovery-services/vault/replication-fabric/replication-protection-container/replication-protection-container-mapping/main.bicep index 1ad80f5bf3..faaeff807d 100644 --- a/modules/recovery-services/vault/replication-fabric/replication-protection-container/replication-protection-container-mapping/main.bicep +++ b/modules/recovery-services/vault/replication-fabric/replication-protection-container/replication-protection-container-mapping/main.bicep @@ -1,4 +1,4 @@ -metadata name = 'Recovery Services Vault Replication Fabric Replication Protection Container Replication Protection Container Mappings' +metadata name = 'Recovery Services Vault Replication Fabric Replication Protection Container Replication Protection Container Mappings ' metadata description = '''This module deploys a Recovery Services Vault (RSV) Replication Protection Container Mapping. > **Note**: this version of the module only supports the `instanceType: 'A2A'` scenario.''' From 6a770da10d046c4045bf15fe216faec95956d69a Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 14:46:23 +0200 Subject: [PATCH 07/31] Introduced temp change --- modules/key-vault/vault/key/main.bicep | 4 ++-- .../replication-protection-container-mapping/main.bicep | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/key-vault/vault/key/main.bicep b/modules/key-vault/vault/key/main.bicep index 7cc9dea2a5..0d4b0d42a7 100644 --- a/modules/key-vault/vault/key/main.bicep +++ b/modules/key-vault/vault/key/main.bicep @@ -1,7 +1,7 @@ metadata name = 'Key Vault Keys' -metadata description = 'This module deploys a Key Vault Key. ' +metadata description = 'This module deploys a Key Vault Key.' metadata owner = 'Azure/module-maintainers' - +// Comment to @description('Conditional. The name of the parent key vault. Required if the template is used in a standalone deployment.') param keyVaultName string diff --git a/modules/recovery-services/vault/replication-fabric/replication-protection-container/replication-protection-container-mapping/main.bicep b/modules/recovery-services/vault/replication-fabric/replication-protection-container/replication-protection-container-mapping/main.bicep index faaeff807d..1eb9093e33 100644 --- a/modules/recovery-services/vault/replication-fabric/replication-protection-container/replication-protection-container-mapping/main.bicep +++ b/modules/recovery-services/vault/replication-fabric/replication-protection-container/replication-protection-container-mapping/main.bicep @@ -1,9 +1,9 @@ -metadata name = 'Recovery Services Vault Replication Fabric Replication Protection Container Replication Protection Container Mappings ' +metadata name = 'Recovery Services Vault Replication Fabric Replication Protection Container Replication Protection Container Mappings' metadata description = '''This module deploys a Recovery Services Vault (RSV) Replication Protection Container Mapping. > **Note**: this version of the module only supports the `instanceType: 'A2A'` scenario.''' metadata owner = 'Azure/module-maintainers' - +// Comment to @description('Conditional. The name of the parent Azure Recovery Service Vault. Required if the template is used in a standalone deployment.') param recoveryVaultName string From bafb9a35c0a067463f5d92895594ab381fc51ba0 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 15:06:32 +0200 Subject: [PATCH 08/31] Added conversion --- .azuredevops/pipelineTemplates/jobs.publishModule.yml | 6 +++--- .github/actions/templates/publishModule/action.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.publishModule.yml b/.azuredevops/pipelineTemplates/jobs.publishModule.yml index 4466d17325..e8269b4b16 100644 --- a/.azuredevops/pipelineTemplates/jobs.publishModule.yml +++ b/.azuredevops/pipelineTemplates/jobs.publishModule.yml @@ -196,7 +196,7 @@ jobs: VstsFeedProject = '${{ parameters.vstsFeedProject }}' VstsFeedName = '${{ parameters.vstsFeedName }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = '${{ parameters.publishUsingApiAlignedName }}' + UseApiAlignedName = [bool] '${{ parameters.publishUsingApiAlignedName }}' } Write-Verbose "Invoke Publish-ModuleToUniversalArtifactsFeed with" -Verbose @@ -290,7 +290,7 @@ jobs: TemplateSpecsRgLocation = '${{ parameters.templateSpecsRgLocation }}' TemplateSpecsDescription = '${{ parameters.templateSpecsDescription }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = '${{ parameters.publishUsingApiAlignedName }}' + UseApiAlignedName = [bool] '${{ parameters.publishUsingApiAlignedName }}' } Write-Verbose "Invoke Publish-ModuleToTemplateSpecsRG with" -Verbose @@ -386,7 +386,7 @@ jobs: BicepRegistryRgName = '${{ parameters.bicepRegistryRgName }}' BicepRegistryRgLocation = '${{ parameters.bicepRegistryRgLocation }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = '${{ parameters.publishUsingApiAlignedName }}' + UseApiAlignedName = [bool] '${{ parameters.publishUsingApiAlignedName }}' } Write-Verbose "Invoke Publish-ModuleToPrivateBicepRegistry with" -Verbose diff --git a/.github/actions/templates/publishModule/action.yml b/.github/actions/templates/publishModule/action.yml index 81c645f3ed..bc1fb3b51a 100644 --- a/.github/actions/templates/publishModule/action.yml +++ b/.github/actions/templates/publishModule/action.yml @@ -154,7 +154,7 @@ runs: TemplateSpecsRgLocation = '${{ inputs.templateSpecsRgLocation }}' TemplateSpecsDescription = '${{ inputs.templateSpecsDescription }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = '${{ inputs.publishUsingApiAlignedName }}' + UseApiAlignedName = [bool]' ${{ inputs.publishUsingApiAlignedName }}' } Write-Verbose "Invoke task with" -Verbose @@ -235,7 +235,7 @@ runs: BicepRegistryRgName = '${{ inputs.bicepRegistryRgName }}' BicepRegistryRgLocation = '${{ inputs.bicepRegistryRgLocation }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = '${{ inputs.publishUsingApiAlignedName }}' + UseApiAlignedName = [bool] '${{ inputs.publishUsingApiAlignedName }}' } Write-Verbose "Invoke task with" -Verbose From a562ddb6bb42f97a0aefcde41a2496acf8b6af73 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 16:56:03 +0200 Subject: [PATCH 09/31] Added Microsoft to MS rename for template specs --- utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 index 7ccb99e09a..2d678ccbaf 100644 --- a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 @@ -35,6 +35,7 @@ function Get-TemplateSpecsName { # Load helper script . (Join-Path (Get-Item -Path $PSScriptRoot).Parent.Parent 'tools' 'helper' 'Get-SpecsAlignedResourceName.ps1') $moduleIdentifier = Get-SpecsAlignedResourceName -ResourceIdentifier $moduleIdentifier + $moduleIdentifier = $moduleIdentifier -replace 'microsoft', 'ms' } $templateSpecIdentifier = $moduleIdentifier.Replace('\', '/').Replace('/', '.').ToLower() From f7b556328f352ad8ee6ad3a792630087f544800c Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 16:57:30 +0200 Subject: [PATCH 10/31] Disabled anything but publishing for testing --- .../pipelineTemplates/stages.module.yml | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.azuredevops/pipelineTemplates/stages.module.yml b/.azuredevops/pipelineTemplates/stages.module.yml index 4f7c3103ff..3b6130078c 100644 --- a/.azuredevops/pipelineTemplates/stages.module.yml +++ b/.azuredevops/pipelineTemplates/stages.module.yml @@ -7,23 +7,23 @@ parameters: defaultJobTimeoutInMinutes: 120 stages: - - stage: validation - displayName: Static validation - condition: eq('${{ parameters.staticValidation }}', 'True') - jobs: - - template: /.azuredevops/pipelineTemplates/jobs.validateModulePester.yml + # - stage: validation + # displayName: Static validation + # condition: eq('${{ parameters.staticValidation }}', 'True') + # jobs: + # - template: /.azuredevops/pipelineTemplates/jobs.validateModulePester.yml - - stage: deployment - displayName: Deployment validation - condition: and(eq('${{ parameters.deploymentValidation }}', 'True'), ne(dependencies.validation.result, 'Failed')) - dependsOn: - - validation - jobs: - - template: /.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml - parameters: - templateFilePath: '$(modulePath)/main.bicep' - removeDeployment: '${{ parameters.removeDeployment }}' - defaultJobTimeoutInMinutes: ${{ parameters.defaultJobTimeoutInMinutes }} + # - stage: deployment + # displayName: Deployment validation + # condition: and(eq('${{ parameters.deploymentValidation }}', 'True'), ne(dependencies.validation.result, 'Failed')) + # dependsOn: + # - validation + # jobs: + # - template: /.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml + # parameters: + # templateFilePath: '$(modulePath)/main.bicep' + # removeDeployment: '${{ parameters.removeDeployment }}' + # defaultJobTimeoutInMinutes: ${{ parameters.defaultJobTimeoutInMinutes }} - stage: Publishing displayName: Publish module From 704ba72024f86bfe8130da4f70f93c0593932e9b Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 16:57:58 +0200 Subject: [PATCH 11/31] Disabled anything but publishing for testing --- .azuredevops/pipelineTemplates/stages.module.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.azuredevops/pipelineTemplates/stages.module.yml b/.azuredevops/pipelineTemplates/stages.module.yml index 3b6130078c..4d5da957a0 100644 --- a/.azuredevops/pipelineTemplates/stages.module.yml +++ b/.azuredevops/pipelineTemplates/stages.module.yml @@ -27,9 +27,9 @@ stages: - stage: Publishing displayName: Publish module - condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq('${{ parameters.prerelease }}', 'True'))) - dependsOn: - - validation - - deployment + # condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq('${{ parameters.prerelease }}', 'True'))) + # dependsOn: + # - validation + # - deployment jobs: - template: /.azuredevops/pipelineTemplates/jobs.publishModule.yml From dac3f2547cd6301ebb35212f5037f88e6f2c8d76 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 17:27:06 +0200 Subject: [PATCH 12/31] Disabled universal packaging as already tested --- .../pipelineTemplates/jobs.publishModule.yml | 168 +++++++++--------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.publishModule.yml b/.azuredevops/pipelineTemplates/jobs.publishModule.yml index e8269b4b16..a8d014f051 100644 --- a/.azuredevops/pipelineTemplates/jobs.publishModule.yml +++ b/.azuredevops/pipelineTemplates/jobs.publishModule.yml @@ -123,90 +123,90 @@ jobs: # [Universal Artifact-feed publish] task(s) #------------------------------------------ - - task: PowerShell@2 - displayName: 'Publish module to artifacts feed' - condition: and( - eq(variables['artifactsFeedDoPublish'], true), - succeeded() - ) - enabled: true - inputs: - targetType: inline - pwsh: true - script: | - # Load used functions - . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesToPublish.ps1') - . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Publish-ModuleToUniversalArtifactsFeed.ps1') - . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesMissingFromUniversalArtifactsFeed.ps1') - - #Prioritizing the bicep file - $TemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.modulePath }}' 'main.bicep' - if (-not (Test-Path $TemplateFilePath)) { - $TemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.modulePath }}' 'main.json' - } - - ################################ - ## Get modules to publish ## - ################################ - $functionInput = @{ - TemplateFilePath = $TemplateFilePath - PublishLatest = $false # Not supported by Azure DevOps feeds - } - - Write-Verbose "Invoke Get-ModulesToPublish with" -Verbose - Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose - - $modulesToPublish = @() - - # Get the modified child resources - $modulesToPublish += Get-ModulesToPublish @functionInput -Verbose - - ############################# - ## Get missing modules ## - ############################# - # Add all modules that don't exist in the target location - $missingInputObject = @{ - TemplateFilePath = $TemplateFilePath - VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}' - VstsFeedProject = '${{ parameters.vstsFeedProject }}' - VstsFeedName = '${{ parameters.vstsFeedName }}' - } - - Write-Verbose "Invoke Get-ModulesMissingFromUniversalArtifactsFeed with" -Verbose - Write-Verbose ($missingInputObject | ConvertTo-Json | Out-String) -Verbose - - $missingModules = Get-ModulesMissingFromUniversalArtifactsFeed @missingInputObject -BearerToken $env:TOKEN - - foreach($missingModule in $missingModules) { - if($modulsToPublish.TemplateFilePath -notcontains $missingModule.TemplateFilePath) { - $modulesToPublish += $missingModule - } - } - - ################# - ## Publish ## - ################# - foreach ($moduleToPublish in $modulesToPublish) { - $RelPath = (($moduleToPublish.TemplateFilePath).Split('/modules/')[-1]).Split('/main.')[0] - Write-Host "##[group]$(' - [{0}] [{1}]' -f $RelPath, $moduleToPublish.Version)" - - $functionInput = @{ - TemplateFilePath = $moduleToPublish.TemplateFilePath - VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}' - VstsFeedProject = '${{ parameters.vstsFeedProject }}' - VstsFeedName = '${{ parameters.vstsFeedName }}' - ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = [bool] '${{ parameters.publishUsingApiAlignedName }}' - } - - Write-Verbose "Invoke Publish-ModuleToUniversalArtifactsFeed with" -Verbose - Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose - - Publish-ModuleToUniversalArtifactsFeed @functionInput -BearerToken $env:TOKEN -Verbose - Write-Host "##[endgroup]" - } - env: - TOKEN: $(vstsFeedToken) + # - task: PowerShell@2 + # displayName: 'Publish module to artifacts feed' + # condition: and( + # eq(variables['artifactsFeedDoPublish'], true), + # succeeded() + # ) + # enabled: true + # inputs: + # targetType: inline + # pwsh: true + # script: | + # # Load used functions + # . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesToPublish.ps1') + # . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Publish-ModuleToUniversalArtifactsFeed.ps1') + # . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesMissingFromUniversalArtifactsFeed.ps1') + + # #Prioritizing the bicep file + # $TemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.modulePath }}' 'main.bicep' + # if (-not (Test-Path $TemplateFilePath)) { + # $TemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.modulePath }}' 'main.json' + # } + + # ################################ + # ## Get modules to publish ## + # ################################ + # $functionInput = @{ + # TemplateFilePath = $TemplateFilePath + # PublishLatest = $false # Not supported by Azure DevOps feeds + # } + + # Write-Verbose "Invoke Get-ModulesToPublish with" -Verbose + # Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose + + # $modulesToPublish = @() + + # # Get the modified child resources + # $modulesToPublish += Get-ModulesToPublish @functionInput -Verbose + + # ############################# + # ## Get missing modules ## + # ############################# + # # Add all modules that don't exist in the target location + # $missingInputObject = @{ + # TemplateFilePath = $TemplateFilePath + # VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}' + # VstsFeedProject = '${{ parameters.vstsFeedProject }}' + # VstsFeedName = '${{ parameters.vstsFeedName }}' + # } + + # Write-Verbose "Invoke Get-ModulesMissingFromUniversalArtifactsFeed with" -Verbose + # Write-Verbose ($missingInputObject | ConvertTo-Json | Out-String) -Verbose + + # $missingModules = Get-ModulesMissingFromUniversalArtifactsFeed @missingInputObject -BearerToken $env:TOKEN + + # foreach($missingModule in $missingModules) { + # if($modulsToPublish.TemplateFilePath -notcontains $missingModule.TemplateFilePath) { + # $modulesToPublish += $missingModule + # } + # } + + # ################# + # ## Publish ## + # ################# + # foreach ($moduleToPublish in $modulesToPublish) { + # $RelPath = (($moduleToPublish.TemplateFilePath).Split('/modules/')[-1]).Split('/main.')[0] + # Write-Host "##[group]$(' - [{0}] [{1}]' -f $RelPath, $moduleToPublish.Version)" + + # $functionInput = @{ + # TemplateFilePath = $moduleToPublish.TemplateFilePath + # VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}' + # VstsFeedProject = '${{ parameters.vstsFeedProject }}' + # VstsFeedName = '${{ parameters.vstsFeedName }}' + # ModuleVersion = $moduleToPublish.Version + # UseApiAlignedName = [bool] '${{ parameters.publishUsingApiAlignedName }}' + # } + + # Write-Verbose "Invoke Publish-ModuleToUniversalArtifactsFeed with" -Verbose + # Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose + + # Publish-ModuleToUniversalArtifactsFeed @functionInput -BearerToken $env:TOKEN -Verbose + # Write-Host "##[endgroup]" + # } + # env: + # TOKEN: $(vstsFeedToken) # [template-spec publish] task(s) #-------------------------------- From 756bdeecdd60384f61f18f4f901f6c24351c11a6 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 17:32:05 +0200 Subject: [PATCH 13/31] Disabled api aligned --- settings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.yml b/settings.yml index 40a0042a3d..9f43ef6ba1 100644 --- a/settings.yml +++ b/settings.yml @@ -54,7 +54,7 @@ variables: # --------------- # publishLatest: true # [Only for Template-Specs & Bicep Registry] Publish an absolute latest version. Note: This version may include breaking changes and is not recommended for production environments - publishUsingApiAlignedName: true # Publish a module not using its folder path, but the matching name in the REST API (i.e., the classic naming). For example: `bicep/modules/microsoft.keyvault.vaults.secrets` instead of `bicep/modules/key-vault.vault.secret` + publishUsingApiAlignedName: false # Publish a module not using its folder path, but the matching name in the REST API (i.e., the classic naming). For example: `bicep/modules/microsoft.keyvault.vaults.secrets` instead of `bicep/modules/key-vault.vault.secret` # Template-Spec settings # # ---------------------- # From c2727d37ffa2ef13b23e60dfe89bb33087a3f55b Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 17:33:52 +0200 Subject: [PATCH 14/31] Disabled most of gh pipeline for testing --- .github/workflows/template.module.yml | 118 +++++++++++++------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/.github/workflows/template.module.yml b/.github/workflows/template.module.yml index 6e547e19ec..2ffe5efeb4 100644 --- a/.github/workflows/template.module.yml +++ b/.github/workflows/template.module.yml @@ -50,63 +50,63 @@ jobs: ######################### # PSRule validation # ######################### - job_psrule_test: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners. - name: 'PSRule validation' - runs-on: ubuntu-20.04 - if: (fromJson(inputs.workflowInput)).staticValidation == 'true' - strategy: - fail-fast: false - matrix: - moduleTestFilePaths: ${{ fromJson(inputs.moduleTestFilePaths) }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set environment - uses: ./.github/actions/templates/setEnvironment - with: - variablesPath: ${{ env.variablesPath }} - - name: Set PSRule validation - uses: ./.github/actions/templates/validateModulePSRule - with: - templateFilePath: '${{ inputs.modulePath }}/${{ matrix.moduleTestFilePaths }}' - subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' - managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}' + # job_psrule_test: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners. + # name: 'PSRule validation' + # runs-on: ubuntu-20.04 + # if: (fromJson(inputs.workflowInput)).staticValidation == 'true' + # strategy: + # fail-fast: false + # matrix: + # moduleTestFilePaths: ${{ fromJson(inputs.moduleTestFilePaths) }} + # steps: + # - name: Checkout + # uses: actions/checkout@v3 + # - name: Set environment + # uses: ./.github/actions/templates/setEnvironment + # with: + # variablesPath: ${{ env.variablesPath }} + # - name: Set PSRule validation + # uses: ./.github/actions/templates/validateModulePSRule + # with: + # templateFilePath: '${{ inputs.modulePath }}/${{ matrix.moduleTestFilePaths }}' + # subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' + # managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}' - ############################# - # Deployment validation # - ############################# - job_module_deploy_validation: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners. - name: 'Deployment validation' - runs-on: ubuntu-20.04 - if: | - !cancelled() && - (fromJson(inputs.workflowInput)).deploymentValidation == 'true' && - needs.job_module_static_validation.result != 'failure' - needs: - - job_module_static_validation - # - job_psrule_test # Ignoring dependency whilst PSRule gets bedded in, in this project - strategy: - fail-fast: false - matrix: - moduleTestFilePaths: ${{ fromJson(inputs.moduleTestFilePaths) }} - steps: - - name: 'Checkout' - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set environment - uses: ./.github/actions/templates/setEnvironment - with: - variablesPath: ${{ env.variablesPath }} - removeDeployment: '${{ fromJson(inputs.workflowInput).removeDeployment }}' - - name: 'Using test file [${{ matrix.moduleTestFilePaths }}]' - uses: ./.github/actions/templates/validateModuleDeployment - with: - templateFilePath: '${{ inputs.modulePath }}/${{ matrix.moduleTestFilePaths }}' - location: '${{ env.location }}' - subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' - managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}' - removeDeployment: '${{ fromJson(inputs.workflowInput).removeDeployment }}' + # ############################# + # # Deployment validation # + # ############################# + # job_module_deploy_validation: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners. + # name: 'Deployment validation' + # runs-on: ubuntu-20.04 + # if: | + # !cancelled() && + # (fromJson(inputs.workflowInput)).deploymentValidation == 'true' && + # needs.job_module_static_validation.result != 'failure' + # needs: + # - job_module_static_validation + # # - job_psrule_test # Ignoring dependency whilst PSRule gets bedded in, in this project + # strategy: + # fail-fast: false + # matrix: + # moduleTestFilePaths: ${{ fromJson(inputs.moduleTestFilePaths) }} + # steps: + # - name: 'Checkout' + # uses: actions/checkout@v3 + # with: + # fetch-depth: 0 + # - name: Set environment + # uses: ./.github/actions/templates/setEnvironment + # with: + # variablesPath: ${{ env.variablesPath }} + # removeDeployment: '${{ fromJson(inputs.workflowInput).removeDeployment }}' + # - name: 'Using test file [${{ matrix.moduleTestFilePaths }}]' + # uses: ./.github/actions/templates/validateModuleDeployment + # with: + # templateFilePath: '${{ inputs.modulePath }}/${{ matrix.moduleTestFilePaths }}' + # location: '${{ env.location }}' + # subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' + # managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}' + # removeDeployment: '${{ fromJson(inputs.workflowInput).removeDeployment }}' ################## # Publishing # @@ -114,9 +114,9 @@ jobs: job_publish_module: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners. name: 'Publishing' runs-on: ubuntu-20.04 - if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || fromJson(inputs.workflowInput).prerelease == 'true' - needs: - - job_module_deploy_validation + # if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || fromJson(inputs.workflowInput).prerelease == 'true' + # needs: + # - job_module_deploy_validation steps: - name: 'Checkout' uses: actions/checkout@v3 From 49d45e9cc707c817465cd85e2f66e717916d6550 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 17:42:00 +0200 Subject: [PATCH 15/31] Refactored bool conversion to be more robust --- .../pipelineTemplates/jobs.publishModule.yml | 14 +++++++------- .github/actions/templates/publishModule/action.yml | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.publishModule.yml b/.azuredevops/pipelineTemplates/jobs.publishModule.yml index a8d014f051..96a1f46a1a 100644 --- a/.azuredevops/pipelineTemplates/jobs.publishModule.yml +++ b/.azuredevops/pipelineTemplates/jobs.publishModule.yml @@ -196,7 +196,7 @@ jobs: # VstsFeedProject = '${{ parameters.vstsFeedProject }}' # VstsFeedName = '${{ parameters.vstsFeedName }}' # ModuleVersion = $moduleToPublish.Version - # UseApiAlignedName = [bool] '${{ parameters.publishUsingApiAlignedName }}' + # UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') # } # Write-Verbose "Invoke Publish-ModuleToUniversalArtifactsFeed with" -Verbose @@ -244,7 +244,7 @@ jobs: ################################ $functionInput = @{ TemplateFilePath = $TemplateFilePath - PublishLatest = [bool] '${{ parameters.publishLatest }}' + PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}') } Write-Verbose "Invoke Get-ModulesToPublish with" -Verbose @@ -263,7 +263,7 @@ jobs: $missingInputObject = @{ TemplateFilePath = $TemplateFilePath TemplateSpecsRGName = '${{ parameters.templateSpecsRgName }}' - PublishLatest = [bool] '${{ parameters.bicepRegistryRgName }}' + PublishLatest = [System.Convert]::ToBoolean('${{ parameters.bicepRegistryRgName }}') } Write-Verbose "Invoke Get-ModulesMissingFromTemplateSpecsRG with" -Verbose @@ -290,7 +290,7 @@ jobs: TemplateSpecsRgLocation = '${{ parameters.templateSpecsRgLocation }}' TemplateSpecsDescription = '${{ parameters.templateSpecsDescription }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = [bool] '${{ parameters.publishUsingApiAlignedName }}' + UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') } Write-Verbose "Invoke Publish-ModuleToTemplateSpecsRG with" -Verbose @@ -340,7 +340,7 @@ jobs: ################################ $functionInput = @{ TemplateFilePath = $TemplateFilePath - PublishLatest = [bool] '${{ parameters.publishLatest }}' + PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}') } Write-Verbose "Invoke Get-ModulesToPublish with" -Verbose @@ -359,7 +359,7 @@ jobs: TemplateFilePath = $TemplateFilePath BicepRegistryName = '${{ parameters.bicepRegistryName }}' BicepRegistryRgName = '${{ parameters.bicepRegistryRgName }}' - PublishLatest = [bool] '${{ parameters.bicepRegistryRgName }}' + PublishLatest = [System.Convert]::ToBoolean('${{ parameters.bicepRegistryRgName }}') } Write-Verbose "Invoke Get-ModulesMissingFromPrivateBicepRegistry with" -Verbose @@ -386,7 +386,7 @@ jobs: BicepRegistryRgName = '${{ parameters.bicepRegistryRgName }}' BicepRegistryRgLocation = '${{ parameters.bicepRegistryRgLocation }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = [bool] '${{ parameters.publishUsingApiAlignedName }}' + UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') } Write-Verbose "Invoke Publish-ModuleToPrivateBicepRegistry with" -Verbose diff --git a/.github/actions/templates/publishModule/action.yml b/.github/actions/templates/publishModule/action.yml index bc1fb3b51a..5c984a7a68 100644 --- a/.github/actions/templates/publishModule/action.yml +++ b/.github/actions/templates/publishModule/action.yml @@ -110,7 +110,7 @@ runs: ################################ $functionInput = @{ TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE "${{ inputs.templateFilePath }}" - PublishLatest = [bool] "${{ inputs.publishLatest }}" + PublishLatest = [System.Convert]::ToBoolean("${{ inputs.publishLatest }}") } Write-Verbose "Invoke task with" -Verbose @@ -127,7 +127,7 @@ runs: $missingInputObject = @{ TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE "${{ inputs.templateFilePath }}" TemplateSpecsRGName = '${{ inputs.templateSpecsRgName }}' - PublishLatest = [bool] "${{ inputs.publishLatest }}" + PublishLatest = [System.Convert]::ToBoolean("${{ inputs.publishLatest }}") } Write-Verbose "Invoke Get-ModulesMissingFromTemplateSpecsRG with" -Verbose @@ -154,7 +154,7 @@ runs: TemplateSpecsRgLocation = '${{ inputs.templateSpecsRgLocation }}' TemplateSpecsDescription = '${{ inputs.templateSpecsDescription }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = [bool]' ${{ inputs.publishUsingApiAlignedName }}' + UseApiAlignedName = [System.Convert]::ToBoolean(${{ inputs.publishUsingApiAlignedName }}') } Write-Verbose "Invoke task with" -Verbose @@ -191,7 +191,7 @@ runs: ################################ $functionInput = @{ TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE "${{ inputs.templateFilePath }}" - PublishLatest = [bool] "${{ inputs.publishLatest }}" + PublishLatest = [System.Convert]::ToBoolean("${{ inputs.publishLatest }}") } Write-Verbose "Invoke task with" -Verbose @@ -208,7 +208,7 @@ runs: TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE "${{ inputs.templateFilePath }}" BicepRegistryName = '${{ inputs.bicepRegistryName }}' BicepRegistryRgName = '${{ inputs.bicepRegistryRgName }}' - PublishLatest = [bool] "${{ inputs.publishLatest }}" + PublishLatest = [System.Convert]::ToBoolean("${{ inputs.publishLatest }}") } Write-Verbose "Invoke Get-ModulesMissingFromPrivateBicepRegistry with" -Verbose @@ -235,7 +235,7 @@ runs: BicepRegistryRgName = '${{ inputs.bicepRegistryRgName }}' BicepRegistryRgLocation = '${{ inputs.bicepRegistryRgLocation }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = [bool] '${{ inputs.publishUsingApiAlignedName }}' + UseApiAlignedName = [System.Convert]::ToBoolean('${{ inputs.publishUsingApiAlignedName }}') } Write-Verbose "Invoke task with" -Verbose From df0185b5af39c32553ce72546a4c0ca13dd1ac4c Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 17:50:44 +0200 Subject: [PATCH 16/31] Added missing quote --- .github/actions/templates/publishModule/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/templates/publishModule/action.yml b/.github/actions/templates/publishModule/action.yml index 5c984a7a68..f6a409ec95 100644 --- a/.github/actions/templates/publishModule/action.yml +++ b/.github/actions/templates/publishModule/action.yml @@ -154,7 +154,7 @@ runs: TemplateSpecsRgLocation = '${{ inputs.templateSpecsRgLocation }}' TemplateSpecsDescription = '${{ inputs.templateSpecsDescription }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = [System.Convert]::ToBoolean(${{ inputs.publishUsingApiAlignedName }}') + UseApiAlignedName = [System.Convert]::ToBoolean('${{ inputs.publishUsingApiAlignedName }}') } Write-Verbose "Invoke task with" -Verbose From 3f6caf5711f764ade0c6d3af157627ef66bb9706 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 17:53:21 +0200 Subject: [PATCH 17/31] Update to latest --- .azuredevops/pipelineTemplates/jobs.publishModule.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.publishModule.yml b/.azuredevops/pipelineTemplates/jobs.publishModule.yml index 96a1f46a1a..fcec44ed31 100644 --- a/.azuredevops/pipelineTemplates/jobs.publishModule.yml +++ b/.azuredevops/pipelineTemplates/jobs.publishModule.yml @@ -263,7 +263,7 @@ jobs: $missingInputObject = @{ TemplateFilePath = $TemplateFilePath TemplateSpecsRGName = '${{ parameters.templateSpecsRgName }}' - PublishLatest = [System.Convert]::ToBoolean('${{ parameters.bicepRegistryRgName }}') + PublishLatest = '${{ parameters.bicepRegistryRgName }}' } Write-Verbose "Invoke Get-ModulesMissingFromTemplateSpecsRG with" -Verbose @@ -359,7 +359,7 @@ jobs: TemplateFilePath = $TemplateFilePath BicepRegistryName = '${{ parameters.bicepRegistryName }}' BicepRegistryRgName = '${{ parameters.bicepRegistryRgName }}' - PublishLatest = [System.Convert]::ToBoolean('${{ parameters.bicepRegistryRgName }}') + PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}') } Write-Verbose "Invoke Get-ModulesMissingFromPrivateBicepRegistry with" -Verbose From 0c6ef423df2db22d4ff51352ba23ba47d4450c7d Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 17:56:42 +0200 Subject: [PATCH 18/31] Undid temp change --- .github/workflows/template.module.yml | 118 +++++++++++++------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/.github/workflows/template.module.yml b/.github/workflows/template.module.yml index 2ffe5efeb4..6e547e19ec 100644 --- a/.github/workflows/template.module.yml +++ b/.github/workflows/template.module.yml @@ -50,63 +50,63 @@ jobs: ######################### # PSRule validation # ######################### - # job_psrule_test: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners. - # name: 'PSRule validation' - # runs-on: ubuntu-20.04 - # if: (fromJson(inputs.workflowInput)).staticValidation == 'true' - # strategy: - # fail-fast: false - # matrix: - # moduleTestFilePaths: ${{ fromJson(inputs.moduleTestFilePaths) }} - # steps: - # - name: Checkout - # uses: actions/checkout@v3 - # - name: Set environment - # uses: ./.github/actions/templates/setEnvironment - # with: - # variablesPath: ${{ env.variablesPath }} - # - name: Set PSRule validation - # uses: ./.github/actions/templates/validateModulePSRule - # with: - # templateFilePath: '${{ inputs.modulePath }}/${{ matrix.moduleTestFilePaths }}' - # subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' - # managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}' + job_psrule_test: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners. + name: 'PSRule validation' + runs-on: ubuntu-20.04 + if: (fromJson(inputs.workflowInput)).staticValidation == 'true' + strategy: + fail-fast: false + matrix: + moduleTestFilePaths: ${{ fromJson(inputs.moduleTestFilePaths) }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set environment + uses: ./.github/actions/templates/setEnvironment + with: + variablesPath: ${{ env.variablesPath }} + - name: Set PSRule validation + uses: ./.github/actions/templates/validateModulePSRule + with: + templateFilePath: '${{ inputs.modulePath }}/${{ matrix.moduleTestFilePaths }}' + subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' + managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}' - # ############################# - # # Deployment validation # - # ############################# - # job_module_deploy_validation: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners. - # name: 'Deployment validation' - # runs-on: ubuntu-20.04 - # if: | - # !cancelled() && - # (fromJson(inputs.workflowInput)).deploymentValidation == 'true' && - # needs.job_module_static_validation.result != 'failure' - # needs: - # - job_module_static_validation - # # - job_psrule_test # Ignoring dependency whilst PSRule gets bedded in, in this project - # strategy: - # fail-fast: false - # matrix: - # moduleTestFilePaths: ${{ fromJson(inputs.moduleTestFilePaths) }} - # steps: - # - name: 'Checkout' - # uses: actions/checkout@v3 - # with: - # fetch-depth: 0 - # - name: Set environment - # uses: ./.github/actions/templates/setEnvironment - # with: - # variablesPath: ${{ env.variablesPath }} - # removeDeployment: '${{ fromJson(inputs.workflowInput).removeDeployment }}' - # - name: 'Using test file [${{ matrix.moduleTestFilePaths }}]' - # uses: ./.github/actions/templates/validateModuleDeployment - # with: - # templateFilePath: '${{ inputs.modulePath }}/${{ matrix.moduleTestFilePaths }}' - # location: '${{ env.location }}' - # subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' - # managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}' - # removeDeployment: '${{ fromJson(inputs.workflowInput).removeDeployment }}' + ############################# + # Deployment validation # + ############################# + job_module_deploy_validation: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners. + name: 'Deployment validation' + runs-on: ubuntu-20.04 + if: | + !cancelled() && + (fromJson(inputs.workflowInput)).deploymentValidation == 'true' && + needs.job_module_static_validation.result != 'failure' + needs: + - job_module_static_validation + # - job_psrule_test # Ignoring dependency whilst PSRule gets bedded in, in this project + strategy: + fail-fast: false + matrix: + moduleTestFilePaths: ${{ fromJson(inputs.moduleTestFilePaths) }} + steps: + - name: 'Checkout' + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set environment + uses: ./.github/actions/templates/setEnvironment + with: + variablesPath: ${{ env.variablesPath }} + removeDeployment: '${{ fromJson(inputs.workflowInput).removeDeployment }}' + - name: 'Using test file [${{ matrix.moduleTestFilePaths }}]' + uses: ./.github/actions/templates/validateModuleDeployment + with: + templateFilePath: '${{ inputs.modulePath }}/${{ matrix.moduleTestFilePaths }}' + location: '${{ env.location }}' + subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' + managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}' + removeDeployment: '${{ fromJson(inputs.workflowInput).removeDeployment }}' ################## # Publishing # @@ -114,9 +114,9 @@ jobs: job_publish_module: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners. name: 'Publishing' runs-on: ubuntu-20.04 - # if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || fromJson(inputs.workflowInput).prerelease == 'true' - # needs: - # - job_module_deploy_validation + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || fromJson(inputs.workflowInput).prerelease == 'true' + needs: + - job_module_deploy_validation steps: - name: 'Checkout' uses: actions/checkout@v3 From b4deca8b7d0fbac2903896b02e53d212028d1416 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 17:57:27 +0200 Subject: [PATCH 19/31] Small fix --- .azuredevops/pipelineTemplates/jobs.publishModule.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azuredevops/pipelineTemplates/jobs.publishModule.yml b/.azuredevops/pipelineTemplates/jobs.publishModule.yml index fcec44ed31..a00ccb1cbb 100644 --- a/.azuredevops/pipelineTemplates/jobs.publishModule.yml +++ b/.azuredevops/pipelineTemplates/jobs.publishModule.yml @@ -263,7 +263,7 @@ jobs: $missingInputObject = @{ TemplateFilePath = $TemplateFilePath TemplateSpecsRGName = '${{ parameters.templateSpecsRgName }}' - PublishLatest = '${{ parameters.bicepRegistryRgName }}' + PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}') } Write-Verbose "Invoke Get-ModulesMissingFromTemplateSpecsRG with" -Verbose From 9a2657e99c08def1950ded2c9d1b3edc90d5bef9 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 18:01:27 +0200 Subject: [PATCH 20/31] Removed temp changes --- modules/key-vault/vault/key/main.bicep | 2 +- .../replication-protection-container-mapping/main.bicep | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/key-vault/vault/key/main.bicep b/modules/key-vault/vault/key/main.bicep index 0d4b0d42a7..5db4a3ebf3 100644 --- a/modules/key-vault/vault/key/main.bicep +++ b/modules/key-vault/vault/key/main.bicep @@ -1,7 +1,7 @@ metadata name = 'Key Vault Keys' metadata description = 'This module deploys a Key Vault Key.' metadata owner = 'Azure/module-maintainers' -// Comment to + @description('Conditional. The name of the parent key vault. Required if the template is used in a standalone deployment.') param keyVaultName string diff --git a/modules/recovery-services/vault/replication-fabric/replication-protection-container/replication-protection-container-mapping/main.bicep b/modules/recovery-services/vault/replication-fabric/replication-protection-container/replication-protection-container-mapping/main.bicep index 1eb9093e33..1ad80f5bf3 100644 --- a/modules/recovery-services/vault/replication-fabric/replication-protection-container/replication-protection-container-mapping/main.bicep +++ b/modules/recovery-services/vault/replication-fabric/replication-protection-container/replication-protection-container-mapping/main.bicep @@ -3,7 +3,7 @@ metadata description = '''This module deploys a Recovery Services Vault (RSV) Re > **Note**: this version of the module only supports the `instanceType: 'A2A'` scenario.''' metadata owner = 'Azure/module-maintainers' -// Comment to + @description('Conditional. The name of the parent Azure Recovery Service Vault. Required if the template is used in a standalone deployment.') param recoveryVaultName string From b06acf8d92c3ab30f06c7c1c8e6da5195213a4ee Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 18:09:20 +0200 Subject: [PATCH 21/31] Added missing flag --- .../pipelineTemplates/jobs.publishModule.yml | 169 +++++++++--------- .../service/api/policy/README.md | 2 +- .../lock/resource-group/README.md | 2 +- .../authorization/lock/subscription/README.md | 2 +- .../management-group/README.md | 2 +- .../resource-group/README.md | 2 +- .../policy-assignment/subscription/README.md | 2 +- .../management-group/README.md | 2 +- .../policy-definition/subscription/README.md | 2 +- .../management-group/README.md | 2 +- .../policy-exemption/resource-group/README.md | 2 +- .../policy-exemption/subscription/README.md | 2 +- .../management-group/README.md | 2 +- .../subscription/README.md | 2 +- .../management-group/README.md | 2 +- .../role-assignment/resource-group/README.md | 2 +- .../role-assignment/subscription/README.md | 2 +- .../management-group/README.md | 2 +- .../role-definition/resource-group/README.md | 2 +- .../role-definition/subscription/README.md | 2 +- modules/compute/gallery/application/README.md | 2 +- modules/compute/gallery/image/README.md | 2 +- .../registry/replication/README.md | 2 +- .../registry/webhook/README.md | 2 +- .../factory/integration-runtime/README.md | 2 +- .../factory/managed-virtual-network/README.md | 2 +- .../managed-private-endpoint/README.md | 2 +- ...dulesMissingFromUniversalArtifactsFeed.ps1 | 10 +- 28 files changed, 120 insertions(+), 111 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.publishModule.yml b/.azuredevops/pipelineTemplates/jobs.publishModule.yml index a00ccb1cbb..f06ee9a78f 100644 --- a/.azuredevops/pipelineTemplates/jobs.publishModule.yml +++ b/.azuredevops/pipelineTemplates/jobs.publishModule.yml @@ -123,90 +123,91 @@ jobs: # [Universal Artifact-feed publish] task(s) #------------------------------------------ - # - task: PowerShell@2 - # displayName: 'Publish module to artifacts feed' - # condition: and( - # eq(variables['artifactsFeedDoPublish'], true), - # succeeded() - # ) - # enabled: true - # inputs: - # targetType: inline - # pwsh: true - # script: | - # # Load used functions - # . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesToPublish.ps1') - # . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Publish-ModuleToUniversalArtifactsFeed.ps1') - # . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesMissingFromUniversalArtifactsFeed.ps1') - - # #Prioritizing the bicep file - # $TemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.modulePath }}' 'main.bicep' - # if (-not (Test-Path $TemplateFilePath)) { - # $TemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.modulePath }}' 'main.json' - # } - - # ################################ - # ## Get modules to publish ## - # ################################ - # $functionInput = @{ - # TemplateFilePath = $TemplateFilePath - # PublishLatest = $false # Not supported by Azure DevOps feeds - # } - - # Write-Verbose "Invoke Get-ModulesToPublish with" -Verbose - # Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose - - # $modulesToPublish = @() - - # # Get the modified child resources - # $modulesToPublish += Get-ModulesToPublish @functionInput -Verbose - - # ############################# - # ## Get missing modules ## - # ############################# - # # Add all modules that don't exist in the target location - # $missingInputObject = @{ - # TemplateFilePath = $TemplateFilePath - # VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}' - # VstsFeedProject = '${{ parameters.vstsFeedProject }}' - # VstsFeedName = '${{ parameters.vstsFeedName }}' - # } - - # Write-Verbose "Invoke Get-ModulesMissingFromUniversalArtifactsFeed with" -Verbose - # Write-Verbose ($missingInputObject | ConvertTo-Json | Out-String) -Verbose - - # $missingModules = Get-ModulesMissingFromUniversalArtifactsFeed @missingInputObject -BearerToken $env:TOKEN - - # foreach($missingModule in $missingModules) { - # if($modulsToPublish.TemplateFilePath -notcontains $missingModule.TemplateFilePath) { - # $modulesToPublish += $missingModule - # } - # } - - # ################# - # ## Publish ## - # ################# - # foreach ($moduleToPublish in $modulesToPublish) { - # $RelPath = (($moduleToPublish.TemplateFilePath).Split('/modules/')[-1]).Split('/main.')[0] - # Write-Host "##[group]$(' - [{0}] [{1}]' -f $RelPath, $moduleToPublish.Version)" - - # $functionInput = @{ - # TemplateFilePath = $moduleToPublish.TemplateFilePath - # VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}' - # VstsFeedProject = '${{ parameters.vstsFeedProject }}' - # VstsFeedName = '${{ parameters.vstsFeedName }}' - # ModuleVersion = $moduleToPublish.Version - # UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') - # } - - # Write-Verbose "Invoke Publish-ModuleToUniversalArtifactsFeed with" -Verbose - # Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose - - # Publish-ModuleToUniversalArtifactsFeed @functionInput -BearerToken $env:TOKEN -Verbose - # Write-Host "##[endgroup]" - # } - # env: - # TOKEN: $(vstsFeedToken) + - task: PowerShell@2 + displayName: 'Publish module to artifacts feed' + condition: and( + eq(variables['artifactsFeedDoPublish'], true), + succeeded() + ) + enabled: true + inputs: + targetType: inline + pwsh: true + script: | + # Load used functions + . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesToPublish.ps1') + . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Publish-ModuleToUniversalArtifactsFeed.ps1') + . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesMissingFromUniversalArtifactsFeed.ps1') + + #Prioritizing the bicep file + $TemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.modulePath }}' 'main.bicep' + if (-not (Test-Path $TemplateFilePath)) { + $TemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.modulePath }}' 'main.json' + } + + ################################ + ## Get modules to publish ## + ################################ + $functionInput = @{ + TemplateFilePath = $TemplateFilePath + PublishLatest = $false # Not supported by Azure DevOps feeds + } + + Write-Verbose "Invoke Get-ModulesToPublish with" -Verbose + Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose + + $modulesToPublish = @() + + # Get the modified child resources + $modulesToPublish += Get-ModulesToPublish @functionInput -Verbose + + ############################# + ## Get missing modules ## + ############################# + # Add all modules that don't exist in the target location + $missingInputObject = @{ + TemplateFilePath = $TemplateFilePath + VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}' + VstsFeedProject = '${{ parameters.vstsFeedProject }}' + VstsFeedName = '${{ parameters.vstsFeedName }}' + UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') + } + + Write-Verbose "Invoke Get-ModulesMissingFromUniversalArtifactsFeed with" -Verbose + Write-Verbose ($missingInputObject | ConvertTo-Json | Out-String) -Verbose + + $missingModules = Get-ModulesMissingFromUniversalArtifactsFeed @missingInputObject -BearerToken $env:TOKEN + + foreach($missingModule in $missingModules) { + if($modulsToPublish.TemplateFilePath -notcontains $missingModule.TemplateFilePath) { + $modulesToPublish += $missingModule + } + } + + ################# + ## Publish ## + ################# + foreach ($moduleToPublish in $modulesToPublish) { + $RelPath = (($moduleToPublish.TemplateFilePath).Split('/modules/')[-1]).Split('/main.')[0] + Write-Host "##[group]$(' - [{0}] [{1}]' -f $RelPath, $moduleToPublish.Version)" + + $functionInput = @{ + TemplateFilePath = $moduleToPublish.TemplateFilePath + VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}' + VstsFeedProject = '${{ parameters.vstsFeedProject }}' + VstsFeedName = '${{ parameters.vstsFeedName }}' + ModuleVersion = $moduleToPublish.Version + UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') + } + + Write-Verbose "Invoke Publish-ModuleToUniversalArtifactsFeed with" -Verbose + Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose + + Publish-ModuleToUniversalArtifactsFeed @functionInput -BearerToken $env:TOKEN -Verbose + Write-Host "##[endgroup]" + } + env: + TOKEN: $(vstsFeedToken) # [template-spec publish] task(s) #-------------------------------- diff --git a/modules/api-management/service/api/policy/README.md b/modules/api-management/service/api/policy/README.md index 3696e336ba..2efcedd723 100644 --- a/modules/api-management/service/api/policy/README.md +++ b/modules/api-management/service/api/policy/README.md @@ -1,4 +1,4 @@ -# API Management Service APIs Policies `[Microsoft.ApiManagement/service/apis/policies]` +# API Management Service APIs Policies `[Microsoft.ApiManagement/service/apis/policies service/apis/policy]` This module deploys an API Management Service API Policy. diff --git a/modules/authorization/lock/resource-group/README.md b/modules/authorization/lock/resource-group/README.md index 146e48ed25..4be7ce8ce2 100644 --- a/modules/authorization/lock/resource-group/README.md +++ b/modules/authorization/lock/resource-group/README.md @@ -1,4 +1,4 @@ -# Authorization Locks (Resource Group scope) `[Microsoft.Authorization/locks]` +# Authorization Locks (Resource Group scope) `[Microsoft.Authorization/]` This module deploys an Authorization Lock at a Resource Group scope. diff --git a/modules/authorization/lock/subscription/README.md b/modules/authorization/lock/subscription/README.md index 35fe0fd8ca..6295c60819 100644 --- a/modules/authorization/lock/subscription/README.md +++ b/modules/authorization/lock/subscription/README.md @@ -1,4 +1,4 @@ -# Authorization Locks (Subscription scope) `[Microsoft.Authorization/locks]` +# Authorization Locks (Subscription scope) `[Microsoft.Authorization/]` This module deploys an Authorization Lock at a Subscription scope. diff --git a/modules/authorization/policy-assignment/management-group/README.md b/modules/authorization/policy-assignment/management-group/README.md index 086b1d38ea..a408f543ba 100644 --- a/modules/authorization/policy-assignment/management-group/README.md +++ b/modules/authorization/policy-assignment/management-group/README.md @@ -1,4 +1,4 @@ -# Policy Assignments (Management Group scope) `[Microsoft.Authorization/policyAssignments]` +# Policy Assignments (Management Group scope) `[Microsoft.Authorization/]` This module deploys a Policy Assignment at a Management Group scope. diff --git a/modules/authorization/policy-assignment/resource-group/README.md b/modules/authorization/policy-assignment/resource-group/README.md index 6ed90b07ac..f2336f7aae 100644 --- a/modules/authorization/policy-assignment/resource-group/README.md +++ b/modules/authorization/policy-assignment/resource-group/README.md @@ -1,4 +1,4 @@ -# Policy Assignments (Resource Group scope) `[Microsoft.Authorization/policyAssignments]` +# Policy Assignments (Resource Group scope) `[Microsoft.Authorization/]` This module deploys a Policy Assignment at a Resource Group scope. diff --git a/modules/authorization/policy-assignment/subscription/README.md b/modules/authorization/policy-assignment/subscription/README.md index 26810db431..505028a10e 100644 --- a/modules/authorization/policy-assignment/subscription/README.md +++ b/modules/authorization/policy-assignment/subscription/README.md @@ -1,4 +1,4 @@ -# Policy Assignments (Subscription scope) `[Microsoft.Authorization/policyAssignments]` +# Policy Assignments (Subscription scope) `[Microsoft.Authorization/]` This module deploys a Policy Assignment at a Subscription scope. diff --git a/modules/authorization/policy-definition/management-group/README.md b/modules/authorization/policy-definition/management-group/README.md index 01780427c6..fa0ce94b6c 100644 --- a/modules/authorization/policy-definition/management-group/README.md +++ b/modules/authorization/policy-definition/management-group/README.md @@ -1,4 +1,4 @@ -# Policy Definitions (Management Group scope) `[Microsoft.Authorization/policyDefinitions]` +# Policy Definitions (Management Group scope) `[Microsoft.Authorization/]` This module deploys a Policy Definition at a Management Group scope. diff --git a/modules/authorization/policy-definition/subscription/README.md b/modules/authorization/policy-definition/subscription/README.md index 2557236387..c665835085 100644 --- a/modules/authorization/policy-definition/subscription/README.md +++ b/modules/authorization/policy-definition/subscription/README.md @@ -1,4 +1,4 @@ -# Policy Definitions (Subscription scope) `[Microsoft.Authorization/policyDefinitions]` +# Policy Definitions (Subscription scope) `[Microsoft.Authorization/]` This module deploys a Policy Definition at a Subscription scope. diff --git a/modules/authorization/policy-exemption/management-group/README.md b/modules/authorization/policy-exemption/management-group/README.md index 1bfb787eab..2a869122e7 100644 --- a/modules/authorization/policy-exemption/management-group/README.md +++ b/modules/authorization/policy-exemption/management-group/README.md @@ -1,4 +1,4 @@ -# Policy Exemptions (Management Group scope) `[Microsoft.Authorization/policyExemptions]` +# Policy Exemptions (Management Group scope) `[Microsoft.Authorization/]` This module deploys a Policy Exemption at a Management Group scope. diff --git a/modules/authorization/policy-exemption/resource-group/README.md b/modules/authorization/policy-exemption/resource-group/README.md index 7fd6faa68a..c1502237dc 100644 --- a/modules/authorization/policy-exemption/resource-group/README.md +++ b/modules/authorization/policy-exemption/resource-group/README.md @@ -1,4 +1,4 @@ -# Policy Exemptions (Resource Group scope) `[Microsoft.Authorization/policyExemptions]` +# Policy Exemptions (Resource Group scope) `[Microsoft.Authorization/]` This module deploys a Policy Exemption at a Resource Group scope. diff --git a/modules/authorization/policy-exemption/subscription/README.md b/modules/authorization/policy-exemption/subscription/README.md index 82e45d2349..5c5824449d 100644 --- a/modules/authorization/policy-exemption/subscription/README.md +++ b/modules/authorization/policy-exemption/subscription/README.md @@ -1,4 +1,4 @@ -# Policy Exemptions (Subscription scope) `[Microsoft.Authorization/policyExemptions]` +# Policy Exemptions (Subscription scope) `[Microsoft.Authorization/]` This module deploys a Policy Exemption at a Subscription scope. diff --git a/modules/authorization/policy-set-definition/management-group/README.md b/modules/authorization/policy-set-definition/management-group/README.md index 40de7bcd60..31e45770bf 100644 --- a/modules/authorization/policy-set-definition/management-group/README.md +++ b/modules/authorization/policy-set-definition/management-group/README.md @@ -1,4 +1,4 @@ -# Policy Set Definitions (Initiatives) (Management Group scope) `[Microsoft.Authorization/policySetDefinitions]` +# Policy Set Definitions (Initiatives) (Management Group scope) `[Microsoft.Authorization/]` This module deploys a Policy Set Definition (Initiative) at a Management Group scope. diff --git a/modules/authorization/policy-set-definition/subscription/README.md b/modules/authorization/policy-set-definition/subscription/README.md index 64b2597fe0..e5efdd02af 100644 --- a/modules/authorization/policy-set-definition/subscription/README.md +++ b/modules/authorization/policy-set-definition/subscription/README.md @@ -1,4 +1,4 @@ -# Policy Set Definitions (Initiatives) (Subscription scope) `[Microsoft.Authorization/policySetDefinitions]` +# Policy Set Definitions (Initiatives) (Subscription scope) `[Microsoft.Authorization/]` This module deploys a Policy Set Definition (Initiative) at a Subscription scope. diff --git a/modules/authorization/role-assignment/management-group/README.md b/modules/authorization/role-assignment/management-group/README.md index 911ac2c8e6..4bdb71cf76 100644 --- a/modules/authorization/role-assignment/management-group/README.md +++ b/modules/authorization/role-assignment/management-group/README.md @@ -1,4 +1,4 @@ -# Role Assignments (Management Group scope) `[Microsoft.Authorization/roleAssignments]` +# Role Assignments (Management Group scope) `[Microsoft.Authorization/]` This module deploys a Role Assignment at a Management Group scope. diff --git a/modules/authorization/role-assignment/resource-group/README.md b/modules/authorization/role-assignment/resource-group/README.md index a2cd0959a5..05ce2a6869 100644 --- a/modules/authorization/role-assignment/resource-group/README.md +++ b/modules/authorization/role-assignment/resource-group/README.md @@ -1,4 +1,4 @@ -# Role Assignments (Resource Group scope) `[Microsoft.Authorization/roleAssignments]` +# Role Assignments (Resource Group scope) `[Microsoft.Authorization/]` This module deploys a Role Assignment at a Resource Group scope. diff --git a/modules/authorization/role-assignment/subscription/README.md b/modules/authorization/role-assignment/subscription/README.md index 58b5d059a4..15ec8204c2 100644 --- a/modules/authorization/role-assignment/subscription/README.md +++ b/modules/authorization/role-assignment/subscription/README.md @@ -1,4 +1,4 @@ -# Role Assignments (Subscription scope) `[Microsoft.Authorization/roleAssignments]` +# Role Assignments (Subscription scope) `[Microsoft.Authorization/]` This module deploys a Role Assignment at a Subscription scope. diff --git a/modules/authorization/role-definition/management-group/README.md b/modules/authorization/role-definition/management-group/README.md index 02a11b45bc..16e3277838 100644 --- a/modules/authorization/role-definition/management-group/README.md +++ b/modules/authorization/role-definition/management-group/README.md @@ -1,4 +1,4 @@ -# Role Definitions (Management Group scope) `[Microsoft.Authorization/roleDefinitions]` +# Role Definitions (Management Group scope) `[Microsoft.Authorization/]` This module deploys a Role Definition at a Management Group scope. diff --git a/modules/authorization/role-definition/resource-group/README.md b/modules/authorization/role-definition/resource-group/README.md index 924c4eb112..a5b665c745 100644 --- a/modules/authorization/role-definition/resource-group/README.md +++ b/modules/authorization/role-definition/resource-group/README.md @@ -1,4 +1,4 @@ -# Role Definitions (Resource Group scope) `[Microsoft.Authorization/roleDefinitions]` +# Role Definitions (Resource Group scope) `[Microsoft.Authorization/]` This module deploys a Role Definition at a Resource Group scope. diff --git a/modules/authorization/role-definition/subscription/README.md b/modules/authorization/role-definition/subscription/README.md index 3bbd9894b0..8531393c0d 100644 --- a/modules/authorization/role-definition/subscription/README.md +++ b/modules/authorization/role-definition/subscription/README.md @@ -1,4 +1,4 @@ -# Role Definitions (Subscription scope) `[Microsoft.Authorization/roleDefinitions]` +# Role Definitions (Subscription scope) `[Microsoft.Authorization/]` This module deploys a Role Definition at a Subscription scope. diff --git a/modules/compute/gallery/application/README.md b/modules/compute/gallery/application/README.md index 5c5b203c60..987626e1d4 100644 --- a/modules/compute/gallery/application/README.md +++ b/modules/compute/gallery/application/README.md @@ -1,4 +1,4 @@ -# Compute Galleries Applications `[Microsoft.Compute/galleries/applications]` +# Compute Galleries Applications `[Microsoft.Compute/]` This module deploys an Azure Compute Gallery Application. diff --git a/modules/compute/gallery/image/README.md b/modules/compute/gallery/image/README.md index 2feab7d26a..23f4256ba1 100644 --- a/modules/compute/gallery/image/README.md +++ b/modules/compute/gallery/image/README.md @@ -1,4 +1,4 @@ -# Compute Galleries Image Definitions `[Microsoft.Compute/galleries/images]` +# Compute Galleries Image Definitions `[Microsoft.Compute/]` This module deploys an Azure Compute Gallery Image Definition. diff --git a/modules/container-registry/registry/replication/README.md b/modules/container-registry/registry/replication/README.md index d8f012b3da..13214ba226 100644 --- a/modules/container-registry/registry/replication/README.md +++ b/modules/container-registry/registry/replication/README.md @@ -1,4 +1,4 @@ -# Azure Container Registry (ACR) Replications `[Microsoft.ContainerRegistry/registries/replications]` +# Azure Container Registry (ACR) Replications `[Microsoft.ContainerRegistry/]` This module deploys an Azure Container Registry (ACR) Replication. diff --git a/modules/container-registry/registry/webhook/README.md b/modules/container-registry/registry/webhook/README.md index 4001b8a48a..336c42b60b 100644 --- a/modules/container-registry/registry/webhook/README.md +++ b/modules/container-registry/registry/webhook/README.md @@ -1,4 +1,4 @@ -# Azure Container Registry (ACR) Webhooks `[Microsoft.ContainerRegistry/registries/webhooks]` +# Azure Container Registry (ACR) Webhooks `[Microsoft.ContainerRegistry/]` This module deploys an Azure Container Registry (ACR) Webhook. diff --git a/modules/data-factory/factory/integration-runtime/README.md b/modules/data-factory/factory/integration-runtime/README.md index 8d15a01a4e..dbd81b4a3f 100644 --- a/modules/data-factory/factory/integration-runtime/README.md +++ b/modules/data-factory/factory/integration-runtime/README.md @@ -1,4 +1,4 @@ -# Data Factory Integration RunTimes `[Microsoft.DataFactory/factories/integrationRuntimes]` +# Data Factory Integration RunTimes `[Microsoft.DataFactory/]` This module deploys a Data Factory Managed or Self-Hosted Integration Runtime. diff --git a/modules/data-factory/factory/managed-virtual-network/README.md b/modules/data-factory/factory/managed-virtual-network/README.md index d1da00c980..8f79eceb16 100644 --- a/modules/data-factory/factory/managed-virtual-network/README.md +++ b/modules/data-factory/factory/managed-virtual-network/README.md @@ -1,4 +1,4 @@ -# Data Factory Managed Virtual Networks `[Microsoft.DataFactory/factories/managedVirtualNetworks]` +# Data Factory Managed Virtual Networks `[Microsoft.DataFactory/]` This module deploys a Data Factory Managed Virtual Network. diff --git a/modules/data-factory/factory/managed-virtual-network/managed-private-endpoint/README.md b/modules/data-factory/factory/managed-virtual-network/managed-private-endpoint/README.md index 7d3631961a..31a7424788 100644 --- a/modules/data-factory/factory/managed-virtual-network/managed-private-endpoint/README.md +++ b/modules/data-factory/factory/managed-virtual-network/managed-private-endpoint/README.md @@ -1,4 +1,4 @@ -# Data Factory Managed Virtual Network Managed PrivateEndpoints `[Microsoft.DataFactory/factories/managedVirtualNetworks/managedPrivateEndpoints]` +# Data Factory Managed Virtual Network Managed PrivateEndpoints `[Microsoft.DataFactory/]` This module deploys a Data Factory Managed Virtual Network Managed Private Endpoint. diff --git a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromUniversalArtifactsFeed.ps1 b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromUniversalArtifactsFeed.ps1 index df7b43e33d..e76bf4b750 100644 --- a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromUniversalArtifactsFeed.ps1 +++ b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromUniversalArtifactsFeed.ps1 @@ -20,6 +20,11 @@ Example: 'IaC'. Mandatory. Name to the feed to publish to. Example: 'Artifacts'. +.PARAMETER UseApiAlignedName +Optional. If set to true, the module name looked for is aligned with the Azure API naming. If not, it's one aligned with the module's folder path. See the following examples: +- True: microsoft.keyvault.vaults.secrets +- False: key-vault.vault.secret + .PARAMETER BearerToken Optional. The bearer token to use to authenticate the request. If not provided it MUST be existing in your environment as `$env:TOKEN` @@ -56,6 +61,9 @@ function Get-ModulesMissingFromUniversalArtifactsFeed { [Parameter(Mandatory = $false)] [string] $VstsFeedProject = '', + [Parameter(Mandatory = $false)] + [bool] $UseApiAlignedName = $false, + [Parameter(Mandatory = $false)] [string] $BearerToken = $env:TOKEN ) @@ -104,7 +112,7 @@ function Get-ModulesMissingFromUniversalArtifactsFeed { foreach ($templatePath in $availableModuleTemplatePaths) { # Get a valid Universal Artifact name - $artifactsIdentifier = Get-UniversalArtifactsName -TemplateFilePath $templatePath + $artifactsIdentifier = Get-UniversalArtifactsName -TemplateFilePath $templatePath -UseApiAlignedName $UseApiAlignedName if ($publishedModules -notcontains $artifactsIdentifier) { $missingTemplatePaths += $templatePath From 06714b1748ac5c97d0596d90abdaedc83b0b5368 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 18:12:09 +0200 Subject: [PATCH 22/31] Added missing flag --- .../pipelineTemplates/jobs.publishModule.yml | 2 ++ .../Get-ModulesMissingFromPrivateBicepRegistry.ps1 | 12 ++++++++++-- .../Get-ModulesMissingFromTemplateSpecsRG.ps1 | 12 ++++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.publishModule.yml b/.azuredevops/pipelineTemplates/jobs.publishModule.yml index f06ee9a78f..0495b387da 100644 --- a/.azuredevops/pipelineTemplates/jobs.publishModule.yml +++ b/.azuredevops/pipelineTemplates/jobs.publishModule.yml @@ -265,6 +265,7 @@ jobs: TemplateFilePath = $TemplateFilePath TemplateSpecsRGName = '${{ parameters.templateSpecsRgName }}' PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}') + UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') } Write-Verbose "Invoke Get-ModulesMissingFromTemplateSpecsRG with" -Verbose @@ -361,6 +362,7 @@ jobs: BicepRegistryName = '${{ parameters.bicepRegistryName }}' BicepRegistryRgName = '${{ parameters.bicepRegistryRgName }}' PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}') + UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') } Write-Verbose "Invoke Get-ModulesMissingFromPrivateBicepRegistry with" -Verbose diff --git a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromPrivateBicepRegistry.ps1 b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromPrivateBicepRegistry.ps1 index 124da5f51e..1174cea377 100644 --- a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromPrivateBicepRegistry.ps1 +++ b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromPrivateBicepRegistry.ps1 @@ -18,6 +18,11 @@ Mandatory. The name of Resource Group the Container Registry is located it. Optional. Publish an absolute latest version. Note: This version may include breaking changes and is not recommended for production environments +.PARAMETER UseApiAlignedName +Optional. If set to true, the module name looked for is aligned with the Azure API naming. If not, it's one aligned with the module's folder path. See the following examples: +- True: microsoft.keyvault.vaults.secrets +- False: key-vault.vault.secret + .EXAMPLE Get-ModulesMissingFromPrivateBicepRegistry -TemplateFilePath 'C:\ResourceModules\modules\compute\virtual-machine\main.bicep' -BicepRegistryName 'adpsxxazacrx001' -BicepRegistryRgName 'artifacts-rg' @@ -57,7 +62,10 @@ function Get-ModulesMissingFromPrivateBicepRegistry { [string] $BicepRegistryRgName, [Parameter(Mandatory = $false)] - [bool] $PublishLatest = $true + [bool] $PublishLatest = $true, + + [Parameter(Mandatory = $false)] + [bool] $UseApiAlignedName = $false ) begin { @@ -89,7 +97,7 @@ function Get-ModulesMissingFromPrivateBicepRegistry { foreach ($templatePath in $availableModuleTemplatePaths) { # Get a valid Container Registry name - $moduleRegistryIdentifier = Get-PrivateRegistryRepositoryName -TemplateFilePath $templatePath + $moduleRegistryIdentifier = Get-PrivateRegistryRepositoryName -TemplateFilePath $templatePath -UseApiAlignedName $UseApiAlignedName $null = Get-AzContainerRegistryTag -RepositoryName $moduleRegistryIdentifier -RegistryName $BicepRegistryName -ErrorAction 'SilentlyContinue' -ErrorVariable 'result' diff --git a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromTemplateSpecsRG.ps1 b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromTemplateSpecsRG.ps1 index 6cdfc1f879..228bebbfe1 100644 --- a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromTemplateSpecsRG.ps1 +++ b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromTemplateSpecsRG.ps1 @@ -15,6 +15,11 @@ Mandatory. The Resource Group to search in Optional. Publish an absolute latest version. Note: This version may include breaking changes and is not recommended for production environments +.PARAMETER UseApiAlignedName +Optional. If set to true, the module name looked for is aligned with the Azure API naming. If not, it's one aligned with the module's folder path. See the following examples: +- True: microsoft.keyvault.vaults.secrets +- False: key-vault.vault.secret + .EXAMPLE Get-ModulesMissingFromTemplateSpecsRG -TemplateFilePath 'C:\ResourceModules\modules\key-vault\vault\main.bicep' -TemplateSpecsRGName 'artifacts-rg' @@ -67,7 +72,10 @@ function Get-ModulesMissingFromTemplateSpecsRG { [string] $TemplateSpecsRGName, [Parameter(Mandatory = $false)] - [bool] $PublishLatest = $true + [bool] $PublishLatest = $true, + + [Parameter(Mandatory = $false)] + [bool] $UseApiAlignedName = $false ) begin { @@ -99,7 +107,7 @@ function Get-ModulesMissingFromTemplateSpecsRG { foreach ($templatePath in $availableModuleTemplatePaths) { # Get a valid Template Spec name - $templateSpecsIdentifier = Get-TemplateSpecsName -TemplateFilePath $templatePath + $templateSpecsIdentifier = Get-TemplateSpecsName -TemplateFilePath $templatePath -UseApiAlignedName $UseApiAlignedName $null = Get-AzTemplateSpec -ResourceGroupName $TemplateSpecsRGName -Name $templateSpecsIdentifier -ErrorAction 'SilentlyContinue' -ErrorVariable 'result' From 277710f016614f0408b1311067eadd46113091f5 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 18:16:32 +0200 Subject: [PATCH 23/31] Re-enabled tests --- .../pipelineTemplates/stages.module.yml | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.azuredevops/pipelineTemplates/stages.module.yml b/.azuredevops/pipelineTemplates/stages.module.yml index 4d5da957a0..4f7c3103ff 100644 --- a/.azuredevops/pipelineTemplates/stages.module.yml +++ b/.azuredevops/pipelineTemplates/stages.module.yml @@ -7,29 +7,29 @@ parameters: defaultJobTimeoutInMinutes: 120 stages: - # - stage: validation - # displayName: Static validation - # condition: eq('${{ parameters.staticValidation }}', 'True') - # jobs: - # - template: /.azuredevops/pipelineTemplates/jobs.validateModulePester.yml + - stage: validation + displayName: Static validation + condition: eq('${{ parameters.staticValidation }}', 'True') + jobs: + - template: /.azuredevops/pipelineTemplates/jobs.validateModulePester.yml - # - stage: deployment - # displayName: Deployment validation - # condition: and(eq('${{ parameters.deploymentValidation }}', 'True'), ne(dependencies.validation.result, 'Failed')) - # dependsOn: - # - validation - # jobs: - # - template: /.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml - # parameters: - # templateFilePath: '$(modulePath)/main.bicep' - # removeDeployment: '${{ parameters.removeDeployment }}' - # defaultJobTimeoutInMinutes: ${{ parameters.defaultJobTimeoutInMinutes }} + - stage: deployment + displayName: Deployment validation + condition: and(eq('${{ parameters.deploymentValidation }}', 'True'), ne(dependencies.validation.result, 'Failed')) + dependsOn: + - validation + jobs: + - template: /.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml + parameters: + templateFilePath: '$(modulePath)/main.bicep' + removeDeployment: '${{ parameters.removeDeployment }}' + defaultJobTimeoutInMinutes: ${{ parameters.defaultJobTimeoutInMinutes }} - stage: Publishing displayName: Publish module - # condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq('${{ parameters.prerelease }}', 'True'))) - # dependsOn: - # - validation - # - deployment + condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq('${{ parameters.prerelease }}', 'True'))) + dependsOn: + - validation + - deployment jobs: - template: /.azuredevops/pipelineTemplates/jobs.publishModule.yml From a380486e6295b104aaa5d4e1343cc7319e4e853c Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 18:32:50 +0200 Subject: [PATCH 24/31] Readme fixes --- modules/authorization/lock/resource-group/README.md | 2 +- modules/authorization/lock/subscription/README.md | 2 +- .../policy-assignment/management-group/README.md | 2 +- .../policy-assignment/resource-group/README.md | 2 +- .../authorization/policy-assignment/subscription/README.md | 2 +- .../policy-definition/management-group/README.md | 2 +- .../authorization/policy-definition/subscription/README.md | 2 +- .../policy-exemption/management-group/README.md | 2 +- .../policy-exemption/resource-group/README.md | 2 +- .../authorization/policy-exemption/subscription/README.md | 2 +- .../policy-set-definition/management-group/README.md | 2 +- .../policy-set-definition/subscription/README.md | 2 +- .../role-assignment/management-group/README.md | 2 +- .../authorization/role-assignment/resource-group/README.md | 2 +- .../authorization/role-assignment/subscription/README.md | 2 +- .../role-definition/management-group/README.md | 2 +- .../authorization/role-definition/resource-group/README.md | 2 +- .../authorization/role-definition/subscription/README.md | 2 +- utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 | 7 +++++++ 19 files changed, 25 insertions(+), 18 deletions(-) diff --git a/modules/authorization/lock/resource-group/README.md b/modules/authorization/lock/resource-group/README.md index 4be7ce8ce2..146e48ed25 100644 --- a/modules/authorization/lock/resource-group/README.md +++ b/modules/authorization/lock/resource-group/README.md @@ -1,4 +1,4 @@ -# Authorization Locks (Resource Group scope) `[Microsoft.Authorization/]` +# Authorization Locks (Resource Group scope) `[Microsoft.Authorization/locks]` This module deploys an Authorization Lock at a Resource Group scope. diff --git a/modules/authorization/lock/subscription/README.md b/modules/authorization/lock/subscription/README.md index 6295c60819..35fe0fd8ca 100644 --- a/modules/authorization/lock/subscription/README.md +++ b/modules/authorization/lock/subscription/README.md @@ -1,4 +1,4 @@ -# Authorization Locks (Subscription scope) `[Microsoft.Authorization/]` +# Authorization Locks (Subscription scope) `[Microsoft.Authorization/locks]` This module deploys an Authorization Lock at a Subscription scope. diff --git a/modules/authorization/policy-assignment/management-group/README.md b/modules/authorization/policy-assignment/management-group/README.md index a408f543ba..086b1d38ea 100644 --- a/modules/authorization/policy-assignment/management-group/README.md +++ b/modules/authorization/policy-assignment/management-group/README.md @@ -1,4 +1,4 @@ -# Policy Assignments (Management Group scope) `[Microsoft.Authorization/]` +# Policy Assignments (Management Group scope) `[Microsoft.Authorization/policyAssignments]` This module deploys a Policy Assignment at a Management Group scope. diff --git a/modules/authorization/policy-assignment/resource-group/README.md b/modules/authorization/policy-assignment/resource-group/README.md index f2336f7aae..6ed90b07ac 100644 --- a/modules/authorization/policy-assignment/resource-group/README.md +++ b/modules/authorization/policy-assignment/resource-group/README.md @@ -1,4 +1,4 @@ -# Policy Assignments (Resource Group scope) `[Microsoft.Authorization/]` +# Policy Assignments (Resource Group scope) `[Microsoft.Authorization/policyAssignments]` This module deploys a Policy Assignment at a Resource Group scope. diff --git a/modules/authorization/policy-assignment/subscription/README.md b/modules/authorization/policy-assignment/subscription/README.md index 505028a10e..26810db431 100644 --- a/modules/authorization/policy-assignment/subscription/README.md +++ b/modules/authorization/policy-assignment/subscription/README.md @@ -1,4 +1,4 @@ -# Policy Assignments (Subscription scope) `[Microsoft.Authorization/]` +# Policy Assignments (Subscription scope) `[Microsoft.Authorization/policyAssignments]` This module deploys a Policy Assignment at a Subscription scope. diff --git a/modules/authorization/policy-definition/management-group/README.md b/modules/authorization/policy-definition/management-group/README.md index fa0ce94b6c..01780427c6 100644 --- a/modules/authorization/policy-definition/management-group/README.md +++ b/modules/authorization/policy-definition/management-group/README.md @@ -1,4 +1,4 @@ -# Policy Definitions (Management Group scope) `[Microsoft.Authorization/]` +# Policy Definitions (Management Group scope) `[Microsoft.Authorization/policyDefinitions]` This module deploys a Policy Definition at a Management Group scope. diff --git a/modules/authorization/policy-definition/subscription/README.md b/modules/authorization/policy-definition/subscription/README.md index c665835085..2557236387 100644 --- a/modules/authorization/policy-definition/subscription/README.md +++ b/modules/authorization/policy-definition/subscription/README.md @@ -1,4 +1,4 @@ -# Policy Definitions (Subscription scope) `[Microsoft.Authorization/]` +# Policy Definitions (Subscription scope) `[Microsoft.Authorization/policyDefinitions]` This module deploys a Policy Definition at a Subscription scope. diff --git a/modules/authorization/policy-exemption/management-group/README.md b/modules/authorization/policy-exemption/management-group/README.md index 2a869122e7..1bfb787eab 100644 --- a/modules/authorization/policy-exemption/management-group/README.md +++ b/modules/authorization/policy-exemption/management-group/README.md @@ -1,4 +1,4 @@ -# Policy Exemptions (Management Group scope) `[Microsoft.Authorization/]` +# Policy Exemptions (Management Group scope) `[Microsoft.Authorization/policyExemptions]` This module deploys a Policy Exemption at a Management Group scope. diff --git a/modules/authorization/policy-exemption/resource-group/README.md b/modules/authorization/policy-exemption/resource-group/README.md index c1502237dc..7fd6faa68a 100644 --- a/modules/authorization/policy-exemption/resource-group/README.md +++ b/modules/authorization/policy-exemption/resource-group/README.md @@ -1,4 +1,4 @@ -# Policy Exemptions (Resource Group scope) `[Microsoft.Authorization/]` +# Policy Exemptions (Resource Group scope) `[Microsoft.Authorization/policyExemptions]` This module deploys a Policy Exemption at a Resource Group scope. diff --git a/modules/authorization/policy-exemption/subscription/README.md b/modules/authorization/policy-exemption/subscription/README.md index 5c5824449d..82e45d2349 100644 --- a/modules/authorization/policy-exemption/subscription/README.md +++ b/modules/authorization/policy-exemption/subscription/README.md @@ -1,4 +1,4 @@ -# Policy Exemptions (Subscription scope) `[Microsoft.Authorization/]` +# Policy Exemptions (Subscription scope) `[Microsoft.Authorization/policyExemptions]` This module deploys a Policy Exemption at a Subscription scope. diff --git a/modules/authorization/policy-set-definition/management-group/README.md b/modules/authorization/policy-set-definition/management-group/README.md index 31e45770bf..40de7bcd60 100644 --- a/modules/authorization/policy-set-definition/management-group/README.md +++ b/modules/authorization/policy-set-definition/management-group/README.md @@ -1,4 +1,4 @@ -# Policy Set Definitions (Initiatives) (Management Group scope) `[Microsoft.Authorization/]` +# Policy Set Definitions (Initiatives) (Management Group scope) `[Microsoft.Authorization/policySetDefinitions]` This module deploys a Policy Set Definition (Initiative) at a Management Group scope. diff --git a/modules/authorization/policy-set-definition/subscription/README.md b/modules/authorization/policy-set-definition/subscription/README.md index e5efdd02af..64b2597fe0 100644 --- a/modules/authorization/policy-set-definition/subscription/README.md +++ b/modules/authorization/policy-set-definition/subscription/README.md @@ -1,4 +1,4 @@ -# Policy Set Definitions (Initiatives) (Subscription scope) `[Microsoft.Authorization/]` +# Policy Set Definitions (Initiatives) (Subscription scope) `[Microsoft.Authorization/policySetDefinitions]` This module deploys a Policy Set Definition (Initiative) at a Subscription scope. diff --git a/modules/authorization/role-assignment/management-group/README.md b/modules/authorization/role-assignment/management-group/README.md index 4bdb71cf76..911ac2c8e6 100644 --- a/modules/authorization/role-assignment/management-group/README.md +++ b/modules/authorization/role-assignment/management-group/README.md @@ -1,4 +1,4 @@ -# Role Assignments (Management Group scope) `[Microsoft.Authorization/]` +# Role Assignments (Management Group scope) `[Microsoft.Authorization/roleAssignments]` This module deploys a Role Assignment at a Management Group scope. diff --git a/modules/authorization/role-assignment/resource-group/README.md b/modules/authorization/role-assignment/resource-group/README.md index 05ce2a6869..a2cd0959a5 100644 --- a/modules/authorization/role-assignment/resource-group/README.md +++ b/modules/authorization/role-assignment/resource-group/README.md @@ -1,4 +1,4 @@ -# Role Assignments (Resource Group scope) `[Microsoft.Authorization/]` +# Role Assignments (Resource Group scope) `[Microsoft.Authorization/roleAssignments]` This module deploys a Role Assignment at a Resource Group scope. diff --git a/modules/authorization/role-assignment/subscription/README.md b/modules/authorization/role-assignment/subscription/README.md index 15ec8204c2..58b5d059a4 100644 --- a/modules/authorization/role-assignment/subscription/README.md +++ b/modules/authorization/role-assignment/subscription/README.md @@ -1,4 +1,4 @@ -# Role Assignments (Subscription scope) `[Microsoft.Authorization/]` +# Role Assignments (Subscription scope) `[Microsoft.Authorization/roleAssignments]` This module deploys a Role Assignment at a Subscription scope. diff --git a/modules/authorization/role-definition/management-group/README.md b/modules/authorization/role-definition/management-group/README.md index 16e3277838..02a11b45bc 100644 --- a/modules/authorization/role-definition/management-group/README.md +++ b/modules/authorization/role-definition/management-group/README.md @@ -1,4 +1,4 @@ -# Role Definitions (Management Group scope) `[Microsoft.Authorization/]` +# Role Definitions (Management Group scope) `[Microsoft.Authorization/roleDefinitions]` This module deploys a Role Definition at a Management Group scope. diff --git a/modules/authorization/role-definition/resource-group/README.md b/modules/authorization/role-definition/resource-group/README.md index a5b665c745..924c4eb112 100644 --- a/modules/authorization/role-definition/resource-group/README.md +++ b/modules/authorization/role-definition/resource-group/README.md @@ -1,4 +1,4 @@ -# Role Definitions (Resource Group scope) `[Microsoft.Authorization/]` +# Role Definitions (Resource Group scope) `[Microsoft.Authorization/roleDefinitions]` This module deploys a Role Definition at a Resource Group scope. diff --git a/modules/authorization/role-definition/subscription/README.md b/modules/authorization/role-definition/subscription/README.md index 8531393c0d..3bbd9894b0 100644 --- a/modules/authorization/role-definition/subscription/README.md +++ b/modules/authorization/role-definition/subscription/README.md @@ -1,4 +1,4 @@ -# Role Definitions (Subscription scope) `[Microsoft.Authorization/]` +# Role Definitions (Subscription scope) `[Microsoft.Authorization/roleDefinitions]` This module deploys a Role Definition at a Subscription scope. diff --git a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 index 9fe61ae9c4..c853014f11 100644 --- a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 +++ b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 @@ -91,6 +91,13 @@ function Get-SpecsAlignedResourceName { $resourceTypeRegex = '^{0}(y|ii|e|ys|ies|es|s|)(\/|$)$' -f ($reducedResourceTypeElements -join '(y|ii|e|ys|ies|es|s|)(\/|$)') $resourceType = $innerResourceTypes | Where-Object { $_ -match $resourceTypeRegex } + # If no resource type is found, fall back one level (e.g., for 'authorization\role-definition\management-group' as 'management-group' in this context is no actual resource type) + if (-not $resourceType) { + $fallbackResourceTypeRegex = '{0}$' -f ($resourceTypeRegex -split $reducedResourceTypeElements[-1])[0] + $resourceType = $innerResourceTypes | Where-Object { $_ -match $fallbackResourceTypeRegex } + Write-Warning "Failed to find exact match between core matched resource types and [$reducedResourceType]. Fallback one level of for identifier [$resourceType]." + } + # Build result return "$providerNamespace/$resourceType" } From b26fa7066e74313885b46c645ffaf06925e90010 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 18:47:56 +0200 Subject: [PATCH 25/31] Readme fixes --- modules/compute/gallery/application/README.md | 2 +- modules/compute/gallery/image/README.md | 2 +- modules/container-registry/registry/replication/README.md | 2 +- modules/container-registry/registry/webhook/README.md | 2 +- modules/data-factory/factory/integration-runtime/README.md | 2 +- .../data-factory/factory/managed-virtual-network/README.md | 2 +- .../managed-private-endpoint/README.md | 2 +- utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 | 6 +++--- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/compute/gallery/application/README.md b/modules/compute/gallery/application/README.md index 987626e1d4..5c5b203c60 100644 --- a/modules/compute/gallery/application/README.md +++ b/modules/compute/gallery/application/README.md @@ -1,4 +1,4 @@ -# Compute Galleries Applications `[Microsoft.Compute/]` +# Compute Galleries Applications `[Microsoft.Compute/galleries/applications]` This module deploys an Azure Compute Gallery Application. diff --git a/modules/compute/gallery/image/README.md b/modules/compute/gallery/image/README.md index 23f4256ba1..2feab7d26a 100644 --- a/modules/compute/gallery/image/README.md +++ b/modules/compute/gallery/image/README.md @@ -1,4 +1,4 @@ -# Compute Galleries Image Definitions `[Microsoft.Compute/]` +# Compute Galleries Image Definitions `[Microsoft.Compute/galleries/images]` This module deploys an Azure Compute Gallery Image Definition. diff --git a/modules/container-registry/registry/replication/README.md b/modules/container-registry/registry/replication/README.md index 13214ba226..d8f012b3da 100644 --- a/modules/container-registry/registry/replication/README.md +++ b/modules/container-registry/registry/replication/README.md @@ -1,4 +1,4 @@ -# Azure Container Registry (ACR) Replications `[Microsoft.ContainerRegistry/]` +# Azure Container Registry (ACR) Replications `[Microsoft.ContainerRegistry/registries/replications]` This module deploys an Azure Container Registry (ACR) Replication. diff --git a/modules/container-registry/registry/webhook/README.md b/modules/container-registry/registry/webhook/README.md index 336c42b60b..4001b8a48a 100644 --- a/modules/container-registry/registry/webhook/README.md +++ b/modules/container-registry/registry/webhook/README.md @@ -1,4 +1,4 @@ -# Azure Container Registry (ACR) Webhooks `[Microsoft.ContainerRegistry/]` +# Azure Container Registry (ACR) Webhooks `[Microsoft.ContainerRegistry/registries/webhooks]` This module deploys an Azure Container Registry (ACR) Webhook. diff --git a/modules/data-factory/factory/integration-runtime/README.md b/modules/data-factory/factory/integration-runtime/README.md index dbd81b4a3f..8d15a01a4e 100644 --- a/modules/data-factory/factory/integration-runtime/README.md +++ b/modules/data-factory/factory/integration-runtime/README.md @@ -1,4 +1,4 @@ -# Data Factory Integration RunTimes `[Microsoft.DataFactory/]` +# Data Factory Integration RunTimes `[Microsoft.DataFactory/factories/integrationRuntimes]` This module deploys a Data Factory Managed or Self-Hosted Integration Runtime. diff --git a/modules/data-factory/factory/managed-virtual-network/README.md b/modules/data-factory/factory/managed-virtual-network/README.md index 8f79eceb16..d1da00c980 100644 --- a/modules/data-factory/factory/managed-virtual-network/README.md +++ b/modules/data-factory/factory/managed-virtual-network/README.md @@ -1,4 +1,4 @@ -# Data Factory Managed Virtual Networks `[Microsoft.DataFactory/]` +# Data Factory Managed Virtual Networks `[Microsoft.DataFactory/factories/managedVirtualNetworks]` This module deploys a Data Factory Managed Virtual Network. diff --git a/modules/data-factory/factory/managed-virtual-network/managed-private-endpoint/README.md b/modules/data-factory/factory/managed-virtual-network/managed-private-endpoint/README.md index 31a7424788..7d3631961a 100644 --- a/modules/data-factory/factory/managed-virtual-network/managed-private-endpoint/README.md +++ b/modules/data-factory/factory/managed-virtual-network/managed-private-endpoint/README.md @@ -1,4 +1,4 @@ -# Data Factory Managed Virtual Network Managed PrivateEndpoints `[Microsoft.DataFactory/]` +# Data Factory Managed Virtual Network Managed PrivateEndpoints `[Microsoft.DataFactory/factories/managedVirtualNetworks/managedPrivateEndpoints]` This module deploys a Data Factory Managed Virtual Network Managed Private Endpoint. diff --git a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 index c853014f11..33978f6ded 100644 --- a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 +++ b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 @@ -81,9 +81,9 @@ function Get-SpecsAlignedResourceName { # Find resource type $innerResourceTypes = $specs[$providerNamespace].Keys | Sort-Object - $reducedResourceType = Get-ReducedWordString -StringToReduce $rawResourceType - $reducedResourceTypeElements = $reducedResourceType -split '[\/|\\]' + $rawResourceTypeElem = $rawResourceType -split '[\/|\\]' + $reducedResourceTypeElements = $rawResourceTypeElem | ForEach-Object { Get-ReducedWordString -StringToReduce $_ } ## We built a regex that matches the resource type, but also the plural and singular form of it along its entire path. For example ^vault(y|ii|e|ys|ies|es|s|)(\/|$)key(y|ii|e|ys|ies|es|s|)(\/|$)$ ### (y|ii|e|ys|ies|es|s|) = Singular or plural form @@ -95,7 +95,7 @@ function Get-SpecsAlignedResourceName { if (-not $resourceType) { $fallbackResourceTypeRegex = '{0}$' -f ($resourceTypeRegex -split $reducedResourceTypeElements[-1])[0] $resourceType = $innerResourceTypes | Where-Object { $_ -match $fallbackResourceTypeRegex } - Write-Warning "Failed to find exact match between core matched resource types and [$reducedResourceType]. Fallback one level of for identifier [$resourceType]." + Write-Warning "Failed to find exact match between core matched resource types and [$reducedResourceType]. Fallback one level of for identifier [$rawResourceType]." } # Build result From b307dd32bcdd2a57c3f811234f7bf0b58b8cbd33 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 19:10:55 +0200 Subject: [PATCH 26/31] Readme fixes --- .../service/api/policy/README.md | 2 +- .../security/azure-security-center/README.md | 2 +- .../helper/Get-SpecsAlignedResourceName.ps1 | 19 ++++++++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/modules/api-management/service/api/policy/README.md b/modules/api-management/service/api/policy/README.md index 2efcedd723..3696e336ba 100644 --- a/modules/api-management/service/api/policy/README.md +++ b/modules/api-management/service/api/policy/README.md @@ -1,4 +1,4 @@ -# API Management Service APIs Policies `[Microsoft.ApiManagement/service/apis/policies service/apis/policy]` +# API Management Service APIs Policies `[Microsoft.ApiManagement/service/apis/policies]` This module deploys an API Management Service API Policy. diff --git a/modules/security/azure-security-center/README.md b/modules/security/azure-security-center/README.md index d132f0662b..8c53a2267f 100644 --- a/modules/security/azure-security-center/README.md +++ b/modules/security/azure-security-center/README.md @@ -1,4 +1,4 @@ -# Azure Security Center (Defender for Cloud) `[Microsoft.Security/azuresecuritycenter]` +# Azure Security Center (Defender for Cloud) `[Microsoft.Security/]` This module deploys an Azure Security Center (Defender for Cloud) Configuration. diff --git a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 index 33978f6ded..12483b3e98 100644 --- a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 +++ b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 @@ -88,14 +88,27 @@ function Get-SpecsAlignedResourceName { ## We built a regex that matches the resource type, but also the plural and singular form of it along its entire path. For example ^vault(y|ii|e|ys|ies|es|s|)(\/|$)key(y|ii|e|ys|ies|es|s|)(\/|$)$ ### (y|ii|e|ys|ies|es|s|) = Singular or plural form ### (\/|$) = End of string or another resource type level - $resourceTypeRegex = '^{0}(y|ii|e|ys|ies|es|s|)(\/|$)$' -f ($reducedResourceTypeElements -join '(y|ii|e|ys|ies|es|s|)(\/|$)') + $resourceTypeRegex = '^{0}(y|ii|e|ys|ies|es|s|ses|)(\/|$)$' -f ($reducedResourceTypeElements -join '(y|ii|e|ys|ies|es|s|ses|)(\/|$)') $resourceType = $innerResourceTypes | Where-Object { $_ -match $resourceTypeRegex } - # If no resource type is found, fall back one level (e.g., for 'authorization\role-definition\management-group' as 'management-group' in this context is no actual resource type) + # Special case handling: Ambiguous resource types (usually incorrect RP implementations) + if ($resourceType.count -gt 1) { + switch ($rawResourceType) { + 'service/api/policy' { + # Setting explicitely as both [apimanagement/service/apis/policies] & [apimanagement/service/apis/policy] exist in the specs and the later seem to have been an initial incorrect publish (only one API version exists) + $resourceType = 'service/apis/policies' + } + Default { + throw ('Found ambiguous resource types [{0}] for identifier [{1}]' -f ($resourceType -join ','), $rawResourceType) + } + } + } + + # Special case handling: If no resource type is found, fall back one level (e.g., for 'authorization\role-definition\management-group' as 'management-group' in this context is no actual resource type) if (-not $resourceType) { $fallbackResourceTypeRegex = '{0}$' -f ($resourceTypeRegex -split $reducedResourceTypeElements[-1])[0] $resourceType = $innerResourceTypes | Where-Object { $_ -match $fallbackResourceTypeRegex } - Write-Warning "Failed to find exact match between core matched resource types and [$reducedResourceType]. Fallback one level of for identifier [$rawResourceType]." + Write-Warning "Failed to find exact match between core matched resource types and [$rawResourceType]. Fallback one level up." } # Build result From 7679063bce31685758b54f70435d27b938079d07 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 1 Sep 2023 19:17:57 +0200 Subject: [PATCH 27/31] ReadMe Fixes --- modules/security/azure-security-center/README.md | 2 +- utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/security/azure-security-center/README.md b/modules/security/azure-security-center/README.md index 8c53a2267f..d132f0662b 100644 --- a/modules/security/azure-security-center/README.md +++ b/modules/security/azure-security-center/README.md @@ -1,4 +1,4 @@ -# Azure Security Center (Defender for Cloud) `[Microsoft.Security/]` +# Azure Security Center (Defender for Cloud) `[Microsoft.Security/azuresecuritycenter]` This module deploys an Azure Security Center (Defender for Cloud) Configuration. diff --git a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 index 12483b3e98..9e86e3000d 100644 --- a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 +++ b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 @@ -108,7 +108,13 @@ function Get-SpecsAlignedResourceName { if (-not $resourceType) { $fallbackResourceTypeRegex = '{0}$' -f ($resourceTypeRegex -split $reducedResourceTypeElements[-1])[0] $resourceType = $innerResourceTypes | Where-Object { $_ -match $fallbackResourceTypeRegex } - Write-Warning "Failed to find exact match between core matched resource types and [$rawResourceType]. Fallback one level up." + if (-not $resourceType) { + # if we still don't find anything (because the resource type straight up does not exist, we fall back to itself as the default) + Write-Warning "Resource type [$rawResourceType] does not exist in the API / is custom. Falling back to it as default." + $resourceType = $rawResourceType + } else { + Write-Warning "Failed to find exact match between core matched resource types and [$rawResourceType]. Fallback one level up." + } } # Build result From 72610f439231dffdf72632ab835899de49e4b7af Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Fri, 1 Sep 2023 23:47:01 +0200 Subject: [PATCH 28/31] Update utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 Co-authored-by: Ahmad Abdalla <28486158+ahmadabdalla@users.noreply.github.com> --- utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 index 2d678ccbaf..4a21b93695 100644 --- a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 @@ -63,7 +63,7 @@ function Get-TemplateSpecsName { } elseif ($stringToCheck.StartsWith($stringToRemove)) { # If the subsequent string starts with the current string, we want to remove the current string from the subsequent string. # So we take the index of the end of the current string, caculate the length until the end of the string and reduce. If a `-` was in between the 2 elements, we also want to trim it from the front. - # For example 'replication-protection-container' & 'replication-protection-container-mapping' shiuld become 'mapping' + # For example 'replication-protection-container' & 'replication-protection-container-mapping' should become 'mapping' $nameElems[($index + 1)] = $stringToCheck.Substring($stringToRemove.length, $stringToCheck.length - $stringToRemove.length).TrimStart('-') } } From 5f95afdbca558c072c6ed04d520ffc09df6edfbe Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sat, 2 Sep 2023 10:59:38 +0200 Subject: [PATCH 29/31] Renamed param to align --- .../pipelineTemplates/jobs.publishModule.yml | 48 +++++++++---------- .../templates/publishModule/action.yml | 8 ++-- .github/workflows/template.module.yml | 2 +- settings.yml | 2 +- ...ModulesMissingFromPrivateBicepRegistry.ps1 | 6 +-- .../Get-ModulesMissingFromTemplateSpecsRG.ps1 | 6 +-- ...dulesMissingFromUniversalArtifactsFeed.ps1 | 6 +-- .../Get-PrivateRegistryRepositoryName.ps1 | 6 +-- .../resourcePublish/Get-TemplateSpecsName.ps1 | 6 +-- .../Get-UniversalArtifactsName.ps1 | 6 +-- .../Publish-ModuleToPrivateBicepRegistry.ps1 | 6 +-- .../Publish-ModuleToTemplateSpecsRG.ps1 | 6 +-- ...Publish-ModuleToUniversalArtifactsFeed.ps1 | 6 +-- 13 files changed, 57 insertions(+), 57 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.publishModule.yml b/.azuredevops/pipelineTemplates/jobs.publishModule.yml index 0495b387da..5087e1244f 100644 --- a/.azuredevops/pipelineTemplates/jobs.publishModule.yml +++ b/.azuredevops/pipelineTemplates/jobs.publishModule.yml @@ -28,7 +28,7 @@ ## | defaultJobTimeoutInMinutes | 120 | The timeout for the job in this pipeline | 120 | ## | modulePath | '$(modulePath)' | The path to the module to deploy. E.g. [c:/KeyVault] | 'c:/KeyVault' | ## | publishLatest | '$(publishLatest)' | Flag to indicate whether or not to publish a "latest" version to Bicep Registry and Template Specs | true | -## | publishUsingApiAlignedName | '$(publishUsingApiAlignedName)' | Flag to indicate whether or not to publish module using their REST API, or their folder path name | true | +## | useApiSpecsAlignedName | '$(useApiSpecsAlignedName)' | Flag to indicate whether or not to publish module using their REST API, or their folder path name | true | ## | templateSpecsRGName | '$(templateSpecsRGName)' | Required to publish to template spec. ResourceGroup of the template spec to publish to | 'mgmt-rg' | ## | templateSpecsRGLocation | '$(templateSpecsRGLocation)' | Required to publish to template spec. Location of the template spec resource group | 'West Europe' | ## | templateSpecsDescription | '$(templateSpecsDescription)' | Required to publish to template spec. Description of the template spec to publish to | 'IaCs module' | @@ -61,7 +61,7 @@ parameters: # Shared publishLatest: '$(publishLatest)' - publishUsingApiAlignedName: '$(publishUsingApiAlignedName)' + useApiSpecsAlignedName: '$(useApiSpecsAlignedName)' ## TemplateSpec-related templateSpecsDoPublish: '$(templateSpecsDoPublish)' @@ -166,11 +166,11 @@ jobs: ############################# # Add all modules that don't exist in the target location $missingInputObject = @{ - TemplateFilePath = $TemplateFilePath - VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}' - VstsFeedProject = '${{ parameters.vstsFeedProject }}' - VstsFeedName = '${{ parameters.vstsFeedName }}' - UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') + TemplateFilePath = $TemplateFilePath + VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}' + VstsFeedProject = '${{ parameters.vstsFeedProject }}' + VstsFeedName = '${{ parameters.vstsFeedName }}' + UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ parameters.useApiSpecsAlignedName }}') } Write-Verbose "Invoke Get-ModulesMissingFromUniversalArtifactsFeed with" -Verbose @@ -192,12 +192,12 @@ jobs: Write-Host "##[group]$(' - [{0}] [{1}]' -f $RelPath, $moduleToPublish.Version)" $functionInput = @{ - TemplateFilePath = $moduleToPublish.TemplateFilePath - VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}' - VstsFeedProject = '${{ parameters.vstsFeedProject }}' - VstsFeedName = '${{ parameters.vstsFeedName }}' - ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') + TemplateFilePath = $moduleToPublish.TemplateFilePath + VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}' + VstsFeedProject = '${{ parameters.vstsFeedProject }}' + VstsFeedName = '${{ parameters.vstsFeedName }}' + ModuleVersion = $moduleToPublish.Version + UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ parameters.useApiSpecsAlignedName }}') } Write-Verbose "Invoke Publish-ModuleToUniversalArtifactsFeed with" -Verbose @@ -262,10 +262,10 @@ jobs: # Add all modules that don't exist in the target location $missingInputObject = @{ - TemplateFilePath = $TemplateFilePath - TemplateSpecsRGName = '${{ parameters.templateSpecsRgName }}' - PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}') - UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') + TemplateFilePath = $TemplateFilePath + TemplateSpecsRGName = '${{ parameters.templateSpecsRgName }}' + PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}') + UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ parameters.useApiSpecsAlignedName }}') } Write-Verbose "Invoke Get-ModulesMissingFromTemplateSpecsRG with" -Verbose @@ -292,7 +292,7 @@ jobs: TemplateSpecsRgLocation = '${{ parameters.templateSpecsRgLocation }}' TemplateSpecsDescription = '${{ parameters.templateSpecsDescription }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') + UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ parameters.useApiSpecsAlignedName }}') } Write-Verbose "Invoke Publish-ModuleToTemplateSpecsRG with" -Verbose @@ -358,11 +358,11 @@ jobs: ############################# # Add all modules that don't exist in the target location $missingInputObject = @{ - TemplateFilePath = $TemplateFilePath - BicepRegistryName = '${{ parameters.bicepRegistryName }}' - BicepRegistryRgName = '${{ parameters.bicepRegistryRgName }}' - PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}') - UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') + TemplateFilePath = $TemplateFilePath + BicepRegistryName = '${{ parameters.bicepRegistryName }}' + BicepRegistryRgName = '${{ parameters.bicepRegistryRgName }}' + PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}') + UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ parameters.useApiSpecsAlignedName }}') } Write-Verbose "Invoke Get-ModulesMissingFromPrivateBicepRegistry with" -Verbose @@ -389,7 +389,7 @@ jobs: BicepRegistryRgName = '${{ parameters.bicepRegistryRgName }}' BicepRegistryRgLocation = '${{ parameters.bicepRegistryRgLocation }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = [System.Convert]::ToBoolean('${{ parameters.publishUsingApiAlignedName }}') + UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ parameters.useApiSpecsAlignedName }}') } Write-Verbose "Invoke Publish-ModuleToPrivateBicepRegistry with" -Verbose diff --git a/.github/actions/templates/publishModule/action.yml b/.github/actions/templates/publishModule/action.yml index f6a409ec95..53f1415b7e 100644 --- a/.github/actions/templates/publishModule/action.yml +++ b/.github/actions/templates/publishModule/action.yml @@ -26,7 +26,7 @@ ## | bicepRegistryRgLocation | false | '' | Required to publish to private bicep registry. Location of the container registry resource group | 'WestEurope' | ## | bicepRegistryDoPublish | false | 'false' | Flag to indicate whether or not to publish to the private bicep registry | 'true' | ## | publishLatest | false | 'true' | Flag to indicate whether or not to publish a "latest" version | 'true' | -## | publishUsingApiAlignedName | false | 'false' | Flag to indicate whether or not to publish module using their REST API, or their folder path name | 'true' | +## | useApiSpecsAlignedName | false | 'false' | Flag to indicate whether or not to publish module using their REST API, or their folder path name | 'true' | ## |==============================================================================================================================================================================================================| ## ##---------------------------------------------## @@ -70,7 +70,7 @@ inputs: description: 'Flag to indicate whether or not to publish a "latest" version' default: 'true' required: false - publishUsingApiAlignedName: + useApiSpecsAlignedName: description: 'Flag to indicate whether or not to publish module using their REST API, or their folder path name' default: 'false' required: false @@ -154,7 +154,7 @@ runs: TemplateSpecsRgLocation = '${{ inputs.templateSpecsRgLocation }}' TemplateSpecsDescription = '${{ inputs.templateSpecsDescription }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = [System.Convert]::ToBoolean('${{ inputs.publishUsingApiAlignedName }}') + UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ inputs.useApiSpecsAlignedName }}') } Write-Verbose "Invoke task with" -Verbose @@ -235,7 +235,7 @@ runs: BicepRegistryRgName = '${{ inputs.bicepRegistryRgName }}' BicepRegistryRgLocation = '${{ inputs.bicepRegistryRgLocation }}' ModuleVersion = $moduleToPublish.Version - UseApiAlignedName = [System.Convert]::ToBoolean('${{ inputs.publishUsingApiAlignedName }}') + UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ inputs.useApiSpecsAlignedName }}') } Write-Verbose "Invoke task with" -Verbose diff --git a/.github/workflows/template.module.yml b/.github/workflows/template.module.yml index 6e547e19ec..d1dd1d4c4f 100644 --- a/.github/workflows/template.module.yml +++ b/.github/workflows/template.module.yml @@ -140,4 +140,4 @@ jobs: bicepRegistryRgLocation: '${{ env.bicepRegistryRgLocation }}' bicepRegistryDoPublish: '${{ env.bicepRegistryDoPublish }}' publishLatest: '${{ env.publishLatest }}' - publishUsingApiAlignedName: '${{ env.publishUsingApiAlignedName }}' + useApiSpecsAlignedName: '${{ env.useApiSpecsAlignedName }}' diff --git a/settings.yml b/settings.yml index 9f43ef6ba1..c96dbe1dc2 100644 --- a/settings.yml +++ b/settings.yml @@ -54,7 +54,7 @@ variables: # --------------- # publishLatest: true # [Only for Template-Specs & Bicep Registry] Publish an absolute latest version. Note: This version may include breaking changes and is not recommended for production environments - publishUsingApiAlignedName: false # Publish a module not using its folder path, but the matching name in the REST API (i.e., the classic naming). For example: `bicep/modules/microsoft.keyvault.vaults.secrets` instead of `bicep/modules/key-vault.vault.secret` + useApiSpecsAlignedName: false # Publish a module not using its folder path, but the matching name in the REST API (i.e., the classic naming). For example: `bicep/modules/microsoft.keyvault.vaults.secrets` instead of `bicep/modules/key-vault.vault.secret` # Template-Spec settings # # ---------------------- # diff --git a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromPrivateBicepRegistry.ps1 b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromPrivateBicepRegistry.ps1 index 1174cea377..c91319fa94 100644 --- a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromPrivateBicepRegistry.ps1 +++ b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromPrivateBicepRegistry.ps1 @@ -18,7 +18,7 @@ Mandatory. The name of Resource Group the Container Registry is located it. Optional. Publish an absolute latest version. Note: This version may include breaking changes and is not recommended for production environments -.PARAMETER UseApiAlignedName +.PARAMETER UseApiSpecsAlignedName Optional. If set to true, the module name looked for is aligned with the Azure API naming. If not, it's one aligned with the module's folder path. See the following examples: - True: microsoft.keyvault.vaults.secrets - False: key-vault.vault.secret @@ -65,7 +65,7 @@ function Get-ModulesMissingFromPrivateBicepRegistry { [bool] $PublishLatest = $true, [Parameter(Mandatory = $false)] - [bool] $UseApiAlignedName = $false + [bool] $UseApiSpecsAlignedName = $false ) begin { @@ -97,7 +97,7 @@ function Get-ModulesMissingFromPrivateBicepRegistry { foreach ($templatePath in $availableModuleTemplatePaths) { # Get a valid Container Registry name - $moduleRegistryIdentifier = Get-PrivateRegistryRepositoryName -TemplateFilePath $templatePath -UseApiAlignedName $UseApiAlignedName + $moduleRegistryIdentifier = Get-PrivateRegistryRepositoryName -TemplateFilePath $templatePath -UseApiSpecsAlignedName $UseApiSpecsAlignedName $null = Get-AzContainerRegistryTag -RepositoryName $moduleRegistryIdentifier -RegistryName $BicepRegistryName -ErrorAction 'SilentlyContinue' -ErrorVariable 'result' diff --git a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromTemplateSpecsRG.ps1 b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromTemplateSpecsRG.ps1 index 228bebbfe1..a71c7fe258 100644 --- a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromTemplateSpecsRG.ps1 +++ b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromTemplateSpecsRG.ps1 @@ -15,7 +15,7 @@ Mandatory. The Resource Group to search in Optional. Publish an absolute latest version. Note: This version may include breaking changes and is not recommended for production environments -.PARAMETER UseApiAlignedName +.PARAMETER UseApiSpecsAlignedName Optional. If set to true, the module name looked for is aligned with the Azure API naming. If not, it's one aligned with the module's folder path. See the following examples: - True: microsoft.keyvault.vaults.secrets - False: key-vault.vault.secret @@ -75,7 +75,7 @@ function Get-ModulesMissingFromTemplateSpecsRG { [bool] $PublishLatest = $true, [Parameter(Mandatory = $false)] - [bool] $UseApiAlignedName = $false + [bool] $UseApiSpecsAlignedName = $false ) begin { @@ -107,7 +107,7 @@ function Get-ModulesMissingFromTemplateSpecsRG { foreach ($templatePath in $availableModuleTemplatePaths) { # Get a valid Template Spec name - $templateSpecsIdentifier = Get-TemplateSpecsName -TemplateFilePath $templatePath -UseApiAlignedName $UseApiAlignedName + $templateSpecsIdentifier = Get-TemplateSpecsName -TemplateFilePath $templatePath -UseApiSpecsAlignedName $UseApiSpecsAlignedName $null = Get-AzTemplateSpec -ResourceGroupName $TemplateSpecsRGName -Name $templateSpecsIdentifier -ErrorAction 'SilentlyContinue' -ErrorVariable 'result' diff --git a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromUniversalArtifactsFeed.ps1 b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromUniversalArtifactsFeed.ps1 index e76bf4b750..1654e16d2c 100644 --- a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromUniversalArtifactsFeed.ps1 +++ b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromUniversalArtifactsFeed.ps1 @@ -20,7 +20,7 @@ Example: 'IaC'. Mandatory. Name to the feed to publish to. Example: 'Artifacts'. -.PARAMETER UseApiAlignedName +.PARAMETER UseApiSpecsAlignedName Optional. If set to true, the module name looked for is aligned with the Azure API naming. If not, it's one aligned with the module's folder path. See the following examples: - True: microsoft.keyvault.vaults.secrets - False: key-vault.vault.secret @@ -62,7 +62,7 @@ function Get-ModulesMissingFromUniversalArtifactsFeed { [string] $VstsFeedProject = '', [Parameter(Mandatory = $false)] - [bool] $UseApiAlignedName = $false, + [bool] $UseApiSpecsAlignedName = $false, [Parameter(Mandatory = $false)] [string] $BearerToken = $env:TOKEN @@ -112,7 +112,7 @@ function Get-ModulesMissingFromUniversalArtifactsFeed { foreach ($templatePath in $availableModuleTemplatePaths) { # Get a valid Universal Artifact name - $artifactsIdentifier = Get-UniversalArtifactsName -TemplateFilePath $templatePath -UseApiAlignedName $UseApiAlignedName + $artifactsIdentifier = Get-UniversalArtifactsName -TemplateFilePath $templatePath -UseApiSpecsAlignedName $UseApiSpecsAlignedName if ($publishedModules -notcontains $artifactsIdentifier) { $missingTemplatePaths += $templatePath diff --git a/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 b/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 index 32ff1a5da0..1b4070c6a6 100644 --- a/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 @@ -8,7 +8,7 @@ Convert the given template file path into a valid Container Registry repository .PARAMETER TemplateFilePath Mandatory. The template file path to convert -.PARAMETER UseApiAlignedName +.PARAMETER UseApiSpecsAlignedName Optional. If set to true, the returned name will be aligned with the Azure API naming. If not, the one aligned with the module's folder path. See the following examples: - True: bicep/modules/microsoft.keyvault.vaults.secrets - False: bicep/modules/key-vault.vault.secret @@ -26,12 +26,12 @@ function Get-PrivateRegistryRepositoryName { [string] $TemplateFilePath, [Parameter(Mandatory = $false)] - [bool] $UseApiAlignedName = $false + [bool] $UseApiSpecsAlignedName = $false ) $moduleIdentifier = (Split-Path $TemplateFilePath -Parent).Replace('\', '/').Split('/modules/')[1] - if ($UseApiAlignedName) { + if ($UseApiSpecsAlignedName) { # Load helper script . (Join-Path (Get-Item -Path $PSScriptRoot).Parent.Parent 'tools' 'helper' 'Get-SpecsAlignedResourceName.ps1') $moduleIdentifier = Get-SpecsAlignedResourceName -ResourceIdentifier $moduleIdentifier diff --git a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 index 4a21b93695..049d9f69a5 100644 --- a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 @@ -8,7 +8,7 @@ Convert the given template file path into a valid Template Specs repository name .PARAMETER TemplateFilePath Mandatory. The template file path to convert -.PARAMETER UseApiAlignedName +.PARAMETER UseApiSpecsAlignedName Optional. If set to true, the returned name will be aligned with the Azure API naming. If not, the one aligned with the module's folder path. See the following examples: - True: microsoft.keyvault.vaults.secrets - False: key-vault.vault.secret @@ -26,12 +26,12 @@ function Get-TemplateSpecsName { [string] $TemplateFilePath, [Parameter(Mandatory = $false)] - [bool] $UseApiAlignedName = $false + [bool] $UseApiSpecsAlignedName = $false ) $moduleIdentifier = (Split-Path $TemplateFilePath -Parent).Replace('\', '/').Split('/modules/')[1] - if ($UseApiAlignedName) { + if ($UseApiSpecsAlignedName) { # Load helper script . (Join-Path (Get-Item -Path $PSScriptRoot).Parent.Parent 'tools' 'helper' 'Get-SpecsAlignedResourceName.ps1') $moduleIdentifier = Get-SpecsAlignedResourceName -ResourceIdentifier $moduleIdentifier diff --git a/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 b/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 index 3458e1c459..9cc29a5091 100644 --- a/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 @@ -9,7 +9,7 @@ Must be lowercase alphanumerics, dashes, dots or underscores, under 256 characte .PARAMETER TemplateFilePath Mandatory. The template file path to convert -.PARAMETER UseApiAlignedName +.PARAMETER UseApiSpecsAlignedName Optional. If set to true, the returned name will be aligned with the Azure API naming. If not, the one aligned with the module's folder path. See the following examples: - True: microsoft.keyvault.vaults.secrets - False: key-vault.vault.secret @@ -27,13 +27,13 @@ function Get-UniversalArtifactsName { [string] $TemplateFilePath, [Parameter(Mandatory = $false)] - [bool] $UseApiAlignedName = $false + [bool] $UseApiSpecsAlignedName = $false ) $ModuleFolderPath = Split-Path $TemplateFilePath -Parent $universalPackageModuleName = $ModuleFolderPath.Replace('\', '/').Split('/modules/')[1] - if ($UseApiAlignedName) { + if ($UseApiSpecsAlignedName) { # Load helper script . (Join-Path (Get-Item -Path $PSScriptRoot).Parent.Parent 'tools' 'helper' 'Get-SpecsAlignedResourceName.ps1') $universalPackageModuleName = Get-SpecsAlignedResourceName -ResourceIdentifier $universalPackageModuleName diff --git a/utilities/pipelines/resourcePublish/Publish-ModuleToPrivateBicepRegistry.ps1 b/utilities/pipelines/resourcePublish/Publish-ModuleToPrivateBicepRegistry.ps1 index 8b018f6be8..220c245767 100644 --- a/utilities/pipelines/resourcePublish/Publish-ModuleToPrivateBicepRegistry.ps1 +++ b/utilities/pipelines/resourcePublish/Publish-ModuleToPrivateBicepRegistry.ps1 @@ -25,7 +25,7 @@ Example: 'artifacts-rg' Optional. The location of the resourceGroup the private bicep registry is deployed to. Required if the resource group is not yet existing. Example: 'West Europe' -.PARAMETER UseApiAlignedName +.PARAMETER UseApiSpecsAlignedName Optional. If set to true, the module will be published with a name that is aligned with the Azure API naming. If not, one aligned with the module's folder path. See the following examples: - True: bicep/modules/microsoft.keyvault.vaults.secrets - False: bicep/modules/key-vault.vault.secret @@ -55,7 +55,7 @@ function Publish-ModuleToPrivateBicepRegistry { [string] $BicepRegistryRgLocation, [Parameter(Mandatory = $false)] - [bool] $UseApiAlignedName = $false + [bool] $UseApiSpecsAlignedName = $false ) begin { @@ -88,7 +88,7 @@ function Publish-ModuleToPrivateBicepRegistry { } # Get a valid Container Registry name - $moduleRegistryIdentifier = Get-PrivateRegistryRepositoryName -TemplateFilePath $TemplateFilePath -UseApiAlignedName $UseApiAlignedName + $moduleRegistryIdentifier = Get-PrivateRegistryRepositoryName -TemplateFilePath $TemplateFilePath -UseApiSpecsAlignedName $UseApiSpecsAlignedName ############################################# ## Publish to private bicep registry ## diff --git a/utilities/pipelines/resourcePublish/Publish-ModuleToTemplateSpecsRG.ps1 b/utilities/pipelines/resourcePublish/Publish-ModuleToTemplateSpecsRG.ps1 index 868302881c..209033b84e 100644 --- a/utilities/pipelines/resourcePublish/Publish-ModuleToTemplateSpecsRG.ps1 +++ b/utilities/pipelines/resourcePublish/Publish-ModuleToTemplateSpecsRG.ps1 @@ -26,7 +26,7 @@ Example: 'West Europe' Mandatory. The description of the parent template spec. Example: 'iacs key vault' -.PARAMETER UseApiAlignedName +.PARAMETER UseApiSpecsAlignedName Optional. If set to true, the module will be published with a name that is aligned with the Azure API naming. If not, one aligned with the module's folder path. See the following examples: - True: microsoft.keyvault.vaults.secrets - False: key-vault.vault.secret @@ -56,7 +56,7 @@ function Publish-ModuleToTemplateSpecsRG { [string] $TemplateSpecsDescription, [Parameter(Mandatory = $false)] - [bool] $UseApiAlignedName = $false + [bool] $UseApiSpecsAlignedName = $false ) begin { @@ -77,7 +77,7 @@ function Publish-ModuleToTemplateSpecsRG { } # Get a valid Template Specs name - $templateSpecIdentifier = Get-TemplateSpecsName -TemplateFilePath $TemplateFilePath -UseApiAlignedName $UseApiAlignedName + $templateSpecIdentifier = Get-TemplateSpecsName -TemplateFilePath $TemplateFilePath -UseApiSpecsAlignedName $UseApiSpecsAlignedName ################################ ## Create template spec ## diff --git a/utilities/pipelines/resourcePublish/Publish-ModuleToUniversalArtifactsFeed.ps1 b/utilities/pipelines/resourcePublish/Publish-ModuleToUniversalArtifactsFeed.ps1 index 7d095a4169..c2705690fe 100644 --- a/utilities/pipelines/resourcePublish/Publish-ModuleToUniversalArtifactsFeed.ps1 +++ b/utilities/pipelines/resourcePublish/Publish-ModuleToUniversalArtifactsFeed.ps1 @@ -59,7 +59,7 @@ Example: 'Artifacts'. .PARAMETER BearerToken Optional. The bearer token to use to authenticate the request. If not provided it MUST be existing in your environment as `$env:TOKEN` -.PARAMETER UseApiAlignedName +.PARAMETER UseApiSpecsAlignedName Optional. If set to true, the module will be published with a name that is aligned with the Azure API naming. If not, one aligned with the module's folder path. See the following examples: - True: microsoft.keyvault.vaults.secrets - False: key-vault.vault.secret @@ -92,7 +92,7 @@ function Publish-ModuleToUniversalArtifactsFeed { [string] $ModuleVersion, [Parameter(Mandatory = $false)] - [bool] $UseApiAlignedName = $false + [bool] $UseApiSpecsAlignedName = $false ) begin { @@ -111,7 +111,7 @@ function Publish-ModuleToUniversalArtifactsFeed { ################################# ## Generate package name ## ################################# - $universalPackageModuleName = Get-UniversalArtifactsName -TemplateFilePath $TemplateFilePath -UseApiAlignedName $UseApiAlignedName + $universalPackageModuleName = Get-UniversalArtifactsName -TemplateFilePath $TemplateFilePath -UseApiSpecsAlignedName $UseApiSpecsAlignedName ########################### ## Find feed scope ## From 5f454b28366e44da50b5ceab7a69d0301ca50c7c Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sat, 2 Sep 2023 11:06:47 +0200 Subject: [PATCH 30/31] Added examples --- .../resourcePublish/Get-TemplateSpecsName.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 index 049d9f69a5..89777d6308 100644 --- a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 @@ -55,11 +55,11 @@ function Get-TemplateSpecsName { # For example: /virtualNetworks/ (plural) & /virtualNetworks/virtualNetworkPeerings/ (singular) # In this case we want to remove the singular version from the subsequent string & format it accordingly if ($stringToRemove.EndsWith('s') -and $stringToCheck.StartsWith($stringToRemove.Substring(0, $stringToRemove.length - 1))) { - $singularString = $stringToRemove.Substring(0, $stringToRemove.length - 1) - $rest = $stringToCheck.length - $singularString.Length - $shortenedString = $stringToCheck.Substring($singularString.length, $rest) - $camelCaseString = [Regex]::Replace($shortenedString , '\b.', { $args[0].Value.Tolower() }) - $nameElems[($index + 1)] = $camelCaseString + $singularString = $stringToRemove.Substring(0, $stringToRemove.length - 1) # Would be 'virtualNetwork' from the example above + $rest = $stringToCheck.length - $singularString.Length # Would be 8 from the example above + $shortenedString = $stringToCheck.Substring($singularString.length, $rest) # Would be 'peerings' from the example above + $camelCaseString = [Regex]::Replace($shortenedString , '\b.', { $args[0].Value.Tolower() }) # Would be 'peerings' from the example above + $nameElems[($index + 1)] = $camelCaseString # Would overwrite 'virtualnetworkpeerings' with 'peerings' from the example above } elseif ($stringToCheck.StartsWith($stringToRemove)) { # If the subsequent string starts with the current string, we want to remove the current string from the subsequent string. # So we take the index of the end of the current string, caculate the length until the end of the string and reduce. If a `-` was in between the 2 elements, we also want to trim it from the front. From db028b4d3a3ce5a8a1f96de81eb250df160f0bf4 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sat, 2 Sep 2023 11:15:44 +0200 Subject: [PATCH 31/31] Small update to verbosity --- utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 index 9e86e3000d..7cfab64e1d 100644 --- a/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 +++ b/utilities/tools/helper/Get-SpecsAlignedResourceName.ps1 @@ -113,7 +113,7 @@ function Get-SpecsAlignedResourceName { Write-Warning "Resource type [$rawResourceType] does not exist in the API / is custom. Falling back to it as default." $resourceType = $rawResourceType } else { - Write-Warning "Failed to find exact match between core matched resource types and [$rawResourceType]. Fallback one level up." + Write-Warning ('Failed to find exact match between core matched resource types and [{0}]. Fallback on [{1}].' -f $rawResourceType, (Split-Path $rawResourceType -Parent)) } }