This commit is contained in:
@@ -9,7 +9,8 @@ Param(
|
||||
Throw "'$_' is not a valid filename (within working directory '$PWD'), or access denied; aborting."
|
||||
}
|
||||
})]
|
||||
[string]$OVFFile
|
||||
[string]$OVFFile,
|
||||
[hashtable]$Parameter
|
||||
)
|
||||
|
||||
$GetContentSplat = @{
|
||||
@@ -21,7 +22,24 @@ $ConvertFromYamlSplat = @{
|
||||
Yaml = $RawContent
|
||||
AllDocuments = $True
|
||||
}
|
||||
$OVFConfig = ConvertFrom-Yaml @ConvertFromYamlSplat
|
||||
$YamlDocuments = ConvertFrom-Yaml @ConvertFromYamlSplat
|
||||
|
||||
# Check if the respective .yml file declared substitutions which need to be parsed
|
||||
If (($YamlDocuments.Count -gt 1) -and $YamlDocuments[-1].Variables) {
|
||||
ForEach ($Pattern in $YamlDocuments[-1].Variables) {
|
||||
$RawContent = $RawContent -replace "\{\{ ($($Pattern.Name)) \}\}", [string](Invoke-Expression -Command $Pattern.Expression)
|
||||
}
|
||||
# Perform conversion to Yaml again, now with parsed file contents
|
||||
$ConvertFromYamlSplat = @{
|
||||
Yaml = $RawContent
|
||||
AllDocuments = $True
|
||||
}
|
||||
$YamlDocuments = ConvertFrom-Yaml @ConvertFromYamlSplat
|
||||
$OVFConfig = $YamlDocuments[0..($YamlDocuments.Count - 2)]
|
||||
}
|
||||
Else {
|
||||
$OVFConfig = $YamlDocuments
|
||||
}
|
||||
|
||||
$SourceFile = Get-Item -Path $OVFFile
|
||||
$GetContentSplat = @{
|
||||
|
Reference in New Issue
Block a user