notifications_table.go 601 B

12345678910111213141516171819202122232425
  1. package main
  2. import (
  3. "io"
  4. "strings"
  5. "github.com/aquasecurity/table"
  6. )
  7. func notificationListTable(out io.Writer, ncfgs map[string]NotificationsCfg) {
  8. t := newLightTable(out)
  9. t.SetHeaders("Name", "Type", "Profile name")
  10. t.SetHeaderAlignment(table.AlignLeft, table.AlignLeft, table.AlignLeft)
  11. t.SetAlignment(table.AlignLeft, table.AlignLeft, table.AlignLeft)
  12. for _, b := range ncfgs {
  13. profilesList := []string{}
  14. for _, p := range b.Profiles {
  15. profilesList = append(profilesList, p.Name)
  16. }
  17. t.AddRow(b.Config.Name, b.Config.Type, strings.Join(profilesList, ", "))
  18. }
  19. t.Render()
  20. }