From 01a4a806f31f24cc8ebdb1c27aa5f7b671ee81ec Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Tue, 12 Mar 2024 17:38:01 +0100 Subject: [PATCH] Adds support to create snapshot repositories with "New-IcingaRepository" --- doc/100-General/10-Changelog.md | 1 + lib/core/repository/New-IcingaRepository.psm1 | 5 +++-- lib/core/repository/New-IcingaRepositoryFile.psm1 | 9 +++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index b9cc4d0..3da98fb 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -20,6 +20,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic ### Enhancements +* [#587](https://github.com/Icinga/icinga-powershell-framework/issues/587) Adds support to create own snapshot repositories with `New-IcingaRepository` * [#631](https://github.com/Icinga/icinga-powershell-framework/pull/631) Deduplicates `-C try { Use-Icinga ...` boilerplate by adding it to the `PowerShell Base` template and removing it from every single command * [#679](https://github.com/Icinga/icinga-powershell-framework/pull/679) Adds a new data provider for fetching process information of Windows systems, while sorting all objects based on a process name and their process id * [#688](https://github.com/Icinga/icinga-powershell-framework/pull/688) Adds new handling to add scheduled tasks in Windows for interacting with Icinga for Windows core functionality as well as an auto renewal task for the Icinga for Windows certificate generation diff --git a/lib/core/repository/New-IcingaRepository.psm1 b/lib/core/repository/New-IcingaRepository.psm1 index 4668140..b169fa0 100644 --- a/lib/core/repository/New-IcingaRepository.psm1 +++ b/lib/core/repository/New-IcingaRepository.psm1 @@ -4,7 +4,8 @@ function New-IcingaRepository() [string]$Name = $null, [string]$Path = $null, [string]$RemotePath = $null, - [switch]$Force = $FALSE + [switch]$Force = $FALSE, + [switch]$Snapshot = $FALSE ); if ([string]::IsNullOrEmpty($Name)) { @@ -35,7 +36,7 @@ function New-IcingaRepository() return; } - $IcingaRepository = New-IcingaRepositoryFile -Path $Path -RemotePath $RemotePath -Name $Name; + $IcingaRepository = New-IcingaRepositoryFile -Path $Path -RemotePath $RemotePath -Name $Name -SnapshotFile:$Snapshot; [array]$ConfigCount = $IcingaRepository.Packages.PSObject.Properties.Count; diff --git a/lib/core/repository/New-IcingaRepositoryFile.psm1 b/lib/core/repository/New-IcingaRepositoryFile.psm1 index 9e10e56..8ca3db7 100644 --- a/lib/core/repository/New-IcingaRepositoryFile.psm1 +++ b/lib/core/repository/New-IcingaRepositoryFile.psm1 @@ -1,9 +1,10 @@ function New-IcingaRepositoryFile() { param ( - [string]$Path = $null, - [string]$RemotePath = $null, - [string]$Name = '' + [string]$Path = $null, + [string]$RemotePath = $null, + [string]$Name = '', + [switch]$SnapshotFile = $FALSE ); $RepoFile = 'ifw.repo.json'; @@ -57,7 +58,7 @@ function New-IcingaRepositoryFile() [bool]$IsSnapshot = $FALSE; - if ($entry.FullName.ToLower() -like '*\master.zip') { + if ($entry.FullName.ToLower() -like '*\master.zip' -Or $SnapshotFile) { $IsSnapshot = $TRUE; }