33 lines
874 B
PowerShell
33 lines
874 B
PowerShell
function Resolve-ConfigurationDataVariable {
|
|
[CmdletBinding()]
|
|
Param(
|
|
[Parameter(Mandatory=$true)]
|
|
[string]
|
|
$Name,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
$Context
|
|
)
|
|
|
|
if($Context.Variables.ContainsKey($Name)){
|
|
return $Context.Variables[$Name]
|
|
}
|
|
|
|
if(-not $Context.VariableDefinitions.ContainsKey($Name)){
|
|
throw "Variable [$Name] is not defined."
|
|
}
|
|
|
|
if($Context.ResolvingVariables.ContainsKey($Name)){
|
|
throw "Circular variable reference detected for variable [$Name]."
|
|
}
|
|
|
|
$Context.ResolvingVariables[$Name] = $true
|
|
try {
|
|
$Resolved = Resolve-ConfigurationDataValue -Value $Context.VariableDefinitions[$Name] -Context $Context
|
|
$Context.Variables[$Name] = $Resolved
|
|
return $Resolved
|
|
} finally {
|
|
$Context.ResolvingVariables.Remove($Name)
|
|
}
|
|
}
|