initial Commit
This commit is contained in:
32
Private/Resolve-ConfigurationDataVariable.ps1
Normal file
32
Private/Resolve-ConfigurationDataVariable.ps1
Normal file
@@ -0,0 +1,32 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user