Skip to content

Commit c8e8683

Browse files
authored
Merge pull request #451 from Icinga:fix/jea_error_on_no_modules_and_output
Fix: JEA context cannot be created and command not found output Fixes the PowerShell not being able to enter the JEA context, if only the Icinga PowerShell Framework is installed and no other component like plugins being present. Fixes in addition the output for the JEA PowerShell, in case a check command cannot be executed. Previously the pipe `|` for performance data was always added, which is now gone.
2 parents 9bcd221 + 210862e commit c8e8683

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

doc/100-General/10-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
3232
* [#441](https://github.com/Icinga/icinga-powershell-framework/pull/441) Fixes an exception while loading the Framework, caused by a race condition for missing environment variables which are accessed by some plugins before the Framework is loaded properly
3333
* [#446](https://github.com/Icinga/icinga-powershell-framework/pull/446) Fixes Icinga for Windows progress preference, which sometimes caused UI glitches
3434
* [#449](https://github.com/Icinga/icinga-powershell-framework/pull/449) Fixes unhandled exception while importing modules during `Install-IcingaComponent` process, because of possible missing dependencies
35+
* [#451](https://github.com/Icinga/icinga-powershell-framework/pull/451) Fixes PowerShell being unable to enter JEA context if only the Framework is installed and removes the `|` from plugin output, in case a JEA error is thrown that check commands are not present
3536

3637
### Enhancements
3738

lib/core/jea/Get-IcingaJEAConfiguration.psm1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ function Get-IcingaJEAConfiguration()
154154
-CmdName 'Add-IcingaForWindowsDaemon' `
155155
-CmdType 'Function';
156156

157+
# Fixes error if only the Icinga PowerShell Framework is installed, which then causes JEA to fail entirely because of this missing Cmdlet
158+
$UsedCmdlets = Get-IcingaCommandDependency `
159+
-DependencyList $DependencyList `
160+
-CompiledList $UsedCmdlets `
161+
-CmdName 'Select-Object' `
162+
-CmdType 'Cmdlet';
163+
157164
# Finally loop through all commands again and build our JEA command list
158165
$DeserializedFile = Read-IcingaPowerShellModuleFile -FileContent $ModuleContent;
159166
[array]$JeaCmds = $DeserializedFile.CommandList + $DeserializedFile.FunctionList;

lib/icinga/plugin/Write-IcingaPluginResult.psm1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ function Write-IcingaPluginResult()
77

88
[string]$CheckResult = $PluginOutput;
99

10-
if ($PluginPerfData -ne 0) {
11-
$CheckResult += "`n`r| ";
10+
if ($PluginPerfData.Count -ne 0) {
11+
[string]$PerfDataContent = '';
1212
foreach ($PerfData in $PluginPerfData) {
13-
$CheckResult += $PerfData;
13+
$PerfDataContent += $PerfData;
14+
}
15+
16+
if ([string]::IsNullOrEmpty($PerfDataContent) -eq $FALSE) {
17+
$CheckResult += "`n`r| ";
18+
$CheckResult += $PerfDataContent;
1419
}
1520
}
1621

0 commit comments

Comments
 (0)