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.
This commit is contained in:
Alexander A. Klimov 2023-06-06 14:52:32 +02:00
parent e06e781f39
commit e17adcce54

View file

@ -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';