Replace root upgrade flag with self upgrade command#333
Merged
Conversation
Reviewer's GuideReplaces the deprecated top-level Sequence diagram for lets self upgrade command executionsequenceDiagram
actor User
participant Shell
participant Main as CliMain
participant Cobra as CobraRoot
participant Self as SelfCommand
participant UpgradeCmd as UpgradeCommand
participant Factory as upgraderFactory
participant Upgrader as UpgradeUpgrader
User->>Shell: run lets self upgrade
Shell->>Main: invoke Main(version, buildDate)
Main->>Cobra: execute root command
Cobra->>Self: dispatch self subcommand
Self->>UpgradeCmd: dispatch upgrade subcommand
activate UpgradeCmd
UpgradeCmd->>Factory: createUpgrader()
Factory-->>UpgradeCmd: Upgrader or error
alt factory error
UpgradeCmd-->>User: print can not self-upgrade binary
else factory ok
UpgradeCmd->>Upgrader: Upgrade(context)
alt upgrade error
Upgrader-->>UpgradeCmd: error
UpgradeCmd-->>User: print can not self-upgrade binary
else upgrade success
Upgrader-->>UpgradeCmd: nil
UpgradeCmd-->>User: print success and exit 0
end
end
deactivate UpgradeCmd
Class diagram for new self upgrade command structureclassDiagram
class CobraCommand {
+string Use
+string Short
+RunE(cmd CobraCommand, args []string) error
}
class upgraderFactory {
<<function type>>
+New() (Upgrader, error)
}
class UpgradeUpgrader {
<<interface>>
+Upgrade(ctx Context) error
}
class UpgradePackage {
+NewBinaryUpgrader(registry GithubRegistry, version string) Upgrader
}
class GithubRegistry {
+NewGithubRegistry() GithubRegistry
}
class CmdPackage {
+initUpgradeCommand(version string) CobraCommand
+initUpgradeCommandWith(createUpgrader upgraderFactory) CobraCommand
+initSelfCmd(rootCmd CobraCommand, version string, openURL funcUrl) void
}
class CliPackage {
+Main(version string, buildDate string) int
+maybeStartUpdateCheck(command CobraCommand, appSettings Settings) UpdateCheckResult
+shouldCheckForUpdate(command CobraCommand, interactive bool, appSettings Settings) bool
+allowsMissingConfig(current CobraCommand) bool
+isSelfCommand(current CobraCommand) bool
+parseRootFlags(args string[]) Flags
}
class Flags {
+bool help
+bool version
+bool all
+bool init
}
class Settings {
+bool UpgradeNotify
}
class Context
class UpdateCheckResult
class funcUrl {
<<function type>>
+Call(url string) error
}
CmdPackage --> CobraCommand : configures
CmdPackage ..> upgraderFactory : uses
CmdPackage ..> UpgradePackage : uses
CmdPackage ..> GithubRegistry : uses
upgraderFactory --> UpgradeUpgrader : returns
UpgradePackage ..> UpgradeUpgrader : creates
UpgradePackage ..> GithubRegistry : uses
CliPackage ..> CobraCommand : uses
CliPackage ..> Settings : uses
CliPackage ..> Flags : uses
CliPackage ..> Context : uses
CliPackage ..> UpdateCheckResult : uses
CliPackage ..> CmdPackage : calls self subcommands through cobra
CmdPackage ..> funcUrl : uses in initSelfCmd
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
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.
Summary
lets self upgradeas the supported self-update entrypoint--upgradeflag and return a clear migration error for legacy usageTesting
lets fmtgo test ./...lets test-bats help.batslets test-bats help_long.batslets test-bats command_group.batslets test-bats command_group_long.batslets test-bats config_version.batsSummary by Sourcery
Replace the deprecated top-level self-upgrade flag with a dedicated
lets self upgradesubcommand and update CLI behavior, messaging, and docs accordingly.New Features:
lets self upgradesubcommand to perform binary self-upgrades via the existing upgrade infrastructure.Bug Fixes:
selfand its subcommands, includingself upgrade, to avoid redundant notifications during maintenance operations.Enhancements:
--upgraderoot flag, making the CLI reject it with a clear migration error pointing tolets self upgrade.selfas a structured command group.self upgradecommand.Documentation:
lets self upgradeas the supported self-update mechanism and remove references to--upgrade.Tests:
self upgradecommand, legacy--upgradeflag rejection, updated help output, config-version guidance, and update-check skipping for self commands.