diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index 2e657553..f01d79ac 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -39,6 +39,10 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#643](https://github.com/Icinga/icinga-powershell-framework/pull/643) Adds support for `-RebuildCache` flag on `icinga` cmd to rebuild component cache as well * [#644](https://github.com/Icinga/icinga-powershell-framework/pull/644) Adds progress bar output to repository interaction (sync, update, new) instead of plain text output +### Enhancements + +* [#613](https://github.com/Icinga/icinga-powershell-framework/pull/613) Adds a `-Version` parameter to the `Update-Icinga` command, to be able to update a component to a specified version [@log1-c] + ## 1.10.1 (2022-12-20) [Issue and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/27?closed=1) diff --git a/doc/111-Updates-and-Uninstallation/01-Update-Environment.md b/doc/111-Updates-and-Uninstallation/01-Update-Environment.md index 62050776..a6173137 100644 --- a/doc/111-Updates-and-Uninstallation/01-Update-Environment.md +++ b/doc/111-Updates-and-Uninstallation/01-Update-Environment.md @@ -15,6 +15,7 @@ The command for updating is `Update-Icinga` and provides the following arguments | Snapshot | Switch | This will allow to update all components by using snapshot repositories | | Confirm | Switch | Each component being updated will ask for a prompt if the package should be updated. Use this switch to confirm the installation and continue | | Force | Switch | Allows to re-install components in case the no new version was found with the name version | +| Version | String | Allows to set a specific version to update the package to | ## Updating all components @@ -36,6 +37,14 @@ Update-Icinga -Name 'plugins; You have to proceed this step then for all components you want to update. +## Updating a component to a specific version + +To update a component to a specific version, you can use the `-Version` argument: + +```powershell +Update-Icinga -Name 'plugins -Version '1.10.0'; +``` + ## Pinned components If you never want to update a certain component in the near future, you can also [pin components](../120-Repository-Manager/06-Pinning-Versions.md) a certain version. Once you run an update, the component will be ignored in case the pinned version is already installed. diff --git a/lib/core/repository/Update-Icinga.psm1 b/lib/core/repository/Update-Icinga.psm1 index a5f9ffb1..4f3855c8 100644 --- a/lib/core/repository/Update-Icinga.psm1 +++ b/lib/core/repository/Update-Icinga.psm1 @@ -2,6 +2,7 @@ function Update-Icinga() { param ( [string]$Name = $null, + [string]$Version = $null, [switch]$Release = $FALSE, [switch]$Snapshot = $FALSE, [switch]$Confirm = $FALSE, @@ -21,7 +22,11 @@ function Update-Icinga() continue; } - $NewVersion = $Component.LatestVersion; + if ([string]::IsNullOrEmpty($Version) -eq $FALSE){ + $NewVersion = $Component.LatestVersion; + } else { + $NewVersion = $Version; + } if ([string]::IsNullOrEmpty($NewVersion)) { Write-IcingaConsoleNotice 'No update package found for component "{0}"' -Objects $entry;