From 8467d4b7864f1dc9eee69d75cb19d2d3307ae3bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Michon?= Date: Fri, 12 Apr 2019 10:26:33 +0200 Subject: [PATCH] Better display of the duration before trigger --- alerts/list.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/alerts/list.go b/alerts/list.go index 99b899ba8..054efa1d8 100644 --- a/alerts/list.go +++ b/alerts/list.go @@ -19,11 +19,7 @@ func List(app string) error { t := tablewriter.NewWriter(os.Stdout) headers := []string{"ID", "Active", "Container Type", "Metric", "Limit"} hasRemindEvery := false - hasDurationBeforeTrigger := false for _, alert := range alerts { - if alert.DurationBeforeTrigger != 0 { - hasDurationBeforeTrigger = true - } if alert.RemindEvery != "" { hasRemindEvery = true } @@ -31,31 +27,30 @@ func List(app string) error { if hasRemindEvery { headers = append(headers, "Remind Every") } - if hasDurationBeforeTrigger { - headers = append(headers, "Duration") - } t.SetHeader(headers) for _, alert := range alerts { var above string if alert.SendWhenBelow { - above = "below" + above = "≤" } else { - above = "above" + above = "≥" } + var durationString string + if alert.DurationBeforeTrigger != 0 { + durationString = fmt.Sprintf(" (for %s)", alert.DurationBeforeTrigger) + } + row := []string{ alert.ID, fmt.Sprint(!alert.Disabled), alert.ContainerType, alert.Metric, - fmt.Sprintf("triggers %s %.2f", above, alert.Limit), + fmt.Sprintf("%s %.2f%s", above, alert.Limit, durationString), } if hasRemindEvery { row = append(row, alert.RemindEvery) } - if hasDurationBeforeTrigger { - row = append(row, alert.DurationBeforeTrigger.String()) - } t.Append(row) } t.Render()