Repository navigation
feat: make the MongoDB database configurable - #84
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused configuration change preserves existing defaults and has no identified blocking issues.
No open issues 🎉
What changed in this PR
Makes the MongoDB database configurable so separate deployments can use isolated catalog databases, while preserving plugin as the default.
Changes:
- Adds
--mongodb-databaseandMONGODB_DATABASEand passes the selected value into the MongoDB configuration. - Documents the new option and its default.
| File | Description |
|---|---|
| readme.md | Documents the database flag and environment variable. |
| cmd/internal/mongo.go | Defines the database option and wires it into the MongoDB configuration. |
Review effort: Balanced
Contributor
There was a problem hiding this comment.
LGTM. Possible improvement for later, take it directly from URI:
func buildClientOptions(cfg mongodb.Config) (*options.ClientOptions, string, error) {
cs, err := connstring.ParseAndValidate(cfg.URI)
if err != nil {
return nil, "", fmt.Errorf("parsing MongoDB URI: %w", err)
}
clientOptions := options.Client().ApplyURI(cfg.URI).
SetPoolMonitor(&event.PoolMonitor{Event: poolMonitor}).
SetMonitor(otelmongo.NewMonitor())
if !cs.MinPoolSizeSet {
clientOptions.SetMinPoolSize(cfg.MinPool)
}
if !cs.MaxPoolSizeSet {
clientOptions.SetMaxPoolSize(cfg.MaxPool)
}
if !cs.SocketTimeoutSet {
clientOptions.SetSocketTimeout(2 * time.Second)
}
if !cs.ConnectTimeoutSet {
clientOptions.SetConnectTimeout(10 * time.Second)
}
if !cs.ServerSelectionTimeoutSet {
clientOptions.SetServerSelectionTimeout(10 * time.Second)
}
database := cs.Database
if database == "" {
database = defaultDatabase
}
return clientOptions, database, nil
}I tested it locally.
darkweaver87
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The database was hardcoded to
plugin.--mongodb-database(MONGODB_DATABASE) sets it, the default staysplugin.A second deployment can then run on a copy of the catalog in its own database, with a user that has no access to
plugin.Part of traefik/hub-issues#3124