From bb22a882566f90d3dbac65f6e57654eadd2bfaea Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 22 Sep 2023 00:06:32 +0100 Subject: [PATCH] Fixed pipeline name fetch --- .../sharedScripts/Get-PipelineFileName.ps1 | 10 ++++------ .../staticValidation/module.tests.ps1 | 20 ++++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/avm/utilities/pipelines/sharedScripts/Get-PipelineFileName.ps1 b/avm/utilities/pipelines/sharedScripts/Get-PipelineFileName.ps1 index 329cb31135..af637547fd 100644 --- a/avm/utilities/pipelines/sharedScripts/Get-PipelineFileName.ps1 +++ b/avm/utilities/pipelines/sharedScripts/Get-PipelineFileName.ps1 @@ -10,12 +10,12 @@ If a child resource type is provided, the corresponding yml pipeline name is the Mandatory. The resource identifier to search for, i.e. the relative module file path starting from the resource provider folder. .EXAMPLE -Get-PipelineFileName -ResourceIdentifier 'storage/storage-account/blob-service/container/immutability-policy'. +Get-PipelineFileName -ResourceIdentifier 'avm/res/storage/storage-account/blob-service/container/immutability-policy'. Returns 'ms.storage.storageaccounts.yml'. .EXAMPLE -Get-PipelineFileName -ResourceIdentifier 'storage/storage-account'. +Get-PipelineFileName -ResourceIdentifier 'avm/res/storage/storage-account'. Returns 'ms.storage.storageaccounts.yml'. #> @@ -29,10 +29,8 @@ function Get-PipelineFileName { . (Join-Path $PSScriptRoot 'helper' 'Get-SpecsAlignedResourceName.ps1') - $provider, $parentType, $childTypeString = $ResourceIdentifier -split '[\/|\\]', 3 + $avm, $type, $provider, $parentType, $childTypeString = $ResourceIdentifier -split '[\/|\\]', 5 $parentResourceIdentifier = $provider, $parentType -join '/' - $formattedParentResourceType = Get-SpecsAlignedResourceName -ResourceIdentifier $parentResourceIdentifier - $pipelineFileName = '{0}.yml' -f (($formattedParentResourceType -replace 'Microsoft\.', 'ms.') -replace '\/', '.').ToLower() - + $pipelineFileName = ('{0}.{1}.{2}.yml' -f $avm, $type, ($parentResourceIdentifier -replace '\/', '.')).ToLower() return $pipelineFileName } diff --git a/avm/utilities/pipelines/staticValidation/module.tests.ps1 b/avm/utilities/pipelines/staticValidation/module.tests.ps1 index 0a3be0e471..a73006d095 100644 --- a/avm/utilities/pipelines/staticValidation/module.tests.ps1 +++ b/avm/utilities/pipelines/staticValidation/module.tests.ps1 @@ -156,21 +156,23 @@ Describe 'Pipeline tests' -Tag 'Pipeline' { foreach ($moduleFolderPath in $moduleFolderPaths) { $resourceTypeIdentifier = ($moduleFolderPath -split '[\/|\\]{1}avm[\/|\\]{1}(res|ptn)[\/|\\]{1}')[2] -replace '\\', '/' # avm/res// + $relativeModulePath = Join-Path 'avm' ($moduleFolderPath -split '[\/|\\]{1}avm[\/|\\]{1}')[1] $moduleFolderTestCases += @{ - moduleFolderName = $resourceTypeIdentifier - isTopLevelModule = ($resourceTypeIdentifier -split '[\/|\\]').Count -eq 2 + moduleFolderName = $resourceTypeIdentifier + relativeModulePath = $relativeModulePath + isTopLevelModule = ($resourceTypeIdentifier -split '[\/|\\]').Count -eq 2 } } It '[] Module should have a GitHub workflow.' -TestCases ($moduleFolderTestCases | Where-Object { $_.isTopLevelModule }) { param( - [string] $moduleFolderName + [string] $relativeModulePath ) $workflowsFolderName = Join-Path $repoRootPath '.github' 'workflows' - $workflowFileName = Get-PipelineFileName -ResourceIdentifier $moduleFolderName + $workflowFileName = Get-PipelineFileName -ResourceIdentifier $relativeModulePath $workflowPath = Join-Path $workflowsFolderName $workflowFileName Test-Path $workflowPath | Should -Be $true -Because "path [$workflowPath] should exist." } @@ -547,17 +549,17 @@ Describe 'Module tests' -Tag 'Module' { [string] $moduleFolderName, [hashtable] $templateContent ) - $enableDefaultTelemetryFlag = @() + $enableTelemetryFlag = @() $Schemaverion = $templateContent.'$schema' if ((($Schemaverion.Split('/')[5]).Split('.')[0]) -eq (($RGdeployment.Split('/')[5]).Split('.')[0])) { - if (($templateContent.resources.type -ccontains 'Microsoft.Resources/deployments' -and $templateContent.resources.condition -like "*[parameters('enableDefaultTelemetry')]*") -or ($templateContent.resources.resources.type -ccontains 'Microsoft.Resources/deployments' -and $templateContent.resources.resources.condition -like "*[parameters('enableDefaultTelemetry')]*")) { - $enableDefaultTelemetryFlag += $true + if (($templateContent.resources.type -ccontains 'Microsoft.Resources/deployments' -and $templateContent.resources.condition -like "*[parameters('enableTelemetry')]*") -or ($templateContent.resources.resources.type -ccontains 'Microsoft.Resources/deployments' -and $templateContent.resources.resources.condition -like "*[parameters('enableTelemetry')]*")) { + $enableTelemetryFlag += $true } else { - $enableDefaultTelemetryFlag += $false + $enableTelemetryFlag += $false } } - $enableDefaultTelemetryFlag | Should -Not -Contain $false + $enableTelemetryFlag | Should -Not -Contain $false } It '[] The Location should be defined as a parameter, with the default value of [resourceGroup().Location] or global for ResourceGroup deployment scope.' -TestCases $deploymentFolderTestCases {