Merge pull request #548 from Icinga:fix/update_repository_resets_remote_path

Fix: RemoteSouce being cleared during Update-IcingaRepository

Fixes `RemoteSource` being cleared within repository `.json` files during `Update-IcingaRepository` tasks
This commit is contained in:
Lord Hepipud 2022-08-18 14:04:30 +02:00 committed by GitHub
commit a4d1971114
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -19,6 +19,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#529](https://github.com/Icinga/icinga-powershell-framework/pull/529) Fixes package manifest reader for Icinga for Windows components on Windows 2012 R2 and older * [#529](https://github.com/Icinga/icinga-powershell-framework/pull/529) Fixes package manifest reader for Icinga for Windows components on Windows 2012 R2 and older
* [#523](https://github.com/Icinga/icinga-powershell-framework/pull/523) Fixes errors on encapsulated PowerShell calls for missing Cmdlets `Write-IcingaConsoleError` and `Optimize-IcingaForWindowsMemory` * [#523](https://github.com/Icinga/icinga-powershell-framework/pull/523) Fixes errors on encapsulated PowerShell calls for missing Cmdlets `Write-IcingaConsoleError` and `Optimize-IcingaForWindowsMemory`
* [#524](https://github.com/Icinga/icinga-powershell-framework/issues/524) Fixes uninstallation process by improving the location handling of PowerShell instances with Icinga IMC or Shell * [#524](https://github.com/Icinga/icinga-powershell-framework/issues/524) Fixes uninstallation process by improving the location handling of PowerShell instances with Icinga IMC or Shell
* [#545](https://github.com/Icinga/icinga-powershell-framework/issues/545) Fixes `RemoteSource` being cleared within repository `.json` files during `Update-IcingaRepository` tasks
### Enhancements ### Enhancements

View file

@ -59,7 +59,15 @@ function Update-IcingaRepository()
Write-IcingaConsoleNotice 'Updating Icinga for Windows repository "{0}"' -Objects $definedRepo.Name; Write-IcingaConsoleNotice 'Updating Icinga for Windows repository "{0}"' -Objects $definedRepo.Name;
} }
$IcingaRepository = New-IcingaRepositoryFile -Path $Path -RemotePath $RemotePath; # Ensure we use the default RemotePath within our IMC config, unless we specify a different path during update
[string]$SetRemotePath = $definedRepo.Value.RemotePath;
if ([string]::IsNullOrEmpty($RemotePath) -eq $FALSE) {
Set-IcingaPowerShellConfig -Path ([string]::Format('Framework.Repository.Repositories.{0}.RemotePath', $definedRepo.Name)) -Value $RemotePath;
$SetRemotePath = $RemotePath;
}
$IcingaRepository = New-IcingaRepositoryFile -Path $Path -RemotePath $SetRemotePath;
if ($CreateNew) { if ($CreateNew) {
return $IcingaRepository; return $IcingaRepository;