MCPcopy Create free account
hub / github.com/Scalingo/cli / MongoConsole

Function MongoConsole

db/mongo_console.go:16–41  ·  view source on GitHub ↗
(ctx context.Context, opts MongoConsoleOpts)

Source from the content-addressed store, hash-verified

14}
15
16func MongoConsole(ctx context.Context, opts MongoConsoleOpts) error {
17 if opts.VariableName == "" {
18 opts.VariableName = "SCALINGO_MONGO"
19 }
20 mongoURL, _, _, err := dbURL(ctx, opts.App, opts.VariableName, []string{"mongodb"})
21 if err != nil {
22 return errors.Wrapf(ctx, err, "resolve MongoDB URL from %s", opts.VariableName)
23 }
24
25 command := []string{"dbclient-fetcher", "mongo", "&&", "mongo"}
26 if mongoURL.Query().Get("ssl") == "true" {
27 command = append(command, "--ssl", "--sslAllowInvalidCertificates")
28 }
29
30 err = apps.Run(ctx, apps.RunOpts{
31 DisplayCmd: "mongo-console",
32 App: opts.App,
33 Cmd: append(command, "'"+mongoURL.String()+"'"),
34 Size: opts.Size,
35 })
36 if err != nil {
37 return errors.Newf(ctx, "fail to run MongoDB console: %v", err)
38 }
39
40 return nil
41}

Callers 1

mongo.goFile · 0.92

Calls 2

RunFunction · 0.92
dbURLFunction · 0.85

Tested by

no test coverage detected