-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cosmovisor): fix show-upgrade info command #22010
Conversation
📝 WalkthroughWalkthroughThe changes involve modifications to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
@julienrbrt your pull request is missing a changelog! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
tools/cosmovisor/cmd/cosmovisor/show_upgrade.go (1)
20-27
: Suggestion: Consistent error handlingFor consistency, consider using the same error handling pattern for the
GetConfigFromFile
function call as used for reading theupgrade-info.json
file. This would involve wrapping the error in a more descriptive message.Here's a suggested change:
configPath, err := cmd.Flags().GetString(cosmovisor.FlagCosmovisorConfig) if err != nil { - return fmt.Errorf("failed to get config flag: %w", err) + return fmt.Errorf("failed to get cosmovisor config flag: %w", err) } cfg, err := cosmovisor.GetConfigFromFile(configPath) if err != nil { - return err + return fmt.Errorf("failed to get config from file: %w", err) }
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
📒 Files selected for processing (1)
- tools/cosmovisor/cmd/cosmovisor/show_upgrade.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
tools/cosmovisor/cmd/cosmovisor/show_upgrade.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
🔇 Additional comments (2)
tools/cosmovisor/cmd/cosmovisor/show_upgrade.go (2)
15-15
: Improved command descriptionThe updated Short description provides a clearer explanation of the command's purpose. It now explicitly mentions that it displays the current
upgrade-info.json
file from the application data directory, which is more informative for users.
31-36
: Enhanced error handling for file readingThe error handling for reading the
upgrade-info.json
file has been improved. It now distinguishes between a non-existent file and other read errors, providing a more user-friendly message when the file doesn't exist. This enhancement improves the user experience by offering clearer feedback.
data, err := os.ReadFile(cfg.UpgradeInfoFilePath()) | ||
if err != nil { | ||
if os.IsNotExist(err) { | ||
cmd.Printf("No upgrade info found at %s\n", cfg.UpgradeInfoFilePath()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Suggestion: Use a constant for the file name
Consider defining a constant for the upgrade-info.json
file name. This would improve maintainability and reduce the risk of typos if the file name is used in multiple places.
Here's a suggested change:
+const upgradeInfoFileName = "upgrade-info.json"
// In the NewShowUpgradeInfoCmd function
-cmd.Printf("No upgrade info found at %s\n", cfg.UpgradeInfoFilePath())
+cmd.Printf("No %s found at %s\n", upgradeInfoFileName, cfg.UpgradeInfoFilePath())
This change would require adding the constant at the package level.
Committable suggestion was skipped due to low confidence.
Description
Fixes this PR: #21932
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
New Features
upgrade-info.json
file directly in the command line.Bug Fixes
upgrade-info.json
file with user-friendly messages.