From e17adcce54af03e980f6a3d5371c1dcc1de5c721 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 6 Jun 2023 14:52:32 +0200 Subject: [PATCH] Get-IcingaCheckCommandConfig: provide vars.ifw_api_arguments in each command to properly support just importing the ifw-api command. That command e.g. takes DSL/JSON arrays [], not PS ones @(). Similar with strings. Therefore set vars.ifw_api_arguments as ifw-api expects. --- lib/core/tools/Get-IcingaCheckCommandConfig.psm1 | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 b/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 index 2faee4f..fc75cbc 100644 --- a/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 +++ b/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 @@ -211,7 +211,9 @@ function Get-IcingaCheckCommandConfig() 'imports' = @( 'PowerShell Base' ); 'object_name' = $check; 'object_type' = 'object'; - 'vars' = @{ }; + 'vars' = @{ + 'ifw_api_arguments' = @{ }; + }; } ); @@ -313,6 +315,16 @@ function Get-IcingaCheckCommandConfig() ); } + if ($parameter.type.name -eq 'SwitchParameter') { + $Basket.Command[$check].vars.ifw_api_arguments.Add([string]::Format('-{0}', $parameter.Name), @{ + 'set_if' = $IcingaCustomVariable; + }); + } else { + $Basket.Command[$check].vars.ifw_api_arguments.Add([string]::Format('-{0}', $parameter.Name), @{ + 'value' = $IcingaCustomVariable; + }); + } + # Determine wether a parameter is required based on given syntax-information if ($parameter.required -eq $TRUE) { $Required = 'y';