Merge pull request #808 from Icinga:fix/config_compiler_always_using_switchparameter

Fix: Config compiler to always use Switchparameter for switch argument

Fixes Icinga for Windows config compiler to always use `Switchparameter` for `switch` data types, in case the documentation is not written properly for the plugin
This commit is contained in:
Lord Hepipud 2025-04-22 15:32:31 +02:00 committed by GitHub
commit c39ea59986
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View file

@ -17,6 +17,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
### Bugfixes
* [#753](https://github.com/Icinga/icinga-powershell-framework/issues/753) Fixes Icinga for Windows config compiler to always use `Switchparameter` for `switch` data types, in case the documentation is not written properly for the plugin
* [#781](https://github.com/Icinga/icinga-powershell-framework/issues/781) Fixes Icinga for Windows being stuck during installation while fetching service information over CIM-Instances, if other services are frozen, blocking the CIM-Request
* [#784](https://github.com/Icinga/icinga-powershell-framework/issues/784) Fixes Icinga for Windows threshold comparison which wrongly compared warning/critical thresholds for non-range values (like Match)
* [#785](https://github.com/Icinga/icinga-powershell-framework/issues/785) Fixes Icinga for Windows freezing during loading in case the `config.json` is empty

View file

@ -231,7 +231,13 @@ function Get-IcingaCheckCommandConfig()
[string]$Order = 99
}
$IcingaCustomVariable = [string]::Format('${0}_{1}_{2}$', $PluginNameSpace, (Get-Culture).TextInfo.ToTitleCase($parameter.type.name), $parameter.Name);
[string]$ParameterName = $parameter.type.name;
if ($ParameterName -eq 'SwitchParameter' -Or $ParameterName -eq 'Switch') {
$ParameterName = 'SwitchParameter';
}
$IcingaCustomVariable = [string]::Format('${0}_{1}_{2}$', $PluginNameSpace, (Get-Culture).TextInfo.ToTitleCase($ParameterName), $parameter.Name);
if ($IcingaCustomVariable.Length -gt 66) {
Write-IcingaConsoleError 'The generated custom variable name for the argument "{0}" and plugin "{1}" is too long. Custom variables are generated by combining the check function name, the datatype of the argument as well as the argument name itself. Please shorten your argument name and/or the check function name. The maximum size of generated custom variables is 64 digits. Current argument size: "{2}", generated custom variable name: "{3}"' -Objects $parameter.Name, $check, ($IcingaCustomVariable.Length - 2), $IcingaCustomVariable.Replace('$', '');
@ -245,7 +251,7 @@ function Get-IcingaCheckCommandConfig()
}
# Add arguments to a given command
if ($parameter.type.name -eq 'SwitchParameter') {
if ($parameter.type.name -eq 'SwitchParameter' -Or $parameter.type.name -eq 'Switch') {
$Basket.Command[$check].arguments.Add(
[string]::Format('-{0}', $parameter.Name), @{
'set_if' = $IcingaCustomVariable;
@ -317,7 +323,7 @@ function Get-IcingaCheckCommandConfig()
);
}
if ($parameter.type.name -eq 'SwitchParameter') {
if ($parameter.type.name -eq 'SwitchParameter' -Or $parameter.type.name -eq 'Switch') {
$Basket.Command[$check].vars.ifw_api_arguments.Add([string]::Format('{0}', $parameter.Name), @{
'set_if' = $IcingaCustomVariable;
});
@ -363,6 +369,8 @@ function Get-IcingaCheckCommandConfig()
$IsDataList = $TRUE;
} elseif ($parameter.type.name -eq 'SwitchParameter') {
$IcingaDataType = 'Boolean';
} elseif ($parameter.type.name -eq 'Switch') {
$IcingaDataType = 'Boolean';
} elseif ($parameter.type.name -eq 'Object') {
$IcingaDataType = 'String';
} elseif ($parameter.type.name -eq 'Array') {