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

Function PgSQLConsole

db/pgsql_console.go:16–38  ·  view source on GitHub ↗
(ctx context.Context, opts PgSQLConsoleOpts)

Source from the content-addressed store, hash-verified

14}
15
16func PgSQLConsole(ctx context.Context, opts PgSQLConsoleOpts) error {
17 if opts.VariableName == "" {
18 opts.VariableName = "SCALINGO_POSTGRESQL"
19 }
20 postgreSQLURL, user, _, err := dbURL(ctx, opts.App, opts.VariableName, []string{"postgres", "postgis", "postgresql"})
21 if err != nil {
22 return errors.Wrapf(ctx, err, "resolve PostgreSQL URL from %s", opts.VariableName)
23 }
24
25 runOpts := apps.RunOpts{
26 DisplayCmd: "pgsql-console " + user,
27 App: opts.App,
28 Cmd: []string{"dbclient-fetcher", "pgsql", "&&", "psql", "'" + postgreSQLURL.String() + "'"},
29 Size: opts.Size,
30 }
31
32 err = apps.Run(ctx, runOpts)
33 if err != nil {
34 return errors.Newf(ctx, "fail to run PostgreSQL console: %v", err)
35 }
36
37 return nil
38}

Callers 1

pgsql.goFile · 0.92

Calls 2

RunFunction · 0.92
dbURLFunction · 0.85

Tested by

no test coverage detected