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

Function List

notifiers/list.go:15–47  ·  view source on GitHub ↗
(ctx context.Context, app string)

Source from the content-addressed store, hash-verified

13)
14
15func List(ctx context.Context, app string) error {
16 c, err := config.ScalingoClient(ctx)
17 if err != nil {
18 return errors.Wrapf(ctx, err, "fail to get Scalingo client")
19 }
20 notifiers, err := c.NotifiersList(ctx, app)
21 if err != nil {
22 return errors.Wrapf(ctx, err, "list notifiers on app %s", app)
23 }
24
25 t := tablewriter.NewWriter(os.Stdout)
26 t.Header([]string{"ID", "Type", "Name", "Enabled", "Send all events", "Selected events"})
27
28 eventTypes, err := c.EventTypesList(ctx)
29 if err != nil {
30 return errors.Wrapf(ctx, err, "fail to list event types")
31 }
32
33 for _, notifier := range notifiers {
34 selectedEvents := "All"
35 if !notifier.GetSendAllEvents() {
36 selectedEvents = eventTypesToString(eventTypes, notifier.GetSelectedEventIDs())
37 }
38 t.Append([]string{
39 notifier.GetID(), string(notifier.GetType()), notifier.GetName(),
40 strconv.FormatBool(notifier.IsActive()), strconv.FormatBool(notifier.GetSendAllEvents()),
41 selectedEvents,
42 })
43 }
44 t.Render()
45
46 return nil
47}
48
49func eventTypesToString(eventTypes []scalingo.EventType, ids []string) string {
50 res := ""

Callers 1

notifiers.goFile · 0.92

Calls 3

ScalingoClientFunction · 0.92
eventTypesToStringFunction · 0.85
RenderMethod · 0.65

Tested by

no test coverage detected