Skip to content

feat(ovhcloud-cli): add upgrade command#175

Open
Gandalf-Le-Dev wants to merge 2 commits intomainfrom
dev/mrocher/upgrade-cli-command
Open

feat(ovhcloud-cli): add upgrade command#175
Gandalf-Le-Dev wants to merge 2 commits intomainfrom
dev/mrocher/upgrade-cli-command

Conversation

@Gandalf-Le-Dev
Copy link
Copy Markdown
Contributor

Description

Adds a new ovhcloud upgrade command that updates the CLI to the latest GitHub release. Behavior adapts to the detected install method:

Install method Behavior
Homebrew cask Prints brew upgrade --cask ovh/tap/ovhcloud-cli
go install Prints go install github.com/ovh/ovhcloud-cli/cmd/ovhcloud@latest
install.sh / manual binary (linux, darwin) Downloads release asset and atomically replaces the current binary
install.sh / manual binary (windows) Prints manual instructions + release URL

Additional changes:

  • New internal/upgrade package exposes LatestTag, DetectInstallMethod, CheckWritable, and SelfReplace.
  • internal/cmd/root.go background version check now reuses upgrade.LatestTag and its message hints users to run ovhcloud upgrade.
  • Pre-flight CheckWritable runs before prompting so permission issues fail fast. Permission errors are wrapped with a suggestion to retry with sudo or reinstall via the documentation.
  • upgrade is excluded from WASM builds (runtime guard in upgrade.go:init() + wasmHiddenCommands).
  • Flags: --yes / -y skips the confirmation prompt on the self-replace path.
  • Dev builds (version.Version == "undefined") return an error instead of attempting an upgrade.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have commented my code
  • I ran go mod tidy
  • I have added tests that prove my fix is effective or that my feature works

@Gandalf-Le-Dev Gandalf-Le-Dev requested a review from a team as a code owner April 20, 2026 15:24
@Gandalf-Le-Dev Gandalf-Le-Dev force-pushed the dev/mrocher/upgrade-cli-command branch from 68c50b3 to 496f662 Compare April 20, 2026 15:27
@amstuta amstuta requested a review from Copilot April 27, 2026 06:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/upgrade helpers for latest-release lookup, install-method detection, writability checks, and self-replacement.
  • Adds ovhcloud upgrade command with install-method-specific guidance and self-replace behavior on linux/darwin.
  • Updates root background version check to reuse upgrade.LatestTag and to hint ovhcloud 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.

Comment thread internal/upgrade/install_test.go Outdated
Comment thread internal/cmd/upgrade.go Outdated
Comment thread internal/upgrade/install.go Outdated
Mathis Rocher 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>
@Gandalf-Le-Dev Gandalf-Le-Dev force-pushed the dev/mrocher/upgrade-cli-command branch from 337c1b2 to b0d0df5 Compare April 29, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants