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

Function IsResourceDatabase

utils/database.go:18–37  ·  view source on GitHub ↗

IsResourceDatabase returns true if the current resource is a database. It returns an ErrResourceNotFound error if no database name has been found.

(ctx context.Context, resourceName string)

Source from the content-addressed store, hash-verified

16// IsResourceDatabase returns true if the current resource is a database. It returns
17// an ErrResourceNotFound error if no database name has been found.
18func IsResourceDatabase(ctx context.Context, resourceName string) (bool, error) {
19 client, err := config.ScalingoClient(ctx)
20 if err != nil {
21 return false, errors.Wrap(ctx, err, "get Scalingo client")
22 }
23
24 app, err := client.AppsShow(ctx, resourceName)
25 if err != nil {
26 debug.Println("[detect] Unable to show app to check if resource is a database:", err)
27 return false, nil
28 }
29
30 for f, v := range app.Flags {
31 if f == databasesResourceFlag && v {
32 return true, nil
33 }
34 }
35
36 return false, ErrResourceNotFound
37}

Callers 7

rename.goFile · 0.92
db_tunnel.goFile · 0.92
apps.goFile · 0.92
one_off_stop.goFile · 0.92
runOneOffCommandFunction · 0.92
CheckForConsentFunction · 0.85

Calls 1

ScalingoClientFunction · 0.92

Tested by

no test coverage detected