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

Function Remove

logdrains/remove.go:17–66  ·  view source on GitHub ↗
(ctx context.Context, app, database string, opts RemoveAddonOpts)

Source from the content-addressed store, hash-verified

15}
16
17func Remove(ctx context.Context, app, database string, opts RemoveAddonOpts) error {
18 c, err := config.ScalingoClient(ctx)
19 if err != nil {
20 return errors.Wrapf(ctx, err, "fail to get Scalingo client to remove a log drain from the application")
21 }
22
23 if database != "" {
24 err := c.LogDrainAddonRemove(ctx, app, database, opts.URL)
25 if err != nil {
26 return errors.Wrapf(ctx, err, "remove the log drain from the database %s", database)
27 }
28 io.Status("The log drain", opts.URL, "has been deleted from the database", database)
29 return nil
30 }
31
32 if opts.AddonID != "" {
33 // addon only
34 err := c.LogDrainAddonRemove(ctx, app, opts.AddonID, opts.URL)
35 if err != nil {
36 return errors.Wrapf(ctx, err, "fail to remove the log drain from the addon %s", opts.AddonID)
37 }
38 io.Status("The log drain", opts.URL, "has been deleted from the addon", opts.AddonID)
39 return nil
40 }
41
42 err = c.LogDrainRemove(ctx, app, opts.URL)
43 if err != nil {
44 io.Status("fail to remove the log drain from the application:", app, "\n\t", err)
45 } else {
46 io.Status("Log drain", opts.URL, "has been deleted from the application", app)
47 }
48
49 if !opts.OnlyApp {
50 addons, err := c.AddonsList(ctx, app)
51 if err != nil {
52 return errors.Wrapf(ctx, err, "fail to list addons to remove log drain")
53 }
54
55 for _, addon := range addons {
56 err := c.LogDrainAddonRemove(ctx, app, addon.ID, opts.URL)
57 if err != nil {
58 io.Status("fail to remove the log drain from the addon:", addon.AddonProvider.Name, "\n\t", err)
59 } else {
60 io.Status("Log drain", opts.URL, "has been deleted from the addon", addon.AddonProvider.Name)
61 }
62 }
63 }
64
65 return nil
66}

Callers 1

log_drains.goFile · 0.92

Calls 2

ScalingoClientFunction · 0.92
StatusFunction · 0.92

Tested by

no test coverage detected