(ctx context.Context, app, addonID, plan string)
| 11 | ) |
| 12 | |
| 13 | func 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 | } |
no test coverage detected