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

Function Upgrade

addons/upgrade.go:13–52  ·  view source on GitHub ↗
(ctx context.Context, app, addonID, plan string)

Source from the content-addressed store, hash-verified

11)
12
13func Upgrade(ctx context.Context, app, addonID, plan string) error {
14 if app == "" {
15 return errors.New(ctx, "no app defined")
16 } else if addonID == "" {
17 return errors.New(ctx, "no addon ID defined")
18 } else if plan == "" {
19 return errors.New(ctx, "no plan defined")
20 }
21
22 c, err := config.ScalingoClient(ctx)
23 if err != nil {
24 return errors.Wrapf(ctx, err, "fail to get Scalingo client")
25 }
26
27 addon, err := checkAddonExists(ctx, c, app, addonID)
28 if err != nil {
29 return errors.Wrap(ctx, err, "check addon exists")
30 }
31
32 planID, err := utils.FindPlan(ctx, c, addon.AddonProvider.ID, plan)
33 if err != nil {
34 return errors.Wrap(ctx, err, "find plan")
35 }
36
37 params, err := c.AddonUpgrade(ctx, app, addon.ID, scalingo.AddonUpgradeParams{
38 PlanID: planID,
39 })
40 if err != nil {
41 return errors.Wrap(ctx, err, "addon upgrade")
42 }
43
44 io.Status("Addon", addonID, "has been upgraded")
45 if len(params.Variables) > 0 {
46 io.Info("Modified variables:", params.Variables)
47 }
48 if len(params.Message) > 0 {
49 io.Info("Message from addon provider:", params.Message)
50 }
51 return nil
52}

Callers 1

addons.goFile · 0.92

Calls 5

ScalingoClientFunction · 0.92
FindPlanFunction · 0.92
StatusFunction · 0.92
InfoFunction · 0.92
checkAddonExistsFunction · 0.85

Tested by

no test coverage detected