Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/100-General/10-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions lib/core/tools/Get-IcingaCheckCommandConfig.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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('$', '');
Expand All @@ -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;
Expand Down Expand Up @@ -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;
});
Expand Down Expand Up @@ -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') {
Expand Down