Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/100-General/10-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic

### 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
* [#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`
Expand Down
26 changes: 24 additions & 2 deletions lib/core/tools/Get-IcingaCheckCommandConfig.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function Get-IcingaCheckCommandConfig()
# Loop through parameters of a given command
foreach ($parameter in $CheckParamList) {

$IsDataList = $FALSE;
$IsDataList = $FALSE;

# IsNumeric-Check on position to determine the order-value
If (Test-Numeric($parameter.position) -eq $TRUE) {
Expand Down Expand Up @@ -268,6 +268,26 @@ function Get-IcingaCheckCommandConfig()
'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') {
# Convert out input string as SecureString
$Basket.Command[$check].arguments.Add(
Expand Down Expand Up @@ -528,9 +548,11 @@ function Write-IcingaPlainConfigurationFiles()
# Order is numeric -> no "" required
if ($argconfig -eq 'order') {
$StringFormater = ' {0} = {1}{2}';
} elseif ($argconfig -eq 'set_if' -And $CheckArgument[$argconfig] -Like '*var str = macro*') {
$StringFormater = ' {0} = {{{{{2} {1}{2} }}}}{2}';
} else {
# 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
Expand Down