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

Function addonUUIDFromFlags

cmd/flags.go:53–88  ·  view source on GitHub ↗

addonUUIDFromFlags returns the addon UUID based on the --addon flag, the SCALINGO_ADDON env var or the current detected database. exitIfMissing is optional. Set to true to show a message requesting for the --addon flag.

(ctx context.Context, c *cli.Command, app string, exitIfMissing ...bool)

Source from the content-addressed store, hash-verified

51// or the current detected database.
52// exitIfMissing is optional. Set to true to show a message requesting for the --addon flag.
53func addonUUIDFromFlags(ctx context.Context, c *cli.Command, app string, exitIfMissing ...bool) string {
54 var addonName string
55
56 for _, cliContext := range c.Lineage() {
57 if cliContext.String("addon") != "<addon_id>" {
58 addonName = cliContext.String("addon")
59 break
60 }
61 }
62
63 if addonName == "" && os.Getenv("SCALINGO_ADDON") != "" {
64 addonName = os.Getenv("SCALINGO_ADDON")
65 }
66
67 if addonName == "" && os.Getenv("SCALINGO_PREVIEW_FEATURES") == "true" {
68 _, addonName = detect.GetCurrentResourceAndDatabase(ctx, c)
69 }
70
71 if addonName == "" && len(exitIfMissing) > 0 && exitIfMissing[0] {
72 io.Error("Unable to find the addon name, please use --addon flag.")
73 os.Exit(1)
74 }
75 if addonName == "" {
76 return ""
77 }
78
79 var addonUUID string
80 var err error
81 addonUUID, err = utils.GetAddonUUIDFromType(ctx, app, addonName)
82 if err != nil {
83 io.Error("Unable to get the addon UUID based on its type:", err)
84 os.Exit(1)
85 }
86 debug.Println("[ADDON] Addon name is", addonName)
87 return addonUUID
88}
89
90func regionNameFromFlags(c *cli.Command) string {
91 for _, cliContext := range c.Lineage() {

Callers 6

logs.goFile · 0.85
databases.goFile · 0.85
backups.goFile · 0.85
logs_archives.goFile · 0.85
log_drains.goFile · 0.85
maintenance.goFile · 0.85

Calls 3

ErrorFunction · 0.92
GetAddonUUIDFromTypeFunction · 0.92

Tested by

no test coverage detected