fix component status parsing

The Cachet API returns component status as a string,
but cachet-monitor attempts to parse it as int,
resulting in "cannot unmarshal string into Go value of type int".
This applies at least as early as cachet 2.3.12 - 29/06/2017.
This commit is contained in:
Cristi Vîjdea
2017-10-05 21:02:13 +00:00
parent 0e93d140e8
commit c2c9898d68

View File

@@ -82,7 +82,7 @@ func (incident *Incident) GetComponentStatus(cfg *CachetMonitor) (int, error) {
} }
var data struct { var data struct {
Status int `json:"status"` Status int `json:"status,string"`
} }
if err := json.Unmarshal(body.Data, &data); err != nil { if err := json.Unmarshal(body.Data, &data); err != nil {
return 0, fmt.Errorf("Cannot parse component body: %v. Err = %v", string(body.Data), err) return 0, fmt.Errorf("Cannot parse component body: %v. Err = %v", string(body.Data), err)