Skip to content

Commit

Permalink
Get resources for all linked templates not just master
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwilliams committed Apr 29, 2024
1 parent 8f2f950 commit e410741
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,21 @@ try {
Write-Host "##[warning] The script is not compatible with your current PowerShell version $($PSVersionTable.PSVersion). Use either PowerShell Core or at least PS version 7.0, otherwise the script may fail to compare the trigger payload and always stop/start the trigger(s)"
}

$templateJson = Get-Content $ArmTemplate | ConvertFrom-Json
$resources = $templateJson.resources
if ($ArmTemplate.EndsWith("ArmTemplate_master.json")) {
$resources = @()
$templateFile = Get-ChildItem -Path $ArmTemplate
$linkedTemplateFiles = (Get-ChildItem -Path $templateFile.Directory.FullName -File -Filter "*.json").where({
(@("ArmTemplate_master.json", "ArmTemplateParameters_master.json") -inotcontains $PSItem.Name)
}
)
foreach ($linkedTemplateFile in $linkedTemplateFiles) {
$templateJson = Get-Content $linkedTemplateFile.FullName | ConvertFrom-Json
$resources += $templateJson.resources
}
} else {
$templateJson = Get-Content $ArmTemplate | ConvertFrom-Json
$resources = $templateJson.resources
}

if (-not $ArmTemplateParameters) {
$ArmTemplateParameters = Join-Path -Path (Split-Path $ArmTemplate -Parent) -ChildPath 'ArmTemplateParametersForFactory.json'
Expand Down

0 comments on commit e410741

Please sign in to comment.