Skip to content

Commit

Permalink
load URI from file
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-bate committed Dec 12, 2023
1 parent 1d2a433 commit 494c8d8
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"math"
"os"
"strings"
"time"

"github.com/urfave/cli"
Expand Down Expand Up @@ -69,9 +70,9 @@ func (m *Migration) RunAndExit() {
}

m.CLI().Action = func(ctx *cli.Context) error {
log.Println("running")
var err error
m.client, err = mongo.Connect(m.ctx, options.Client().ApplyURI(m.config.uri))
mongoURI := strings.ReplaceAll(m.config.uri, " ", "")
m.client, err = mongo.Connect(m.ctx, options.Client().ApplyURI(mongoURI))
if err != nil {
return fmt.Errorf("unable to connect to MongoDB: %w", err)
}
Expand Down Expand Up @@ -151,10 +152,12 @@ func (m *Migration) Initialize() error {
Name: "uri",
Usage: "mongo connection URI",
Destination: &m.config.uri,
Value: "mongodb://localhost:27017",
Value: "",
Required: false,
FilePath: "./uri",
},
)

return nil
}

Expand Down

0 comments on commit 494c8d8

Please sign in to comment.