Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

feat: support getting config from homes for query commands #619

Merged
merged 6 commits into from
Nov 28, 2023

Conversation

rach-id
Copy link
Member

@rach-id rach-id commented Nov 26, 2023

Overview

Closes #618

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

Summary by CodeRabbit

  • New Features

    • Added a new search functionality to the app.
  • Style

    • Added styles for the search bar.

@rach-id rach-id added the enhancement New feature or request label Nov 26, 2023
@rach-id rach-id self-assigned this Nov 26, 2023
@rach-id rach-id requested a review from evan-forbes as a code owner November 26, 2023 20:18
Copy link
Contributor

coderabbitai bot commented Nov 26, 2023

Walkthrough

The changes across various cmd/blobstream files in the Go codebase primarily focus on improving configuration management and user experience. A significant addition is the --home flag for the query command, which simplifies the process of loading configurations. The code now supports retrieving existing configurations based on service type and includes default configurations for easier setup. Error handling and logging have also been enhanced, and function names have been updated for consistency and external accessibility.

Changes

File Path Change Summary
cmd/blobstream/orchestrator/cmd.go Added error handling for config.Bootstrappers check and imported "fmt" package.
cmd/blobstream/orchestrator/config.go Renamed getStartConfig to GetStartConfig and updated LoadFileConfiguration function signature.
cmd/blobstream/query/cmd.go Added tryToGetExistingConfig function, modified Signers and Signature functions, and added imports for configuration retrieval.
cmd/blobstream/query/config.go Introduced NewPartialConfig and DefaultConfig functions, updated parseFlags function to accept and return startConf *Config, and added getP2PNodeFlag helper function.
cmd/blobstream/relayer/config.go Renamed getStartConfig to GetStartConfig affecting the function signature in the exported package.

Assessment against linked issues

Objective Addressed Explanation
Add --home flag for query command (#618) The changes include the addition of a function tryToGetExistingConfig which seems to be part of the effort to simplify configuration loading, likely in conjunction with the --home flag addition.

Poem

In the code where configs abound,
A rabbit hopped, improvements found.
With a --home flag in its teeth,
It made the user's journey brief. 🐇💻✨


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 33f7618 and df837e1.
Files selected for processing (5)
  • cmd/blobstream/orchestrator/cmd.go (2 hunks)
  • cmd/blobstream/orchestrator/config.go (2 hunks)
  • cmd/blobstream/query/cmd.go (6 hunks)
  • cmd/blobstream/query/config.go (2 hunks)
  • cmd/blobstream/relayer/config.go (2 hunks)
Additional comments: 15
cmd/blobstream/orchestrator/config.go (3)
  • 282-286: The function GetStartConfig has been correctly renamed to follow Go's convention for exporting functions. Ensure that all references to this function in the codebase have been updated to use the new name.

  • 246-249: The update to use GetStartConfig in LoadFileConfiguration is correct. However, ensure that the error message is consistent with the context of the function call and provides enough information for debugging.

  • 279-279: The file permissions for the configuration file are set to 0o600, which is a secure practice as it restricts access to the file owner only.

cmd/blobstream/query/cmd.go (6)
  • 6-16: The new import statements are correctly added and used within the code.

  • 501-574: The tryToGetExistingConfig function is well-implemented with proper error handling and clear logic for retrieving configuration based on the service type.

  • 60-70: The integration of tryToGetExistingConfig within the Signers function is correct, and the error handling for configuration retrieval is properly implemented.

  • 352-362: The integration of tryToGetExistingConfig within the Signature function is correct, and the error handling for configuration retrieval is properly implemented.

  • 88-96: The creation of Tendermint and application queriers within the Signers function is correctly implemented, and the error handling is appropriate.

  • 380-383: The creation of Tendermint and application queriers within the Signature function is correctly implemented, and the error handling is appropriate.

cmd/blobstream/query/config.go (4)
  • 20-24: The addition of new flags for the command is correctly implemented and follows the established pattern for adding flags in Cobra-based CLI applications.

  • 34-41: The DefaultConfig function is correctly implemented and provides a clear and concise way to generate a default configuration.

  • 44-86: The parseFlags function is updated to modify the startConf based on the provided flags. However, the function signature in the summary mentions it should return a boolean indicating if any flag has changed, which is not reflected in the code. Ensure that the implementation aligns with the intended behavior as described in the summary.

  • 89-96: The getP2PNodeFlag function is correctly implemented to retrieve the P2P node flag value and a boolean indicating if the flag has changed.

cmd/blobstream/relayer/config.go (2)
  • 345-349: The function getStartConfig has been correctly renamed to GetStartConfig to make it publicly accessible. Ensure that all references to this function in other packages have been updated to use the new name.

  • 342-342: The use of 0o600 permissions for the configuration file is a good security practice, ensuring that only the owner can read and write to the file.

cmd/blobstream/orchestrator/cmd.go Outdated Show resolved Hide resolved
cmd/blobstream/orchestrator/cmd.go Outdated Show resolved Hide resolved
cmd/blobstream/query/cmd.go Outdated Show resolved Hide resolved
cmd/blobstream/query/cmd.go Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between df837e1 and ee153cd.
Files selected for processing (1)
  • cmd/blobstream/query/cmd.go (6 hunks)
Additional comments: 6
cmd/blobstream/query/cmd.go (6)
  • 6-16: The new imports are necessary for the functionality introduced in the file, such as file path operations and configuration management.

  • 58-74: The Signers function has been updated to use the new configuration retrieval logic, which is a good improvement for maintainability and usability.

  • 350-366: The Signature function has been updated to use the new configuration retrieval logic, which is a good improvement for maintainability and usability.

  • 526-526: There is an inconsistency in the field name grpcInsecure between the orchestrator and relayer configurations. Ensure that this is intentional and does not lead to bugs due to mismatched field names.

  • 538-538: There is an inconsistency in the field name grpcInsecure between the orchestrator and relayer configurations. Ensure that this is intentional and does not lead to bugs due to mismatched field names.

  • 501-578: The addition of the tryToGetExistingConfig function is a good practice to simplify the configuration process for users by attempting to retrieve existing configurations from home directories based on the service type.

@codecov-commenter
Copy link

codecov-commenter commented Nov 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (33f7618) 26.13% compared to head (408de1d) 26.13%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #619   +/-   ##
=======================================
  Coverage   26.13%   26.13%           
=======================================
  Files          29       29           
  Lines        3019     3019           
=======================================
  Hits          789      789           
  Misses       2135     2135           
  Partials       95       95           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between ee153cd and 408de1d.
Files selected for processing (2)
  • cmd/blobstream/query/cmd.go (6 hunks)
  • cmd/blobstream/query/config.go (2 hunks)
Additional comments: 10
cmd/blobstream/query/cmd.go (6)
  • 6-16: The addition of new import statements aligns with the changes described in the summary, ensuring the necessary packages are available for the new functionality.

  • 61-70: The creation of a logger and the invocation of tryToGetExistingConfig within the Signers function are implemented correctly, with proper error handling.

  • 88-96: The invocation of common.NewTmAndAppQuerier in the Signers function correctly includes the additional parameter config.grpcInsecure, as per the changes described in the summary.

  • 353-362: The creation of a logger and the invocation of tryToGetExistingConfig within the Signature function are implemented correctly, with proper error handling.

  • 380-383: The invocation of common.NewTmAndAppQuerier in the Signature function correctly includes the additional parameter config.grpcInsecure, as per the changes described in the summary.

  • 501-577: The tryToGetExistingConfig function is well-structured and includes comprehensive error handling for different scenarios where the configuration might be retrieved from. It also provides a default configuration if none is found.

cmd/blobstream/query/config.go (4)
  • 53-95: The summary indicates that parseFlags should return a Config and a boolean indicating if any flag has changed, but the code still returns a Config and an error. Please verify if the summary or the code needs to be updated to reflect the intended behavior.

  • 34-50: The implementation of NewPartialConfig and DefaultConfig functions aligns with the summary description and appears to be correct.

  • 98-104: The getP2PNodeFlag function correctly retrieves the P2PNode flag value and indicates if it has been changed, as described in the summary.

  • 20-24: The addFlags function has been updated to include new flags, which is consistent with the changes outlined in the summary.

@rach-id rach-id requested a review from evan-forbes November 27, 2023 20:36
@rach-id rach-id enabled auto-merge (squash) November 28, 2023 17:23
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 408de1d and a197180.
Files selected for processing (1)
  • cmd/blobstream/relayer/config.go (2 hunks)
Additional comments: 2
cmd/blobstream/relayer/config.go (2)
  • 360-364: The function GetStartConfig has been correctly updated to be public, aligning with the summary of changes.

  • 357-357: The file permissions for the configuration file are set to 0o600, which is a secure practice for sensitive configuration files.

cmd/blobstream/relayer/config.go Show resolved Hide resolved
@rach-id rach-id merged commit c229e91 into celestiaorg:main Nov 28, 2023
17 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add --home flag for query command
3 participants