mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Fixes various code stylings and internal function namings
This commit is contained in:
parent
3bf87c2f2a
commit
76f27caba4
2 changed files with 40 additions and 35 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
@{
|
@{
|
||||||
ModuleToProcess = 'icinga-powershell-framework.psm1'
|
RootModule = 'icinga-powershell-framework.psm1'
|
||||||
ModuleVersion = '1.2.0'
|
ModuleVersion = '1.2.0'
|
||||||
GUID = 'fcd7a805-a41b-49f9-afee-9d17a2b76d42'
|
GUID = 'fcd7a805-a41b-49f9-afee-9d17a2b76d42'
|
||||||
Author = 'Lord Hepipud'
|
Author = 'Lord Hepipud'
|
||||||
|
|
@ -7,13 +7,25 @@
|
||||||
Copyright = '(c) 2020 Icinga GmbH | MIT'
|
Copyright = '(c) 2020 Icinga GmbH | MIT'
|
||||||
Description = 'Icinga for Windows module which allows to entirely monitor the Windows Host system.'
|
Description = 'Icinga for Windows module which allows to entirely monitor the Windows Host system.'
|
||||||
PowerShellVersion = '4.0'
|
PowerShellVersion = '4.0'
|
||||||
FunctionsToExport = @( '*' )
|
FunctionsToExport = @(
|
||||||
|
'Use-Icinga',
|
||||||
|
'Invoke-IcingaCommand',
|
||||||
|
'Import-IcingaLib',
|
||||||
|
'Publish-IcingaModuleManifest',
|
||||||
|
'Publish-IcingaEventlogDocumentation',
|
||||||
|
'Get-IcingaPluginDir',
|
||||||
|
'Get-IcingaCustomPluginDir',
|
||||||
|
'Get-IcingaCacheDir',
|
||||||
|
'Get-IcingaPowerShellConfigDir',
|
||||||
|
'Get-IcingaFrameworkRootPath',
|
||||||
|
'Get-IcingaPowerShellModuleFile'
|
||||||
|
)
|
||||||
CmdletsToExport = @()
|
CmdletsToExport = @()
|
||||||
VariablesToExport = '*'
|
VariablesToExport = '*'
|
||||||
AliasesToExport = @( '*' )
|
AliasesToExport = @( 'icinga' )
|
||||||
PrivateData = @{
|
PrivateData = @{
|
||||||
PSData = @{
|
PSData = @{
|
||||||
Tags = @( 'icinga','icinga2','IcingaPowerShellFramework','IcingaPowerShell','IcingaforWindows','IcingaWindows')
|
Tags = @( 'icinga', 'icinga2', 'IcingaPowerShellFramework', 'IcingaPowerShell', 'IcingaforWindows', 'IcingaWindows')
|
||||||
LicenseUri = 'https://github.com/Icinga/icinga-powershell-framework/blob/master/LICENSE'
|
LicenseUri = 'https://github.com/Icinga/icinga-powershell-framework/blob/master/LICENSE'
|
||||||
ProjectUri = 'https://github.com/Icinga/icinga-powershell-framework'
|
ProjectUri = 'https://github.com/Icinga/icinga-powershell-framework'
|
||||||
ReleaseNotes = 'https://github.com/Icinga/icinga-powershell-framework/releases'
|
ReleaseNotes = 'https://github.com/Icinga/icinga-powershell-framework/releases'
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Install-Icinga
|
Install-Icinga
|
||||||
.NOTES
|
.NOTES
|
||||||
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
function Use-Icinga()
|
function Use-Icinga()
|
||||||
|
|
@ -70,8 +69,8 @@ function Use-Icinga()
|
||||||
foreach ($entry in $EventLogMessages.Values) {
|
foreach ($entry in $EventLogMessages.Values) {
|
||||||
foreach ($event in $entry.Keys) {
|
foreach ($event in $entry.Keys) {
|
||||||
Add-IcingaHashtableItem -Hashtable $global:IcingaEventLogEnums `
|
Add-IcingaHashtableItem -Hashtable $global:IcingaEventLogEnums `
|
||||||
-Key $event `
|
-Key $event `
|
||||||
-Value $entry[$event] | Out-Null;
|
-Value $entry[$event] | Out-Null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -79,12 +78,6 @@ function Use-Icinga()
|
||||||
function Import-IcingaLib()
|
function Import-IcingaLib()
|
||||||
{
|
{
|
||||||
param(
|
param(
|
||||||
[Parameter(
|
|
||||||
Position=0,
|
|
||||||
Mandatory=$true,
|
|
||||||
ValueFromPipeline=$true,
|
|
||||||
ValueFromPipelineByPropertyName=$true)
|
|
||||||
]
|
|
||||||
[String]$Lib,
|
[String]$Lib,
|
||||||
# The Force Reload will remove the module in case it's loaded and reload it to track
|
# 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
|
# possible development changes without having to create new PowerShell environments
|
||||||
|
|
@ -114,22 +107,22 @@ function Import-IcingaLib()
|
||||||
if ((Test-Path $module -PathType Container)) {
|
if ((Test-Path $module -PathType Container)) {
|
||||||
|
|
||||||
Get-ChildItem -Path $module -Recurse -Filter *.psm1 |
|
Get-ChildItem -Path $module -Recurse -Filter *.psm1 |
|
||||||
ForEach-Object {
|
ForEach-Object {
|
||||||
[string]$modulePath = $_.FullName;
|
[string]$modulePath = $_.FullName;
|
||||||
$moduleName = $_.Name.Replace('.psm1', '');
|
$moduleName = $_.Name.Replace('.psm1', '');
|
||||||
|
|
||||||
if ($ListOfLoadedModules -like "*$moduleName*") {
|
if ($ListOfLoadedModules -like "*$moduleName*") {
|
||||||
if ($ForceReload) {
|
if ($ForceReload) {
|
||||||
Remove-Module -Name $moduleName
|
Remove-Module -Name $moduleName
|
||||||
|
Import-Module ([string]::Format('{0}', $modulePath)) -Global;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Import-Module ([string]::Format('{0}', $modulePath)) -Global;
|
Import-Module ([string]::Format('{0}', $modulePath)) -Global;
|
||||||
}
|
if ($WriteManifests) {
|
||||||
} else {
|
Publish-IcingaModuleManifest -Module $moduleName;
|
||||||
Import-Module ([string]::Format('{0}', $modulePath)) -Global;
|
}
|
||||||
if ($WriteManifests) {
|
|
||||||
Publish-IcingaModuleManifests -Module $moduleName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$module = $module.Replace('.psm1', ''); # Cut possible .psm1 ending
|
$module = $module.Replace('.psm1', ''); # Cut possible .psm1 ending
|
||||||
$moduleName = $module.Split('\')[-1]; # Get the last element
|
$moduleName = $module.Split('\')[-1]; # Get the last element
|
||||||
|
|
@ -142,12 +135,12 @@ function Import-IcingaLib()
|
||||||
|
|
||||||
Import-Module ([string]::Format('{0}.psm1', $module)) -Global;
|
Import-Module ([string]::Format('{0}.psm1', $module)) -Global;
|
||||||
if ($WriteManifests) {
|
if ($WriteManifests) {
|
||||||
Publish-IcingaModuleManifests -Module $moduleName;
|
Publish-IcingaModuleManifest -Module $moduleName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Publish-IcingaModuleManifests()
|
function Publish-IcingaModuleManifest()
|
||||||
{
|
{
|
||||||
param(
|
param(
|
||||||
[string]$Module
|
[string]$Module
|
||||||
|
|
@ -161,7 +154,7 @@ function Publish-IcingaModuleManifests()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
New-ModuleManifest -path $PSDFile -ModuleVersion 1.0 -Author $env:USERNAME -CompanyName 'Icinga GmbH' -Copyright '(c) 2019 Icinga GmbH. All rights reserved.' -PowerShellVersion 4.0;
|
New-ModuleManifest -Path $PSDFile -ModuleVersion 1.0 -Author $env:USERNAME -CompanyName 'Icinga GmbH' -Copyright '(c) 2019 Icinga GmbH. All rights reserved.' -PowerShellVersion 4.0;
|
||||||
$Content = Get-Content $PSDFile;
|
$Content = Get-Content $PSDFile;
|
||||||
$NewContent = @();
|
$NewContent = @();
|
||||||
|
|
||||||
|
|
@ -224,7 +217,7 @@ function Publish-IcingaEventlogDocumentation()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([string]::IsNullOrEmpty($OutFile)) {
|
if ([string]::IsNullOrEmpty($OutFile)) {
|
||||||
Write-Host $DocContent;
|
Write-Output $DocContent;
|
||||||
} else {
|
} else {
|
||||||
Set-Content -Path $OutFile -Value $DocContent;
|
Set-Content -Path $OutFile -Value $DocContent;
|
||||||
}
|
}
|
||||||
|
|
@ -279,10 +272,10 @@ function Invoke-IcingaCommand()
|
||||||
# Print a header informing our user that loaded the Icinga Framework with a specific
|
# Print a header informing our user that loaded the Icinga Framework with a specific
|
||||||
# version. We can also skip the header by using $SKipHeader
|
# version. We can also skip the header by using $SKipHeader
|
||||||
if ([string]::IsNullOrEmpty($ScriptBlock) -And $SkipHeader -eq $FALSE) {
|
if ([string]::IsNullOrEmpty($ScriptBlock) -And $SkipHeader -eq $FALSE) {
|
||||||
Write-Host '******************************************************';
|
Write-Output '******************************************************';
|
||||||
Write-Host ([string]::Format('** Icinga PowerShell Framework {0}', $IcingaFrameworkData.PrivateData.Version));
|
Write-Output ([string]::Format('** Icinga PowerShell Framework {0}', $IcingaFrameworkData.PrivateData.Version));
|
||||||
Write-Host ([string]::Format('** Copyright {0}', $IcingaFrameworkData.Copyright));
|
Write-Output ([string]::Format('** Copyright {0}', $IcingaFrameworkData.Copyright));
|
||||||
Write-Host '******************************************************';
|
Write-Output '******************************************************';
|
||||||
}
|
}
|
||||||
|
|
||||||
powershell.exe -NoExit -Command {
|
powershell.exe -NoExit -Command {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue