feat(duo): lock Duo CLI auto-updates to compatible major version
What does this MR do and why?
Adds a duoMaxCompatibleMajorVersion constant that bounds Duo CLI auto-updates to the approved major version. When the latest release in the package registry has a higher major version than supported, glab blocks the update and notifies the user to upgrade glab first.
Closes #8230 (closed)
How to set it up
The constant lives in internal/commands/duo/cli/cliutils/binary_manager.go:
// duoMaxCompatibleMajorVersion is the maximum Duo CLI major version this build of glab
// supports. Auto-updates are bounded to this major version. When Duo CLI releases a new
// major version, glab must be updated to increment this value after validating compatibility.
duoMaxCompatibleMajorVersion = 8
When Duo CLI ships a new major:
- Duo team notifies glab team
- glab team validates compatibility and bumps
duoMaxCompatibleMajorVersion - New glab ships — users who update glab receive the new Duo major on next check
- Users on older glab are protected and continue on their current version
Changes
binary_manager.go
- Add
duoMaxCompatibleMajorVersion = 8constant - Replace
latestPackageOptions+getLatestVersionwithfetchLatestPackage(fetchesper_page=1— sufficient since Duo CLI releases linearly on one major at a time, confirmed by release history) -
CheckForUpdategains anewMajorVersionreturn value (non-empty when the latest release exceeds the supported major) -
fetchPackageAssetblocks install/update when the latest package is an incompatible major - Removed
strings.TrimPrefixon version strings —hashicorp/go-versionhandles thevprefix natively
cli.go
-
updateCheckResultgainsnewMajorVersion string - Background update check and
--updateboth surface a "requires newer glab" notice when a new major is detected
binary_manager_test.go
- Replace removed
scanVersionstests withTestDuoMaxCompatibleMajorVersion— table-driven tests verifying the version boundary logic against thehashicorp/go-versionlibrary
MR acceptance checklist
- This MR does not have a documentation impact
- I have added tests, or tested this manually (or both)
- I have followed the contributing guidelines