-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Make app runnable without creating default home dir #1062
Conversation
WalkthroughThe recent modifications involve simplifying the handling of the home directory within the project's command-line interface. The approach towards setting the home directory has shifted from utilizing a predefined parameter to dynamically creating a temporary directory. This change is aimed at enhancing flexibility and possibly improving the application's handling of user data or configurations by relying on temporary directories for operations. Changes
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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: 1
Configuration used: CodeRabbit UI
Files selected for processing (2)
- protocol/cmd/dydxprotocold/cmd/root.go (4 hunks)
- protocol/cmd/dydxprotocold/main.go (1 hunks)
Additional comments: 2
protocol/cmd/dydxprotocold/main.go (1)
- 17-17: The removal of
app.DefaultNodeHome
from thesvrcmd.Execute
call aligns with the PR's objective but ensure all related functionalities are tested to confirm no side effects.protocol/cmd/dydxprotocold/cmd/root.go (1)
- 106-106: Using
tempDir()
to set the home directory is consistent with the PR's objectives. Ensure the temporary directory's lifecycle is managed appropriately throughout the application's runtime.
|
||
var tempDir = func() string { | ||
dir, err := os.MkdirTemp("", "dydxprotocol") | ||
if err != nil { | ||
dir = dydxapp.DefaultNodeHome | ||
} | ||
defer os.RemoveAll(dir) | ||
|
||
return dir | ||
} |
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 tempDir
function creates and immediately removes the temporary directory, which could lead to runtime issues. Consider removing defer os.RemoveAll(dir)
to ensure the directory persists for the application's lifetime.
- defer os.RemoveAll(dir)
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
var tempDir = func() string { | |
dir, err := os.MkdirTemp("", "dydxprotocol") | |
if err != nil { | |
dir = dydxapp.DefaultNodeHome | |
} | |
defer os.RemoveAll(dir) | |
return dir | |
} | |
var tempDir = func() string { | |
dir, err := os.MkdirTemp("", "dydxprotocol") | |
if err != nil { | |
dir = dydxapp.DefaultNodeHome | |
} | |
return dir | |
} |
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 (2)
- protocol/cmd/dydxprotocold/cmd/root.go (5 hunks)
- protocol/cmd/dydxprotocold/main.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- protocol/cmd/dydxprotocold/cmd/root.go
- protocol/cmd/dydxprotocold/main.go
a8f1218
to
23307d3
Compare
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 (2)
- protocol/cmd/dydxprotocold/cmd/root.go (1 hunks)
- protocol/cmd/dydxprotocold/main.go (2 hunks)
Files skipped from review as they are similar to previous changes (2)
- protocol/cmd/dydxprotocold/cmd/root.go
- protocol/cmd/dydxprotocold/main.go
aa3bc31
to
999ef5f
Compare
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 (3)
- protocol/cmd/dydxprotocold/cmd/root.go (3 hunks)
- protocol/cmd/dydxprotocold/main.go (1 hunks)
- protocol/testing/containertest/node.go (2 hunks)
Files skipped from review as they are similar to previous changes (2)
- protocol/cmd/dydxprotocold/cmd/root.go
- protocol/cmd/dydxprotocold/main.go
Additional comments: 1
protocol/testing/containertest/node.go (1)
- 107-107: The
NewRootCmd
function is now called with a new parameteroption
, which is obtained fromcmd.GetOptionWithCustomStartCmd()
. Ensure that this change aligns with the PR's objective to prevent the creation of a default home directory and that it correctly implements the temporary directory workaround. Verify that theoption
parameter is properly configured to support this behavior.
if err != nil { | ||
dir = app.DefaultNodeHome | ||
} | ||
defer os.RemoveAll(dir) |
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.
won't defer delete dir
when function is returning and this would clear the DefaultNodeHome
from any existing state if creating a temp dir creation is not possible?
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.
Yeah, I just copied this straight from cosmos. But it doesn't matter because the directories are recreated created in ReadFromClientConfig
.
@@ -165,6 +165,7 @@ func NewRootCmdWithInterceptors( | |||
if err != nil { | |||
panic(err) | |||
} | |||
initClientCtx.HomeDir = "" |
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.
is there a reason why it is set here instead of above on line 109?
If so can you document why with a comment?
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.
If we set this before ReadFromClientConfig
, the config will be created in cwd instead.
* Make app runnable without creating default home dir * Add comments (cherry picked from commit 2657b35)
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 (3)
- protocol/cmd/dydxprotocold/cmd/root.go (1 hunks)
- protocol/cmd/dydxprotocold/main.go (2 hunks)
- protocol/testing/containertest/node.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- protocol/cmd/dydxprotocold/cmd/root.go
- protocol/cmd/dydxprotocold/main.go
- protocol/testing/containertest/node.go
Changelist
Test Plan
./build/dydxprotocold query subaccounts show-subaccount dydx1q628jg3e8vzy6xcns6fxls7k7kplqgxr0gy87t 0 --home ~/.dydxprotocol2
, with existing custom home dir, ensure it works properly and doesn't create default home dir.Author/Reviewer Checklist
state-breaking
label.indexer-postgres-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.