-
Notifications
You must be signed in to change notification settings - Fork 108
feat: add support for supplying config options #45
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
Changes from 3 commits
09a9757
45e10a8
ee7ce69
cf7d011
ad91bfc
7f3a8d9
84a0fe0
cac95a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { NodeDriverServiceProvider } from "@mongosh/service-provider-node-driver | |
import { DbOperationType, MongoDBToolBase } from "./mongodbTool.js"; | ||
import { ToolArgs } from "../tool"; | ||
import { ErrorCodes, MongoDBError } from "../../errors.js"; | ||
import { saveState } from "../../state.js"; | ||
|
||
export class ConnectTool extends MongoDBToolBase { | ||
protected name = "connect"; | ||
|
@@ -20,8 +21,8 @@ export class ConnectTool extends MongoDBToolBase { | |
protected async execute({ | ||
connectionStringOrClusterName, | ||
}: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> { | ||
connectionStringOrClusterName ??= this.state.connectionString; | ||
if (!connectionStringOrClusterName) { | ||
// TODO: try reconnecting to the default connection | ||
return { | ||
content: [ | ||
{ type: "text", text: "No connection details provided." }, | ||
|
@@ -71,5 +72,7 @@ export class ConnectTool extends MongoDBToolBase { | |
}); | ||
|
||
this.mongodbState.serviceProvider = provider; | ||
this.state.connectionString = connectionString; | ||
await saveState(this.state); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do I understand correct that we'd save the conectionString with its credentials in a plaintext file this way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes - this should be handled in #20. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: why do we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No - mongodb state is a set of globals that will not get stored on disk. I was debating between adding them to state and then special-casing which fields get persisted but at the end opted to create a separate object. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so far config is read only from env vars / defaults and state is something we expect to store (as in preferences). I think we are merging these two concepts together in this PR, which I'm ok with. In theory There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically, it's not even a config - it's just a place to stash certain things we may need for later (such as the MongoDB client after |
||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.