mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Adds DSL parser to string arguments, fixing errors
This commit is contained in:
parent
a83d35e60e
commit
f126065cad
2 changed files with 25 additions and 2 deletions
|
|
@ -13,6 +13,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
|
* [#473](https://github.com/Icinga/icinga-powershell-framework/pull/473) Fixes an issue with current string rendering config implementation, as string values containing whitespaces or `$` are rendered wrong by default, if not set in single quotes `''`
|
||||||
* [#476](https://github.com/Icinga/icinga-powershell-framework/pull/476) Fixes exception `You cannot call a method on va null-valued expression` during installation in case no background daemon is configured
|
* [#476](https://github.com/Icinga/icinga-powershell-framework/pull/476) Fixes exception `You cannot call a method on va null-valued expression` during installation in case no background daemon is configured
|
||||||
* [#529](https://github.com/Icinga/icinga-powershell-framework/pull/529) Fixes package manifest reader for Icinga for Windows components on Windows 2012 R2 and older
|
* [#529](https://github.com/Icinga/icinga-powershell-framework/pull/529) Fixes package manifest reader for Icinga for Windows components on Windows 2012 R2 and older
|
||||||
* [#523](https://github.com/Icinga/icinga-powershell-framework/pull/523) Fixes errors on encapsulated PowerShell calls for missing Cmdlets `Write-IcingaConsoleError` and `Optimize-IcingaForWindowsMemory`
|
* [#523](https://github.com/Icinga/icinga-powershell-framework/pull/523) Fixes errors on encapsulated PowerShell calls for missing Cmdlets `Write-IcingaConsoleError` and `Optimize-IcingaForWindowsMemory`
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@ function Get-IcingaCheckCommandConfig()
|
||||||
# Loop through parameters of a given command
|
# Loop through parameters of a given command
|
||||||
foreach ($parameter in $CheckParamList) {
|
foreach ($parameter in $CheckParamList) {
|
||||||
|
|
||||||
$IsDataList = $FALSE;
|
$IsDataList = $FALSE;
|
||||||
|
|
||||||
# IsNumeric-Check on position to determine the order-value
|
# IsNumeric-Check on position to determine the order-value
|
||||||
If (Test-Numeric($parameter.position) -eq $TRUE) {
|
If (Test-Numeric($parameter.position) -eq $TRUE) {
|
||||||
|
|
@ -268,6 +268,26 @@ function Get-IcingaCheckCommandConfig()
|
||||||
'order' = $Order;
|
'order' = $Order;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
} elseif ($parameter.type.name -eq 'String') {
|
||||||
|
# Conditional whether type of parameter is String
|
||||||
|
$Basket.Command[$check].arguments.Add(
|
||||||
|
[string]::Format('-{0}', $parameter.Name), @{
|
||||||
|
'value' = @{
|
||||||
|
'type' = 'Function';
|
||||||
|
'body' = [string]::Format(
|
||||||
|
'var str = macro("{0}");{1}var argLen = len(str);{1}{1}if (argLen == 0) {2}{1} return;{1}{3}{1}{1}if (argLen != 0 && str.substr(0,1) == "{4}" && str.substr(argLen - 1, argLen) == "{4}") {2}{1} return str;{1}{3}{1}{1}return ("{4}" + str + "{4}");',
|
||||||
|
$IcingaCustomVariable,
|
||||||
|
"`r`n",
|
||||||
|
'{',
|
||||||
|
'}',
|
||||||
|
"'"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
'set_if' = [string]::Format('var str = macro("{0}"); if (len(str) == 0) {{ return false; }}; return true;', $IcingaCustomVariable);
|
||||||
|
'set_if_format' = 'expression';
|
||||||
|
'order' = $Order;
|
||||||
|
}
|
||||||
|
);
|
||||||
} elseif ($parameter.type.name -eq 'SecureString') {
|
} elseif ($parameter.type.name -eq 'SecureString') {
|
||||||
# Convert out input string as SecureString
|
# Convert out input string as SecureString
|
||||||
$Basket.Command[$check].arguments.Add(
|
$Basket.Command[$check].arguments.Add(
|
||||||
|
|
@ -528,9 +548,11 @@ function Write-IcingaPlainConfigurationFiles()
|
||||||
# Order is numeric -> no "" required
|
# Order is numeric -> no "" required
|
||||||
if ($argconfig -eq 'order') {
|
if ($argconfig -eq 'order') {
|
||||||
$StringFormater = ' {0} = {1}{2}';
|
$StringFormater = ' {0} = {1}{2}';
|
||||||
|
} elseif ($argconfig -eq 'set_if' -And $CheckArgument[$argconfig] -Like '*var str = macro*') {
|
||||||
|
$StringFormater = ' {0} = {{{{{2} {1}{2} }}}}{2}';
|
||||||
} else {
|
} else {
|
||||||
# All other entries should be handled as strings and contain ""
|
# All other entries should be handled as strings and contain ""
|
||||||
$StringFormater =' {0} = "{1}"{2}'
|
$StringFormater = ' {0} = "{1}"{2}'
|
||||||
}
|
}
|
||||||
|
|
||||||
# In case it is a hashtable, this is most likely a DSL function
|
# In case it is a hashtable, this is most likely a DSL function
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue