Skip to content
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

chore(simdv2): allow overriding the --home flag #22348

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

mark-rushakoff
Copy link
Member

@mark-rushakoff mark-rushakoff commented Oct 23, 2024

There were two calls to viper.Set(serverv2.FlagHome, simapp.DefaultNodeHome); these calls invalidated any provided --home command line arguments. When testing multiple simapp instances in the same process, it is necessary to provide separate home directories.

Changing the calls from .Set to .SetDefault retains the previous behavior of using DefaultNodeHome when no --home flag is provided, but it still respects --home when the flag is indeed provided.

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of the default home directory for application configuration to ensure consistent initialization.
    • Enhanced error handling for context validation in command initialization.
  • Refactor

    • Updated method for setting the home directory to utilize default values, streamlining configuration management.

There were two calls to viper.Set(serverv2.FlagHome,
simapp.DefaultNodeHome); these calls invalidated any provided --home
command line arguments. When testing multiple simapp instances in the
same process, it is necessary to provide separate home directories.

Changing the calls from .Set to .SetDefault retains the previous
behavior of using DefaultNodeHome when no --home flag is provided, but
it still respects --home when the flag is indeed provided.
Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

📝 Walkthrough

Walkthrough

The pull request modifies the commands.go file in the simapp/v2/simdv2/cmd package. It updates the method for setting the default home directory for application configuration from a direct assignment to using viper.SetDefault. This change enhances how the home directory is initialized, ensuring a default value is set. The appExport function remains structurally unchanged but now consistently applies the updated method for setting the home directory. Error handling is preserved, and no new commands are introduced.

Changes

File Path Change Summary
simapp/v2/simdv2/cmd/commands.go Updated method for setting the default home directory to viper.SetDefault.
Adjusted appExport function to use the new method for home directory setting.

Possibly related PRs

  • chore: using pre-defined flag variables #21794: This PR modifies the way configuration values are accessed in the simapp/v2/app_test.go file, which is related to the changes in configuration handling in the commands.go file of the main PR. Both PRs focus on improving the management of configuration settings.

Suggested labels

C:server/v2, C:server/v2 appmanager

Suggested reviewers

  • facundomedica
  • julienrbrt

📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 762fad2 and d0ce80e.

📒 Files selected for processing (1)
  • simapp/v2/simdv2/cmd/commands.go (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
simapp/v2/simdv2/cmd/commands.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

🔇 Additional comments (2)
simapp/v2/simdv2/cmd/commands.go (2)

168-168: LGTM: Consistent implementation of home flag default.

The change maintains consistency with the newApp function's behavior and correctly implements the home directory override capability.


40-40: LGTM: Correct usage of viper.SetDefault for home flag.

The change from Set to SetDefault correctly implements the ability to override the home directory while maintaining backward compatibility.

Let's verify the change doesn't break existing behavior:

✅ Verification successful

The previous search might have been too specific. This broader search will help us:

  1. Verify all viper calls related to FlagHome
  2. Understand the context where FlagHome is used
  3. Ensure consistency in how the flag is handled

The change from viper.Set to viper.SetDefault for FlagHome is correct and consistent

Based on the comprehensive search results, I can verify that:

  1. The change in simapp/v2/simdv2/cmd/commands.go correctly uses viper.SetDefault for the home flag.
  2. Most other usages of FlagHome in the codebase are either:
    • Reading the value using GetString/Get
    • Setting up command flags
    • Using it as a configuration key
  3. The only remaining viper.Set calls for FlagHome are in test files or specific command implementations where explicit setting is required (like in testnet commands).

The change aligns with the PR objective to allow overriding of the home flag while maintaining backward compatibility through SetDefault.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify no hardcoded viper.Set calls remain for FlagHome
# Expect: No direct Set calls for FlagHome remain

rg "viper\.Set\(\s*serverv2\.FlagHome" 

Length of output: 40


Script:

#!/bin/bash
# Let's do a more comprehensive check for any viper calls related to FlagHome
# This will help us verify the changes are consistent across the codebase

# Check for any viper calls (Set or SetDefault) related to FlagHome
rg -i "viper\.(Set|SetDefault).*FlagHome"

# Also check for the import and usage of FlagHome constant
rg "FlagHome" -A 2 -B 2

Length of output: 22564


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Oct 23, 2024
@julienrbrt julienrbrt added this pull request to the merge queue Oct 23, 2024
Merged via the queue into main with commit 864ae34 Oct 23, 2024
79 of 80 checks passed
@julienrbrt julienrbrt deleted the mr/simappv2-default-home branch October 23, 2024 20:10
mergify bot pushed a commit that referenced this pull request Oct 23, 2024
alpe added a commit that referenced this pull request Oct 25, 2024
* main: (157 commits)
  feat(core): add ConfigMap type (#22361)
  test: migrate e2e/genutil to systemtest (#22325)
  feat(accounts): re-introduce bundler (#21562)
  feat(log): add slog-backed Logger type (#22347)
  fix(x/tx): add feePayer as signer (#22311)
  test: migrate e2e/baseapp to integration tests (#22357)
  test: add x/circuit system tests (#22331)
  test: migrate e2e/tx tests to systemtest (#22152)
  refactor(simdv2): allow non-comet server components (#22351)
  build(deps): Bump rtCamp/action-slack-notify from 2.3.1 to 2.3.2 (#22352)
  fix(server/v2): respect context cancellation in start command (#22346)
  chore(simdv2): allow overriding the --home flag (#22348)
  feat(server/v2): add SimulateWithState to AppManager (#22335)
  docs(x/accounts): improve comments (#22339)
  chore: remove unused local variables (#22340)
  test: x/accounts systemtests (#22320)
  chore(client): use command's configured output (#22334)
  perf(log): use sonic json lib  (#22233)
  build(deps): bump x/tx (#22327)
  fix(x/accounts/lockup): fix proto path (#22319)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants