Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/ALZ/Private/Tools/Test-Tooling.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ function Test-Tooling {
[CmdletBinding(SupportsShouldProcess = $true)]
param(
[Parameter(Mandatory = $false)]
[switch]$skipAlzModuleVersionCheck
[switch]$skipAlzModuleVersionCheck,
[Parameter(Mandatory = $false)]
[switch]$checkYamlModule
)

$checkResults = @()
Expand Down Expand Up @@ -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 @{
Expand Down
31 changes: 30 additions & 1 deletion src/ALZ/Public/Deploy-Accelerator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading