Fixes repository order/config override on force

This commit is contained in:
Lord Hepipud 2022-02-03 13:36:43 +01:00
parent 87b0e84749
commit 58ed9292c6
2 changed files with 12 additions and 3 deletions

View file

@ -40,6 +40,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#458](https://github.com/Icinga/icinga-powershell-framework/pull/458) Fixes `Install-IcingaSecurity` which should only run in an administrative shell * [#458](https://github.com/Icinga/icinga-powershell-framework/pull/458) Fixes `Install-IcingaSecurity` which should only run in an administrative shell
* [#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) * [#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)
* [#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 * [#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
* [#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
### Enhancements ### Enhancements

View file

@ -30,10 +30,18 @@ function Add-IcingaRepository()
Write-IcingaConsoleError 'A repository with the given name "{0}" does already exist. Use "-Force" to overwrite the current repository' -Objects $Name; Write-IcingaConsoleError 'A repository with the given name "{0}" does already exist. Use "-Force" to overwrite the current repository' -Objects $Name;
return; return;
} elseif ($RepoExists -And $Force) { } elseif ($RepoExists -And $Force) {
Write-IcingaConsoleNotice 'Repository "{0}" is already registered. Forcing removal and re-adding it.' -Objects $Name; Write-IcingaConsoleNotice 'Repository "{0}" is already registered. Forcing override of data.' -Objects $Name;
Remove-IcingaRepository -Name $Name;
$CurrentRepositories = Get-IcingaPowerShellConfig -Path 'Framework.Repository.Repositories'; foreach ($entry in $CurrentRepositories.PSObject.Properties) {
if ($Name.ToLower() -eq $entry.Name.ToLower()) {
$entry.Value.RemotePath = $RemotePath;
break;
}
}
Set-IcingaPowerShellConfig -Path 'Framework.Repository.Repositories' -Value $CurrentRepositories;
return;
} }
[array]$RepoCount = $CurrentRepositories.PSObject.Properties.Count; [array]$RepoCount = $CurrentRepositories.PSObject.Properties.Count;