Enhance configuration data validation and add new utility functions
- Added validation for empty values in Assert-ConfigurationDataParameter. - Introduced Assert-ConfigurationDataSecretReference for secret reference validation. - Implemented Test-ConfigurationDataExpressionParentheses to validate expression syntax. - Added Test-ConfigurationDataMissingReferenceError to check for missing parameter or variable definitions. - Updated Invoke-ConfigurationDataExpression to handle new validation logic. - Revised Readme.md to reflect changes in secret reference handling.
This commit is contained in:
@@ -23,12 +23,40 @@ function Invoke-ConfigurationDataExpression {
|
||||
return [bool]::Parse($Expression)
|
||||
}
|
||||
|
||||
if(-not (Test-ConfigurationDataExpressionParentheses -Expression $Expression)){
|
||||
throw "Invalid configuration data expression [$Expression]."
|
||||
}
|
||||
|
||||
if($Expression -notmatch "^([A-Za-z][A-Za-z0-9]*)\((.*)\)$"){
|
||||
throw "Invalid configuration data expression [$Expression]."
|
||||
}
|
||||
|
||||
$FunctionName = $Matches[1]
|
||||
$ArgumentText = $Matches[2]
|
||||
|
||||
if($FunctionName -ieq "coalesce"){
|
||||
$RawArguments = @(Split-ConfigurationDataExpressionArguments -ArgumentText $ArgumentText)
|
||||
Assert-ConfigurationDataExpressionMinimumArgumentCount -Name $FunctionName -Arguments $RawArguments -Count 1
|
||||
|
||||
foreach($Argument in $RawArguments){
|
||||
try {
|
||||
$Value = Invoke-ConfigurationDataExpressionArgument -Argument $Argument -Context $Context
|
||||
if(-not (Test-ConfigurationDataValueIsEmpty -Value $Value)){
|
||||
return $Value
|
||||
}
|
||||
}
|
||||
catch {
|
||||
if(Test-ConfigurationDataMissingReferenceError -ErrorRecord $_){
|
||||
continue
|
||||
}
|
||||
|
||||
throw
|
||||
}
|
||||
}
|
||||
|
||||
return $null
|
||||
}
|
||||
|
||||
$Arguments = @()
|
||||
foreach($Argument in @(Split-ConfigurationDataExpressionArguments -ArgumentText $ArgumentText)){
|
||||
$Arguments += ,(Invoke-ConfigurationDataExpressionArgument -Argument $Argument -Context $Context)
|
||||
|
||||
Reference in New Issue
Block a user