feat(ovhcloud-cli): add upgrade command#175
Open
Gandalf-Le-Dev wants to merge 2 commits intomainfrom
Open
Conversation
68c50b3 to
496f662
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new ovhcloud upgrade command and supporting internal/upgrade package to help users update the CLI to the latest GitHub release, while also reusing that release-check logic for the existing background “new version available” message.
Changes:
- Introduces
internal/upgradehelpers for latest-release lookup, install-method detection, writability checks, and self-replacement. - Adds
ovhcloud upgradecommand with install-method-specific guidance and self-replace behavior on linux/darwin. - Updates root background version check to reuse
upgrade.LatestTagand to hintovhcloud upgrade; adds generated docs page for the new command.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/upgrade/release.go | Fetch latest GitHub release tag. |
| internal/upgrade/release_test.go | Unit tests for latest-release tag fetching. |
| internal/upgrade/method.go | Defines install method enum and stringer. |
| internal/upgrade/detect.go | Detects install method from executable path/env. |
| internal/upgrade/detect_test.go | Tests for install-method detection. |
| internal/upgrade/install.go | Implements writability check and self-replace download/extract/rename logic. |
| internal/upgrade/install_test.go | Tests for self-replace, asset naming, and writability checks. |
| internal/cmd/upgrade.go | Adds the new upgrade CLI command and flags. |
| internal/cmd/root.go | Reuses upgrade.LatestTag for background version check; hides upgrade in WASM. |
| doc/ovhcloud_upgrade.md | Adds generated documentation for ovhcloud upgrade. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
added 2 commits
April 29, 2026 10:07
Signed-off-by: Mathis Rocher <mathis.rocher@corp.ovh.com>
- CheckWritable: drop O_WRONLY probe on target, keep dir-only probe
(os.Rename only needs write access to parent dir)
- runUpgrade: resolve symlinks once via upgrade.ResolveExecutable and
pass resolved path to CheckWritable, prompt, and SelfReplace
- SelfReplace now takes targetPath argument; symlink resolution moved
to caller for consistency between checks and rename
- Split read-only-dir test into install_unix_test.go with
//go:build !windows so install_test.go compiles on Windows
Signed-off-by: Mathis Rocher <mathis.rocher@corp.ovh.com>
337c1b2 to
b0d0df5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a new
ovhcloud upgradecommand that updates the CLI to the latest GitHub release. Behavior adapts to the detected install method:brew upgrade --cask ovh/tap/ovhcloud-cligo installgo install github.com/ovh/ovhcloud-cli/cmd/ovhcloud@latestAdditional changes:
internal/upgradepackage exposesLatestTag,DetectInstallMethod,CheckWritable, andSelfReplace.internal/cmd/root.gobackground version check now reusesupgrade.LatestTagand its message hints users to runovhcloud upgrade.CheckWritableruns before prompting so permission issues fail fast. Permission errors are wrapped with a suggestion to retry withsudoor reinstall via the documentation.upgradeis excluded from WASM builds (runtime guard inupgrade.go:init()+wasmHiddenCommands).--yes/-yskips the confirmation prompt on the self-replace path.version.Version == "undefined") return an error instead of attempting an upgrade.Type of change
Checklist:
go mod tidy