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

Function checkAddonExists

addons/destroy.go:53–66  ·  view source on GitHub ↗
(ctx context.Context, c *scalingo.Client, app, addonID string)

Source from the content-addressed store, hash-verified

51}
52
53func checkAddonExists(ctx context.Context, c *scalingo.Client, app, addonID string) (*scalingo.Addon, error) {
54 resources, err := c.AddonsList(ctx, app)
55 if err != nil {
56 return nil, errors.Wrapf(ctx, err, "list addons for app %s", app)
57 }
58 addonList := []string{}
59 for _, r := range resources {
60 addonList = append(addonList, r.ID+" ("+r.AddonProvider.Name+")")
61 if addonID == r.ID {
62 return r, nil
63 }
64 }
65 return nil, errors.Newf(ctx, "Addon "+addonID+" doesn't exist for app "+app+"\nExisting addons:\n - %v", strings.Join(addonList, "\n - "))
66}

Callers 2

DestroyFunction · 0.85
UpgradeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected