Merge pull request #519 from Icinga:fix/import_ifw_components_on_framework_loading

Fix: Missing loading for Icinga for Windows modules

Fixes missing loading of Icinga for Windows modules, which is required to ensure an Icinga for Windows environment is providing all commands and variables to a session, allowing other modules to access these information
This commit is contained in:
Lord Hepipud 2022-05-12 08:54:45 +02:00 committed by GitHub
commit 222a10fa84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 5 deletions

View file

@ -7,6 +7,14 @@ documentation before upgrading to a new release.
Released closed milestones can be found on [GitHub](https://github.com/Icinga/icinga-powershell-framework/milestones?state=closed).
## 1.9.1 (2022-05-13)
### Bugfixes
[Issue and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/24?closed=1)
* [#519](https://github.com/Icinga/icinga-powershell-framework/pull/519) Fixes missing loading of Icinga for Windows modules, which is required to ensure an Icinga for Windows environment is providing all commands and variables to a session, allowing other modules to access these information
## 1.9.0 (2022-05-03)
[Issue and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/20?closed=1)

View file

@ -28,11 +28,8 @@ function Use-Icinga()
$Global:Icinga.Protected.Minimal = $TRUE;
}
# Ensure we autoload the Icinga Plugin collection, provided by the external
# module 'icinga-powershell-plugins'
if (Get-Command 'Use-IcingaPlugins' -ErrorAction SilentlyContinue) {
Use-IcingaPlugins;
}
# Ensure we autoload Icinga for Windows modules into this session
Import-IcingaForWindowsModulesInSession;
if ($Daemon) {
$Global:Icinga.Protected.RunAsDaemon = $TRUE;
@ -64,6 +61,29 @@ function Use-Icinga()
}
}
function Import-IcingaForWindowsModulesInSession()
{
$CommandList = Get-Command 'Import-IcingaPowerShellComponent*';
foreach ($entry in $CommandList) {
$ModuleName = $entry.Module.Name;
$ModulePath = $entry.Module.Path;
$RootPath = $ModulePath.Substring(0, $ModulePath.IndexOf($ModuleName));
$Command = $entry.Name;
if ($RootPath.ToLower() -ne (Get-IcingaForWindowsRootPath).ToLower()) {
continue;
}
if ([string]::IsNullOrEmpty($Command) -Or (Test-IcingaFunction $Command) -eq $FALSE) {
continue;
}
# Execute the command if the module is located at the same location as our Framework
& $Command | Out-Null;
}
}
function Get-IcingaFrameworkCodeCacheFile()
{
return (Join-Path -Path (Get-IcingaCacheDir) -ChildPath 'framework_cache.psm1');