File: notifications_table.go

package info (click to toggle)
crowdsec 1.4.6-10.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,500 kB
  • sloc: sh: 2,870; makefile: 386; python: 74
file content (25 lines) | stat: -rw-r--r-- 601 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package main

import (
	"io"
	"strings"

	"github.com/aquasecurity/table"
)

func notificationListTable(out io.Writer, ncfgs map[string]NotificationsCfg) {
	t := newLightTable(out)
	t.SetHeaders("Name", "Type", "Profile name")
	t.SetHeaderAlignment(table.AlignLeft, table.AlignLeft, table.AlignLeft)
	t.SetAlignment(table.AlignLeft, table.AlignLeft, table.AlignLeft)

	for _, b := range ncfgs {
		profilesList := []string{}
		for _, p := range b.Profiles {
			profilesList = append(profilesList, p.Name)
		}
		t.AddRow(b.Config.Name, b.Config.Type, strings.Join(profilesList, ", "))
	}

	t.Render()
}