Skip to content

Commit c486c76

Browse files
authored
Removed hardcoded database name (#166)
1 parent 7b5ada9 commit c486c76

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

cmd/main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package main
33
import (
44
"context"
55
"fmt"
6+
"net/url"
67
"os"
8+
"strings"
79
"time"
810
_ "time/tzdata"
911

@@ -100,7 +102,13 @@ func main() {
100102
log.Warnf("signature header is blank. setting default %s", config.DefaultSignatureHeader)
101103
}
102104

103-
conn := db.Database("convoy", nil)
105+
u, err := url.Parse(cfg.Database.Dsn)
106+
if err != nil {
107+
return err
108+
}
109+
110+
dbName := strings.TrimPrefix(u.Path, "/")
111+
conn := db.Database(dbName, nil)
104112

105113
app.groupRepo = datastore.NewGroupRepo(conn)
106114
app.applicationRepo = datastore.NewApplicationRepo(conn)

convoy-docker.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
{
2-
"sentry": {
3-
"dsn": "<insert-sentry-dsn>"
4-
},
5-
"database": {
62
"environment": "dev",
7-
"dsn": "mongodb://root:rootpassword@mongodb:27017"
3+
"database": {
4+
"dsn": "mongodb://root:rootpassword@mongodb:27017/newConvoy?authSource=admin"
85
},
96
"queue": {
107
"type": "redis",

0 commit comments

Comments
 (0)