diff --git a/src/ALZ/Private/Tools/Test-Tooling.ps1 b/src/ALZ/Private/Tools/Test-Tooling.ps1 index e3b18d6..904d262 100644 --- a/src/ALZ/Private/Tools/Test-Tooling.ps1 +++ b/src/ALZ/Private/Tools/Test-Tooling.ps1 @@ -2,7 +2,9 @@ function Test-Tooling { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $false)] - [switch]$skipAlzModuleVersionCheck + [switch]$skipAlzModuleVersionCheck, + [Parameter(Mandatory = $false)] + [switch]$checkYamlModule ) $checkResults = @() @@ -186,6 +188,24 @@ function Test-Tooling { } } + # Check if powershell-yaml module is installed (only when YAML files are being used) + if ($checkYamlModule.IsPresent) { + Write-Verbose "Checking powershell-yaml module installation" + $yamlModule = Get-Module -ListAvailable -Name powershell-yaml + if ($yamlModule) { + $checkResults += @{ + message = "powershell-yaml module is installed (version $($yamlModule.Version))." + result = "Success" + } + } else { + $checkResults += @{ + message = "powershell-yaml module is not installed. Please install it using 'Install-Module powershell-yaml -Force'." + result = "Failure" + } + $hasFailure = $true + } + } + Write-Verbose "Showing check results" Write-Verbose $(ConvertTo-Json $checkResults -Depth 100) $checkResults | ForEach-Object {[PSCustomObject]$_} | Format-Table -Property @{ diff --git a/src/ALZ/Public/Deploy-Accelerator.ps1 b/src/ALZ/Public/Deploy-Accelerator.ps1 index b752e3e..da457e2 100644 --- a/src/ALZ/Public/Deploy-Accelerator.ps1 +++ b/src/ALZ/Public/Deploy-Accelerator.ps1 @@ -171,11 +171,40 @@ function Deploy-Accelerator { $ProgressPreference = "SilentlyContinue" + # Determine if any input files are YAML to check for powershell-yaml module + $hasYamlFiles = $false + $pathsToCheck = @() + + if ($inputConfigFilePaths.Length -gt 0) { + $pathsToCheck = $inputConfigFilePaths + } else { + # Check environment variable if no paths provided + $envInputConfigPaths = $env:ALZ_input_config_path + if ($null -ne $envInputConfigPaths -and $envInputConfigPaths -ne "") { + $pathsToCheck = $envInputConfigPaths -split "," | Where-Object { $_ -and $_.Trim() } + } + } + + foreach ($path in $pathsToCheck) { + if ($null -ne $path -and $path.Trim() -ne "") { + try { + $extension = [System.IO.Path]::GetExtension($path).ToLower() + if ($extension -eq ".yml" -or $extension -eq ".yaml") { + $hasYamlFiles = $true + break + } + } catch { + # Ignore invalid paths - they will be caught later during config file validation + continue + } + } + } + if ($skip_requirements_check.IsPresent) { Write-InformationColored "WARNING: Skipping the software requirements check..." -ForegroundColor Yellow -InformationAction Continue } else { Write-InformationColored "Checking the software requirements for the Accelerator..." -ForegroundColor Green -InformationAction Continue - Test-Tooling -skipAlzModuleVersionCheck:$skip_alz_module_version_requirements_check.IsPresent + Test-Tooling -skipAlzModuleVersionCheck:$skip_alz_module_version_requirements_check.IsPresent -checkYamlModule:$hasYamlFiles } Write-InformationColored "Getting ready to deploy the accelerator with you..." -ForegroundColor Green -NewLineBefore -InformationAction Continue