mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Include the link in incidents, and set the colours according to user config
Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
parent
391ce432a7
commit
e581646d31
@ -6,6 +6,10 @@ import (
|
||||
"github.com/PagerDuty/go-pagerduty"
|
||||
)
|
||||
|
||||
const (
|
||||
queryTimeFmt = "2006-01-02T15:04:05Z07:00"
|
||||
)
|
||||
|
||||
// GetOnCalls returns a list of people currently on call
|
||||
func GetOnCalls(apiKey string, scheduleIDs []string) ([]pagerduty.OnCall, error) {
|
||||
client := pagerduty.NewClient(apiKey)
|
||||
@ -14,10 +18,8 @@ func GetOnCalls(apiKey string, scheduleIDs []string) ([]pagerduty.OnCall, error)
|
||||
var queryOpts pagerduty.ListOnCallOptions
|
||||
|
||||
queryOpts.ScheduleIDs = scheduleIDs
|
||||
|
||||
timeFmt := "2006-01-02T15:04:05Z07:00"
|
||||
queryOpts.Since = time.Now().Format(timeFmt)
|
||||
queryOpts.Until = time.Now().Format(timeFmt)
|
||||
queryOpts.Since = time.Now().Format(queryTimeFmt)
|
||||
queryOpts.Until = time.Now().Format(queryTimeFmt)
|
||||
|
||||
oncalls, err := client.ListOnCalls(queryOpts)
|
||||
if err != nil {
|
||||
|
@ -79,17 +79,21 @@ func (widget *Widget) contentFrom(onCalls []pagerduty.OnCall, incidents []pagerd
|
||||
// Incidents
|
||||
|
||||
if widget.settings.showIncidents {
|
||||
str += "[yellow] Incidents[white]"
|
||||
str += fmt.Sprintf("[%s] Incidents[white]\n", widget.settings.common.Colors.Subheading)
|
||||
|
||||
if len(incidents) > 0 {
|
||||
for _, incident := range incidents {
|
||||
str += fmt.Sprintf("\n[%s]%s[white]\n", widget.settings.common.Colors.Subheading, incident.Summary)
|
||||
str += fmt.Sprintf("\n [%s]%s[white]\n", widget.settings.common.Colors.Label, tview.Escape(incident.Summary))
|
||||
str += fmt.Sprintf(" Status: %s\n", incident.Status)
|
||||
str += fmt.Sprintf(" Service: %s\n", incident.Service.Summary)
|
||||
str += fmt.Sprintf(" Escalation: %s\n", incident.EscalationPolicy.Summary)
|
||||
str += fmt.Sprintf(" Link: %s\n", incident.HTMLURL)
|
||||
}
|
||||
} else {
|
||||
str += "\n No open incidents\n"
|
||||
}
|
||||
|
||||
str += "\n"
|
||||
}
|
||||
|
||||
onCallTree := make(map[string][]pagerduty.OnCall)
|
||||
@ -117,13 +121,13 @@ func (widget *Widget) contentFrom(onCalls []pagerduty.OnCall, incidents []pagerd
|
||||
sort.Strings(keys)
|
||||
|
||||
if len(keys) > 0 {
|
||||
str += fmt.Sprintf("\n[%s] Schedules[white]\n", widget.settings.common.Colors.Subheading)
|
||||
str += fmt.Sprintf("[%s] Schedules[white]\n", widget.settings.common.Colors.Subheading)
|
||||
|
||||
// Print out policies, and escalation order of users
|
||||
for _, key := range keys {
|
||||
str += fmt.Sprintf(
|
||||
"\n [%s]%s\n",
|
||||
widget.settings.common.Colors.Subheading,
|
||||
widget.settings.common.Colors.Label,
|
||||
key,
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user