Skip to content

Commit 28fad0a

Browse files
committed
Adds DSL parser to string arguments, fixing errors
1 parent e17c416 commit 28fad0a

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

lib/core/tools/Get-IcingaCheckCommandConfig.psm1

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ function Get-IcingaCheckCommandConfig()
216216
# Loop through parameters of a given command
217217
foreach ($parameter in $CheckParamList) {
218218

219-
$IsDataList = $FALSE;
219+
$IsDataList = $FALSE;
220220

221221
# IsNumeric-Check on position to determine the order-value
222222
If (Test-Numeric($parameter.position) -eq $TRUE) {
@@ -268,6 +268,26 @@ function Get-IcingaCheckCommandConfig()
268268
'order' = $Order;
269269
}
270270
);
271+
} elseif ($parameter.type.name -eq 'String') {
272+
# Conditional whether type of parameter is String
273+
$Basket.Command[$check].arguments.Add(
274+
[string]::Format('-{0}', $parameter.Name), @{
275+
'value' = @{
276+
'type' = 'Function';
277+
'body' = [string]::Format(
278+
'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}");',
279+
$IcingaCustomVariable,
280+
"`r`n",
281+
'{',
282+
'}',
283+
"'"
284+
);
285+
}
286+
'set_if' = [string]::Format('{{{{ var str = macro("{0}"); if (len(str) == 0) {{ return false; }} return true; }}}}', $IcingaCustomVariable);
287+
'set_if_format' = 'expression';
288+
'order' = $Order;
289+
}
290+
);
271291
} elseif ($parameter.type.name -eq 'SecureString') {
272292
# Convert out input string as SecureString
273293
$Basket.Command[$check].arguments.Add(

0 commit comments

Comments
 (0)