From 09b9f23f7ede76c6b5c5459cc24d0490772dc521 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Tue, 23 Jul 2019 11:42:16 +0200 Subject: [PATCH] Fixed check initialising for AddCheck() on Check Packages --- lib/icinga/plugin/New-IcingaCheckPackage.psm1 | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/icinga/plugin/New-IcingaCheckPackage.psm1 b/lib/icinga/plugin/New-IcingaCheckPackage.psm1 index 6d51045..bc57f08 100644 --- a/lib/icinga/plugin/New-IcingaCheckPackage.psm1 +++ b/lib/icinga/plugin/New-IcingaCheckPackage.psm1 @@ -30,12 +30,20 @@ function New-IcingaCheckPackage() $Check | Add-Member -membertype ScriptMethod -name 'Initialise' -value { foreach ($check in $this.checks) { - $check.verbose = $this.verbose; - $check.AddSpacing(); - $check.SilentCompile(); + $this.InitCheck($check); } } + $Check | Add-Member -membertype ScriptMethod -name 'InitCheck' -value { + if ($null -eq $check) { + return; + } + + $check.verbose = $this.verbose; + $check.AddSpacing(); + $check.SilentCompile(); + } + $Check | Add-Member -membertype ScriptMethod -name 'AddSpacing' -value { $this.spacing += 1; foreach ($check in $this.checks) { @@ -47,6 +55,11 @@ function New-IcingaCheckPackage() $Check | Add-Member -membertype ScriptMethod -name 'AddCheck' -value { param($check); + if ($null -eq $check) { + return; + } + + $this.InitCheck($check); $this.checks += $check; }