-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
refactor(confix): properly update migrate and diff command #18596
Conversation
Note Reviews PausedUse the following commands to manage reviews:
WalkthroughThe updates focus on enhancing the Changes
TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 5
Configuration used: CodeRabbit UI
Files ignored due to filter (1)
- tools/confix/data/v0.51-app.toml
Files selected for processing (5)
- tools/confix/README.md (2 hunks)
- tools/confix/cmd/diff.go (2 hunks)
- tools/confix/cmd/migrate.go (4 hunks)
- tools/confix/cmd/migrate_test.go (1 hunks)
- tools/confix/cmd/mutate_test.go (2 hunks)
Files skipped from review due to trivial changes (1)
- tools/confix/README.md
Additional comments: 11
tools/confix/cmd/diff.go (3)
18-18: The
Use
field in the command still indicates two arguments, which is inconsistent with the summary stating that the function's signature has been changed to accept only one argument.42-45: The retrieval of
targetVersion
after the configuration checks is consistent with the summary and the intended refactoring.71-71: The addition of the flag to diff
client.toml
instead ofapp.toml
is consistent with the summary and the intended refactoring.tools/confix/cmd/migrate.go (1)
- 21-45: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [22-84]
The changes in the
MigrateCommand
function reflect the updates mentioned in the summary and pull request details. The logic for determiningconfigPath
and handling the--client
flag has been updated accordingly. The flags are correctly defined, and the error handling for loading the configuration and upgrading it seems appropriate.tools/confix/cmd/migrate_test.go (6)
19-20: The test case for version
v0.0
has been updated to remove theapp
argument, which aligns with the changes in the command-line interface.23-24: The test case for version
v0.45
has been updated to remove theapp
argument, which aligns with the changes in the command-line interface.26-28: The test case for version
v0.46
has been updated to useunsupported.toml
instead ofclient.toml
, which aligns with the changes in the command-line interface and the summary.30-33: The test case for version
v0.46
with--skip-validate
and--verbose
flags has been updated to useunsupported.toml
instead ofclient.toml
, which aligns with the changes in the command-line interface and the summary.36-38: The test case for version
v0.51
has been updated to include the--client
flag, which aligns with the changes in the command-line interface and the summary.16-39: The summary mentions the introduction of a symbolic link from
client.toml
tounsupported.toml
within theinitClientContext
function to support the new test scenarios, but this is not visible in the provided hunk. Ensure that theinitClientContext
function is correctly setting up the test environment as described.tools/confix/cmd/mutate_test.go (1)
- 3-8: The addition of the
path/filepath
import is appropriate for the file operations being performed in theinitClientContext
function.
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.
Review Status
Actionable comments generated: 4
Configuration used: CodeRabbit UI
Files selected for processing (2)
- tools/confix/cmd/diff.go (2 hunks)
- tools/confix/cmd/migrate.go (4 hunks)
Additional comments: 7
tools/confix/cmd/diff.go (5)
16-16: The summary states that the
DiffCommand
function's signature has changed, but the hunk shows no change in the signature. Please verify this discrepancy.21-21: The change from
cobra.MinimumNArgs(2)
tocobra.MinimumNArgs(1)
is correctly implemented.22-45: The restructuring of the logic for determining
configPath
andconfigType
using a switch statement and conditional checks is correctly implemented.39-39: The updated error message for an unexpected file type provides clearer guidance to the user.
71-71: The new flag
confix.ClientConfigType
has been correctly added to the command flags.tools/confix/cmd/migrate.go (2)
- 24-24: The
Use
field in thecobra.Command
struct still expects two arguments, but the summary indicates that theconfig-type
argument has been removed. This should be updated to reflect the actual changes.- Use: "migrate [target-version] <config-path>", + Use: "migrate [target-version]",
- 79-82: The flags have been correctly added to the
cobra.Command
struct.
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.
Review Status
Actionable comments generated: 5
Configuration used: CodeRabbit UI
Files selected for processing (5)
- math/int.go (1 hunks)
- tools/confix/cmd/diff.go (2 hunks)
- tools/confix/cmd/migrate.go (4 hunks)
- tools/confix/file.go (2 hunks)
- tools/confix/migrations.go (3 hunks)
Files skipped from review due to trivial changes (2)
- math/int.go
- tools/confix/file.go
Additional comments: 7
tools/confix/cmd/diff.go (1)
- 72-72: The addition of the new flag
--client
to the command is implemented correctly and aligns with the summary.tools/confix/cmd/migrate.go (5)
6-15: The summary states that the import statement for
"github.com/cosmos/cosmos-sdk/client"
was removed, but it has actually been moved within the import block.40-40:
66-66:
69-69:
83-83: The addition of the
--client
flag is consistent with the summary and the changes in the hunk.tools/confix/migrations.go (1)
- 21-25: The summary states that the function signature of
MigrationMap
has been altered to accept three parameters, but the hunk does not reflect this change. Please verify if the summary is accurate or if the code change was omitted.
func PlanBuilder(from *tomledit.Document, to, planType string) transform.Plan { | ||
plan := transform.Plan{} | ||
deletedSections := map[string]bool{} | ||
|
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.
The use of panic
for error handling within PlanBuilder
is not recommended in Go, as it can cause the program to terminate abruptly. Consider returning an error and handling it gracefully.
@coderabbitai resolve |
Resolve command requires updated permissionsCodeRabbit does not currently have write access to Content permissions, which is required to resolve conversations. |
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- tools/confix/cmd/diff.go (2 hunks)
Additional comments: 7
tools/confix/cmd/diff.go (7)
- 27-28: The summary states that
DiffCommand
now accepts only one argument, but the code still checks for a second argument. Please verify if the summary or the code needs to be updated.- case len(args) > 1: + case len(args) == 1:
40-40: The error message "app.toml file expected, got client.toml, use --client flag to diff client.toml" could be improved for clarity. It should indicate that the
--client
flag is required when theclient.toml
file is being used.35-41: The changes to handle
confix.ClientConfigType
using a switch statement and a boolean flag are correctly implemented.32-32: The error message provided when neither a config path nor a home directory is available is clear and consistent with the improved error handling.
40-40: The error message at line 40 could be improved for clarity based on previous comments.
45-46: The error message for an unknown version is specific and informative, listing the supported versions.
50-50: The error message for failing to load the internal config is consistent with the improved error handling.
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.
Thank you @julienrbrt! I've sent in the first round of reviews, please take a look but LGTM otherwise after addressing the comments.
@coderabbitai pause |
Description
ref: https://github.com/cosmos/cosmos-sdk/pull/18455/files#r1409559081
Follow-up of #18455 that had some mistakes and a CLI breaking UX.
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.
I have...
Summary by CodeRabbit
New Features
--client
flag for migrating and diffing client configuration files.Bug Fixes
Documentation
Refactor
Style
Tests