From 0541fccc8595f3d5d8db44447a6758f33f428929 Mon Sep 17 00:00:00 2001 From: LordHepipud Date: Mon, 24 Jul 2023 23:07:55 +0200 Subject: [PATCH] Adds support to write the name of the repo inside the json file --- doc/100-General/10-Changelog.md | 1 + lib/core/repository/New-IcingaRepositoryFile.psm1 | 1 + lib/core/repository/Sync-IcingaRepository.psm1 | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index 0e43bae..7936ec0 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -25,6 +25,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic ### Enhancements * [#544](https://github.com/Icinga/icinga-powershell-framework/issues/544) Adds support to configure the Icinga Director JSON string for registering hosts via self-service API +* [#572](https://github.com/Icinga/icinga-powershell-framework/issues/572) Adds support to write the name of the repository synced/created into the local `ifw.repo.json` file * [#573](https://github.com/Icinga/icinga-powershell-framework/issues/573) Adds support to run command `icinga` with new argument `-NoNewInstance`, to use `-RebuildCache` as example to update the current PowerShell instance with all applied changes * [#619](https://github.com/Icinga/icinga-powershell-framework/pull/619) Adds feature to securely read enum provider values with new function `Get-IcingaProviderEnumData` * [#623](https://github.com/Icinga/icinga-powershell-framework/issues/623) Adds support to provide the Icinga service user written as `user@domain` diff --git a/lib/core/repository/New-IcingaRepositoryFile.psm1 b/lib/core/repository/New-IcingaRepositoryFile.psm1 index 2d6a013..9e10e56 100644 --- a/lib/core/repository/New-IcingaRepositoryFile.psm1 +++ b/lib/core/repository/New-IcingaRepositoryFile.psm1 @@ -13,6 +13,7 @@ function New-IcingaRepositoryFile() $IcingaRepository | Add-Member -MemberType NoteProperty -Name 'Info' -Value (New-Object -TypeName PSObject); # Info + $IcingaRepository.Info | Add-Member -MemberType NoteProperty -Name 'Name' -Value $Name; $IcingaRepository.Info | Add-Member -MemberType NoteProperty -Name 'LocalSource' -Value $Path; $IcingaRepository.Info | Add-Member -MemberType NoteProperty -Name 'RemoteSource' -Value $RemotePath; $IcingaRepository.Info | Add-Member -MemberType NoteProperty -Name 'Created' -Value ((Get-Date).ToUniversalTime().ToString('yyyy\/MM\/dd HH:mm:ss')); diff --git a/lib/core/repository/Sync-IcingaRepository.psm1 b/lib/core/repository/Sync-IcingaRepository.psm1 index 2995811..105963a 100644 --- a/lib/core/repository/Sync-IcingaRepository.psm1 +++ b/lib/core/repository/Sync-IcingaRepository.psm1 @@ -199,6 +199,12 @@ function Sync-IcingaRepository() Start-Sleep -Seconds 2; } + if ((Test-PSCustomObjectMember -PSObject $JsonRepo.Info -Name 'Name') -eq $FALSE) { + $JsonRepo.Info | Add-Member -MemberType NoteProperty -Name 'Name' -Value $Name; + } else { + $JsonRepo.Info.Name = $Name; + } + $JsonRepo.Info.RepoHash = Get-IcingaRepositoryHash -Path $TmpDir; $JsonRepo.Info.LocalSource = $Path; $JsonRepo.Info.RemoteSource = $RemotePath;