1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Make CI happy

This commit is contained in:
Miha Frangež 2020-10-04 10:51:39 +02:00 committed by Chris Cummer
parent 7f05fbcda5
commit 6908e744e1

View File

@ -1,9 +1,9 @@
package uptimerobot package uptimerobot
import ( import (
"fmt"
"errors"
"encoding/json" "encoding/json"
"errors"
"fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
@ -92,11 +92,9 @@ func (widget *Widget) contentFrom(monitors []Monitor) string {
switch monitor.State { switch monitor.State {
case 2: case 2:
prefix += "[green] + " prefix += "[green] + "
break
case 8: case 8:
case 9: case 9:
prefix += "[red] - " prefix += "[red] - "
break
default: default:
prefix += "[yellow] ~ " prefix += "[yellow] ~ "
} }
@ -138,19 +136,22 @@ func (widget *Widget) getMonitors() ([]Monitor, error) {
// First pass to read the status // First pass to read the status
c := make(map[string]json.RawMessage) c := make(map[string]json.RawMessage)
json.Unmarshal([]byte(body), &c) err_j1 := json.Unmarshal([]byte(body), &c)
stat := string(c["stat"]) if err_j1 != nil {
if stat != `"ok"` { return nil, err_j1
}
if string(c["stat"]) != `"ok"` {
return nil, errors.New(string(body)) return nil, errors.New(string(body))
} }
// Second pass to get the actual info // Second pass to get the actual info
var monitors []Monitor var monitors []Monitor
err_j := json.Unmarshal(c["monitors"], &monitors) err_j2 := json.Unmarshal(c["monitors"], &monitors)
if err_j != nil { if err_j2 != nil {
return nil, err_j return nil, err_j2
} }
return monitors, nil return monitors, nil