Skip to content

Commit f328837

Browse files
committed
Fixes config compiler to always use Switchparameter for switch argument
1 parent 702cf87 commit f328837

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

doc/100-General/10-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1515

1616
### Bugfixes
1717

18+
* [#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
1819
* [#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
1920
* [#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)
2021
* [#785](https://github.com/Icinga/icinga-powershell-framework/issues/785) Fixes Icinga for Windows freezing during loading in case the `config.json` is empty

lib/core/tools/Get-IcingaCheckCommandConfig.psm1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,13 @@ function Get-IcingaCheckCommandConfig()
231231
[string]$Order = 99
232232
}
233233

234-
$IcingaCustomVariable = [string]::Format('${0}_{1}_{2}$', $PluginNameSpace, (Get-Culture).TextInfo.ToTitleCase($parameter.type.name), $parameter.Name);
234+
[string]$ParameterName = $parameter.type.name;
235+
236+
if ($ParameterName -eq 'SwitchParameter' -Or $ParameterName -eq 'Switch') {
237+
$ParameterName = 'SwitchParameter';
238+
}
239+
240+
$IcingaCustomVariable = [string]::Format('${0}_{1}_{2}$', $PluginNameSpace, (Get-Culture).TextInfo.ToTitleCase($ParameterName), $parameter.Name);
235241

236242
if ($IcingaCustomVariable.Length -gt 66) {
237243
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()
245251
}
246252

247253
# Add arguments to a given command
248-
if ($parameter.type.name -eq 'SwitchParameter') {
254+
if ($parameter.type.name -eq 'SwitchParameter' -Or $parameter.type.name -eq 'Switch') {
249255
$Basket.Command[$check].arguments.Add(
250256
[string]::Format('-{0}', $parameter.Name), @{
251257
'set_if' = $IcingaCustomVariable;
@@ -317,7 +323,7 @@ function Get-IcingaCheckCommandConfig()
317323
);
318324
}
319325

320-
if ($parameter.type.name -eq 'SwitchParameter') {
326+
if ($parameter.type.name -eq 'SwitchParameter' -Or $parameter.type.name -eq 'Switch') {
321327
$Basket.Command[$check].vars.ifw_api_arguments.Add([string]::Format('{0}', $parameter.Name), @{
322328
'set_if' = $IcingaCustomVariable;
323329
});
@@ -363,6 +369,8 @@ function Get-IcingaCheckCommandConfig()
363369
$IsDataList = $TRUE;
364370
} elseif ($parameter.type.name -eq 'SwitchParameter') {
365371
$IcingaDataType = 'Boolean';
372+
} elseif ($parameter.type.name -eq 'Switch') {
373+
$IcingaDataType = 'Boolean';
366374
} elseif ($parameter.type.name -eq 'Object') {
367375
$IcingaDataType = 'String';
368376
} elseif ($parameter.type.name -eq 'Array') {

0 commit comments

Comments
 (0)