From 484ca5d329a4d352511c025287bf2b8e4064d9cb Mon Sep 17 00:00:00 2001 From: Akash Gupta Date: Mon, 17 Aug 2026 16:46:13 +0530 Subject: [PATCH 1/2] Changes in Deploy-Accelerator script to support Bicep deployment package updates for SLZ --- .../Get-AcceleratorConfigPath.ps1 | 6 +++ .../New-Bootstrap.ps1 | 29 ++++++------ .../Public/New-AcceleratorFolderStructure.ps1 | 6 +-- .../Get-AcceleratorConfigPath.Tests.ps1 | 41 +++++++++++++++++ .../New-AcceleratorFolderStructure.Tests.ps1 | 44 +++++++++++++++++++ 5 files changed, 109 insertions(+), 17 deletions(-) create mode 100644 src/Tests/Unit/Private/Get-AcceleratorConfigPath.Tests.ps1 create mode 100644 src/Tests/Unit/Public/New-AcceleratorFolderStructure.Tests.ps1 diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-AcceleratorConfigPath.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-AcceleratorConfigPath.ps1 index ed566b94..5082536a 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-AcceleratorConfigPath.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-AcceleratorConfigPath.ps1 @@ -37,6 +37,12 @@ function Get-AcceleratorConfigPath { } "bicep" { $inputConfigFilePaths += "$ConfigFolderPath/platform-landing-zone.yaml" + foreach ($folderName in @("templates", ".config")) { + $folderPath = "$ConfigFolderPath/$folderName" + if (Test-Path $folderPath -PathType Container) { + $starterAdditionalFiles += $folderPath + } + } } # bicep-classic and others just use inputs.yaml } diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 index 1f1d30c3..54cd4381 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 @@ -241,20 +241,6 @@ function New-Bootstrap { } } - # Copy additional files - foreach ($additionalFile in $starterAdditionalFiles) { - if (Test-Path $additionalFile -PathType Container) { - $folderName = ([System.IO.DirectoryInfo]::new($additionalFile)).Name - $destination = Join-Path -Path $starterRootModuleFolderPath -ChildPath $folderName - Write-Verbose "Copying folder $additionalFile to $destination" - Copy-Item -Path "$additionalFile/*" -Destination $destination -Recurse -Force - } else { - $fileName = [System.IO.Path]::GetFileName($additionalFile) - $destination = Join-Path -Path $starterRootModuleFolderPath -ChildPath $fileName - Write-Verbose "Copying file $additionalFile to $destination" - Copy-Item -Path $additionalFile -Destination $destination -Force - } - } } if ($iac -like "bicep*") { @@ -282,6 +268,21 @@ function New-Bootstrap { Remove-UnrequiredFileSet -path $starterModulePath -foldersOrFilesToRetain $foldersOrFilesToRetain -subFoldersOrFilesToRemove $subFoldersOrFilesToRemove -writeVerboseLogs:$writeVerboseLogs.IsPresent } + # Copy additional files + foreach ($additionalFile in $starterAdditionalFiles) { + if (Test-Path $additionalFile -PathType Container) { + $folderName = ([System.IO.DirectoryInfo]::new($additionalFile)).Name + $destination = Join-Path -Path $starterRootModuleFolderPath -ChildPath $folderName + Write-Verbose "Copying folder $additionalFile to $destination" + Copy-Item -Path "$additionalFile/*" -Destination $destination -Recurse -Force + } else { + $fileName = [System.IO.Path]::GetFileName($additionalFile) + $destination = Join-Path -Path $starterRootModuleFolderPath -ChildPath $fileName + Write-Verbose "Copying file $additionalFile to $destination" + Copy-Item -Path $additionalFile -Destination $destination -Force + } + } + # Running terraform init and apply Write-ToConsoleLog "Thank you for providing those inputs, we are now initializing and applying Terraform to bootstrap your environment..." -IsSuccess diff --git a/src/ALZ/Public/New-AcceleratorFolderStructure.ps1 b/src/ALZ/Public/New-AcceleratorFolderStructure.ps1 index feb27201..8a94d0d2 100644 --- a/src/ALZ/Public/New-AcceleratorFolderStructure.ps1 +++ b/src/ALZ/Public/New-AcceleratorFolderStructure.ps1 @@ -83,12 +83,12 @@ function New-AcceleratorFolderStructure { "bicep" = @{ repoName = "alz-bicep-accelerator" - folderToClone = "" - libraryFolderPath = "" + folderToClone = "/" + libraryFolderPath = "templates" exampleFolderPath = "examples" bootstrapExampleFolderPath = "bootstrap" hasScenarios = $false - hasLibrary = $false + hasLibrary = $true platformLandingZoneFilePath = "platform-landing-zone.yaml" } diff --git a/src/Tests/Unit/Private/Get-AcceleratorConfigPath.Tests.ps1 b/src/Tests/Unit/Private/Get-AcceleratorConfigPath.Tests.ps1 new file mode 100644 index 00000000..aa07d4a9 --- /dev/null +++ b/src/Tests/Unit/Private/Get-AcceleratorConfigPath.Tests.ps1 @@ -0,0 +1,41 @@ +#------------------------------------------------------------------------- +Set-Location -Path $PSScriptRoot +#------------------------------------------------------------------------- +$ModuleName = 'ALZ' +$PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1") +#------------------------------------------------------------------------- +if (Get-Module -Name $ModuleName -ErrorAction 'SilentlyContinue') { + Remove-Module -Name $ModuleName -Force +} +Import-Module $PathToManifest -Force +#------------------------------------------------------------------------- + +InModuleScope 'ALZ' { + Describe 'Get-AcceleratorConfigPath Function Tests' -Tag Unit { + It 'returns the bicep configuration files and existing additional folders' { + $configFolderPath = Join-Path $TestDrive 'config' + New-Item -Path (Join-Path $configFolderPath 'templates') -ItemType Directory -Force | Out-Null + New-Item -Path (Join-Path $configFolderPath '.config') -ItemType Directory -Force | Out-Null + + $result = Get-AcceleratorConfigPath -ConfigFolderPath $configFolderPath -IacType 'bicep' + + $result.InputConfigFilePaths | Should -Be @( + "$configFolderPath/inputs.yaml" + "$configFolderPath/platform-landing-zone.yaml" + ) + $result.StarterAdditionalFiles | Should -Be @( + "$configFolderPath/templates" + "$configFolderPath/.config" + ) + } + + It 'does not return missing bicep additional folders' { + $configFolderPath = Join-Path $TestDrive 'config-without-additional-folders' + New-Item -Path $configFolderPath -ItemType Directory -Force | Out-Null + + $result = Get-AcceleratorConfigPath -ConfigFolderPath $configFolderPath -IacType 'bicep' + + $result.StarterAdditionalFiles | Should -BeNullOrEmpty + } + } +} \ No newline at end of file diff --git a/src/Tests/Unit/Public/New-AcceleratorFolderStructure.Tests.ps1 b/src/Tests/Unit/Public/New-AcceleratorFolderStructure.Tests.ps1 new file mode 100644 index 00000000..3b30b267 --- /dev/null +++ b/src/Tests/Unit/Public/New-AcceleratorFolderStructure.Tests.ps1 @@ -0,0 +1,44 @@ +#------------------------------------------------------------------------- +Set-Location -Path $PSScriptRoot +#------------------------------------------------------------------------- +$ModuleName = 'ALZ' +$PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1") +#------------------------------------------------------------------------- +if (Get-Module -Name $ModuleName -ErrorAction 'SilentlyContinue') { + Remove-Module -Name $ModuleName -Force +} +Import-Module $PathToManifest -Force +#------------------------------------------------------------------------- + +InModuleScope 'ALZ' { + Describe 'New-AcceleratorFolderStructure Function Tests' -Tag Unit { + BeforeEach { + $script:copyOperations = @() + Mock -CommandName git + Mock -CommandName Copy-Item -MockWith { + $script:copyOperations += [pscustomobject]@{ + Path = $Path + Destination = $Destination + Recurse = $Recurse.IsPresent + Force = $Force.IsPresent + } + } + Mock -CommandName Write-ToConsoleLog + } + + It 'copies bicep templates into the generated config folder' { + $targetFolderPath = Join-Path $TestDrive 'accelerator' + + New-AcceleratorFolderStructure -iacType 'bicep' -targetFolderPath $targetFolderPath + + $templateCopy = $script:copyOperations | Where-Object { + $_.Path -match '[/\\]templates$' + } + $templateCopy.Path | Should -HaveCount 1 + [System.IO.Path]::GetFileName($templateCopy.Path) | Should -Be 'templates' + $templateCopy.Destination | Should -Be "$targetFolderPath/config" + $templateCopy.Recurse | Should -BeTrue + $templateCopy.Force | Should -BeTrue + } + } +} \ No newline at end of file From 3a5994be840db5cf633915ed58560800ff23fde3 Mon Sep 17 00:00:00 2001 From: Akash Gupta Date: Tue, 18 Aug 2026 16:37:12 +0530 Subject: [PATCH 2/2] Linting changes --- src/Tests/Unit/Private/Get-AcceleratorConfigPath.Tests.ps1 | 2 +- src/Tests/Unit/Public/New-AcceleratorFolderStructure.Tests.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tests/Unit/Private/Get-AcceleratorConfigPath.Tests.ps1 b/src/Tests/Unit/Private/Get-AcceleratorConfigPath.Tests.ps1 index aa07d4a9..91f4b14a 100644 --- a/src/Tests/Unit/Private/Get-AcceleratorConfigPath.Tests.ps1 +++ b/src/Tests/Unit/Private/Get-AcceleratorConfigPath.Tests.ps1 @@ -38,4 +38,4 @@ InModuleScope 'ALZ' { $result.StarterAdditionalFiles | Should -BeNullOrEmpty } } -} \ No newline at end of file +} diff --git a/src/Tests/Unit/Public/New-AcceleratorFolderStructure.Tests.ps1 b/src/Tests/Unit/Public/New-AcceleratorFolderStructure.Tests.ps1 index 3b30b267..68178847 100644 --- a/src/Tests/Unit/Public/New-AcceleratorFolderStructure.Tests.ps1 +++ b/src/Tests/Unit/Public/New-AcceleratorFolderStructure.Tests.ps1 @@ -41,4 +41,4 @@ InModuleScope 'ALZ' { $templateCopy.Force | Should -BeTrue } } -} \ No newline at end of file +}