Improved framework loading speed and overhead

This commit is contained in:
Lord Hepipud 2019-09-25 20:22:44 +02:00
parent 1c0844e5e7
commit 5499ff399b

View file

@ -13,6 +13,7 @@ function Use-Icinga()
{
# This function will allow us to load this entire module including possible
# actions, making it available within our shell environment
Import-IcingaLib '\' -Init;
}
function Import-IcingaLib()
@ -27,9 +28,16 @@ function Import-IcingaLib()
[String]$Lib,
# The Force Reload will remove the module in case it's loaded and reload it to track
# possible development changes without having to create new PowerShell environments
[Switch]$ForceReload
[Switch]$ForceReload,
[switch]$Init
);
# This is just to only allow a global loading of the module. Import-IcingaLib is ignored on every other
# location. It is just there to give a basic idea within commands, of which functions are used
if ($Init -eq $FALSE) {
return;
}
[string]$directory = Join-Path -Path $PSScriptRoot -ChildPath 'lib\';
[string]$module = Join-Path -Path $directory -ChildPath $Lib;
[string]$moduleName = '';
@ -38,6 +46,7 @@ function Import-IcingaLib()
# Load modules from directory
if ((Test-Path $module -PathType Container)) {
Get-ChildItem -Path $module -Recurse -Filter *.psm1 |
ForEach-Object {
[string]$modulePath = $_.FullName;
@ -344,9 +353,6 @@ function Get-Icinga-Object()
return $Icinga2;
}
# Automaticly load all library modules
Import-IcingaLib '\';
# Initialise base configuration for our module
<#
$Icinga2 = & (Join-Path -Path $PSScriptRoot -ChildPath '\core\init.ps1') `