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

Function dbURL

db/env.go:12–29  ·  view source on GitHub ↗
(ctx context.Context, appName, envVariableName string, urlSchemes []string)

Source from the content-addressed store, hash-verified

10)
11
12func dbURL(ctx context.Context, appName, envVariableName string, urlSchemes []string) (*url.URL, string, string, error) {
13 u, err := dbURLFromAPI(ctx, appName, envVariableName, urlSchemes)
14 if err != nil {
15 return nil, "", "", errors.Wrapf(ctx, err, "fail to retrieve %s database URL", strings.ToLower(envVariableName))
16 }
17
18 dbURL, err := url.Parse(u)
19 if err != nil {
20 return nil, "", "", errors.Newf(ctx, "%v is not a valid URL", u)
21 }
22
23 user, password, err := extractCredentials(ctx, dbURL)
24 if err != nil {
25 return nil, "", "", errors.Wrapf(ctx, err, "fail to extract credentials from %s database URL", strings.ToLower(envVariableName))
26 }
27
28 return dbURL, user, password, nil
29}
30
31func dbURLFromAPI(ctx context.Context, appName, envVariableName string, urlSchemes []string) (string, error) {
32 scalingoClient, err := config.ScalingoClient(ctx)

Callers 5

PgSQLConsoleFunction · 0.85
RedisConsoleFunction · 0.85
InfluxDBConsoleFunction · 0.85
MongoConsoleFunction · 0.85
MySQLConsoleFunction · 0.85

Calls 2

dbURLFromAPIFunction · 0.85
extractCredentialsFunction · 0.85

Tested by

no test coverage detected