From 33aca914b4d6547f1901b7dccdc8eb00bc77cc15 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Mon, 1 Mar 2021 12:37:15 +0100 Subject: [PATCH] Fixes wrong variable used for API check request --- doc/31-Changelog.md | 1 + .../framework/Invoke-IcingaInternalServiceCall.psm1 | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/31-Changelog.md b/doc/31-Changelog.md index 2453f65b..67a49560 100644 --- a/doc/31-Changelog.md +++ b/doc/31-Changelog.md @@ -35,6 +35,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#213](https://github.com/Icinga/icinga-powershell-framework/pull/213) Fixed possible crash on `Get-IcingaAgentFeatures` if PowerShell is not running as administrator and therefor the command `icinga2 feature list` can not be processed * [#213](https://github.com/Icinga/icinga-powershell-framework/pull/213) Fixed `ConvertTo-IcingaSecureString` to return `$null` for empty strings instead of throwing an exception * [#214](https://github.com/Icinga/icinga-powershell-framework/pull/214) Fixes wrong `[Unknown] PluginNotInstalled` exception because of new plugin configuration and wrong checking against APi result in case feature is enabled +* [#215](https://github.com/Icinga/icinga-powershell-framework/pull/215) Fixes wrong used variable for arguments on API call checks ### Experimental diff --git a/lib/core/framework/Invoke-IcingaInternalServiceCall.psm1 b/lib/core/framework/Invoke-IcingaInternalServiceCall.psm1 index bb81ef47..22bde023 100644 --- a/lib/core/framework/Invoke-IcingaInternalServiceCall.psm1 +++ b/lib/core/framework/Invoke-IcingaInternalServiceCall.psm1 @@ -53,8 +53,6 @@ function Invoke-IcingaInternalServiceCall() Enable-IcingaUntrustedCertificateValidation -SuppressMessages; [hashtable]$CommandArguments = @{ }; - [hashtable]$DebugArguments = @{ }; - [hashtable]$ConvertedArgs = @{ }; [int]$ArgumentIndex = 0; # Resolve our array arguments provided by $args and build proper check arguments @@ -81,7 +79,7 @@ function Invoke-IcingaInternalServiceCall() $Argument = $Argument.Replace('-', ''); - $ConvertedArgs.Add($Argument, $ArgumentValue); + $CommandArguments.Add($Argument, $ArgumentValue); $ArgumentIndex += 1; } @@ -92,7 +90,7 @@ function Invoke-IcingaInternalServiceCall() # Something went wrong -> fallback to local execution $ExMsg = $_.Exception.message; # Fallback to execute plugin locally - Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects $ExMsg, $Command, $DebugArguments; + Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects $ExMsg, $Command, $CommandArguments; return; } @@ -102,12 +100,12 @@ function Invoke-IcingaInternalServiceCall() # In case we didn't receive a check result, fallback to local execution if ([string]::IsNullOrEmpty($IcingaResult.$Command.checkresult)) { - Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects 'The check result for the executed command was empty', $Command, $DebugArguments; + Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects 'The check result for the executed command was empty', $Command, $CommandArguments; return; } if ([string]::IsNullOrEmpty($IcingaResult.$Command.exitcode)) { - Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects 'The check result for the executed command was empty', $Command, $DebugArguments; + Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects 'The check result for the executed command was empty', $Command, $CommandArguments; return; }