Skip to content

Commit

Permalink
Fixed pipeline name fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSehr committed Sep 21, 2023
1 parent c6f1b20 commit bb22a88
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
10 changes: 4 additions & 6 deletions avm/utilities/pipelines/sharedScripts/Get-PipelineFileName.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
#>
Expand All @@ -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
}
20 changes: 11 additions & 9 deletions avm/utilities/pipelines/staticValidation/module.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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/<provider>/<resourceType>
$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 '[<moduleFolderName>] 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."
}
Expand Down Expand Up @@ -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 '[<moduleFolderName>] The Location should be defined as a parameter, with the default value of [resourceGroup().Location] or global for ResourceGroup deployment scope.' -TestCases $deploymentFolderTestCases {
Expand Down

0 comments on commit bb22a88

Please sign in to comment.