Skip to content

Commit 436fca3

Browse files
authored
Merge pull request #463 from Icinga:fix/repository_nolonger_readded_on_force
Fix: Add-IcingaRepository removes and adds repository with -Force Fixes `Add-IcingaRepository` which now only overrides the `RemotePath` by using `-Force` instead of removing and adding the repository again, causing problems with installation orders over IMC for example
2 parents 87b0e84 + 58ed929 commit 436fca3

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

doc/100-General/10-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
4040
* [#458](https://github.com/Icinga/icinga-powershell-framework/pull/458) Fixes `Install-IcingaSecurity` which should only run in an administrative shell
4141
* [#459](https://github.com/Icinga/icinga-powershell-framework/pull/459) Fixes `Update-Icinga` which was not working to downgrade snapshot packages pack to release (**NOTE:** It can still happen that migrations of the `Framework` might break your environment. Not recommended in production environments for the `Framework` component)
4242
* [#460](https://github.com/Icinga/icinga-powershell-framework/issues/460) Fixes Icinga Agent installation over IMC and Director Self-Service, in case the Self-Service is configured to not install the Icinga Agent or the user manually set `Do not install Icinga Agent` inside the IMC, which results in most configurations not being applied to the Agent, in case it is already installed
43+
* [#461](https://github.com/Icinga/icinga-powershell-framework/issues/461) Fixes `Add-IcingaRepository` which now only overrides the `RemotePath` by using `-Force` instead of removing and adding the repository again, causing problems with installation orders over IMC for example
4344

4445
### Enhancements
4546

lib/core/repository/Add-IcingaRepository.psm1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,18 @@ function Add-IcingaRepository()
3030
Write-IcingaConsoleError 'A repository with the given name "{0}" does already exist. Use "-Force" to overwrite the current repository' -Objects $Name;
3131
return;
3232
} elseif ($RepoExists -And $Force) {
33-
Write-IcingaConsoleNotice 'Repository "{0}" is already registered. Forcing removal and re-adding it.' -Objects $Name;
34-
Remove-IcingaRepository -Name $Name;
33+
Write-IcingaConsoleNotice 'Repository "{0}" is already registered. Forcing override of data.' -Objects $Name;
3534

36-
$CurrentRepositories = Get-IcingaPowerShellConfig -Path 'Framework.Repository.Repositories';
35+
foreach ($entry in $CurrentRepositories.PSObject.Properties) {
36+
if ($Name.ToLower() -eq $entry.Name.ToLower()) {
37+
$entry.Value.RemotePath = $RemotePath;
38+
break;
39+
}
40+
}
41+
42+
Set-IcingaPowerShellConfig -Path 'Framework.Repository.Repositories' -Value $CurrentRepositories;
43+
44+
return;
3745
}
3846

3947
[array]$RepoCount = $CurrentRepositories.PSObject.Properties.Count;

0 commit comments

Comments
 (0)