Skip to content

Commit 8d36cb3

Browse files
committed
Add YAML Support for override config
1 parent 24a93fe commit 8d36cb3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/ALZ/Private/Get-ALZConfig.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@ function Get-ALZConfig {
1515

1616
# Import the config from the json file inside assets and transform it to a PowerShell object
1717
if ($configFilePath -ne "") {
18-
$config = Get-Content -Path $configFilePath | ConvertFrom-Json
18+
$extension = (Get-Item -Path $configFilePath).Extension.ToLower()
19+
if($extension -eq ".yml" -or $extension -eq ".yaml") {
20+
if (!(Get-Module -ListAvailable -Name powershell-Yaml)) {
21+
Write-Host "Installing YAML module"
22+
Install-Module powershell-Yaml -Force
23+
}
24+
$config = [PSCustomObject](Get-Content -Path $configFilePath | ConvertFrom-Yaml)
25+
} elseif($extension -eq ".json") {
26+
$config = Get-Content -Path $configFilePath | ConvertFrom-Json
27+
} else {
28+
throw "The config file must be a json or yaml file"
29+
}
30+
1931
return $config
2032
}
2133

0 commit comments

Comments
 (0)