From ccc9fb69b8f1ebaaf871ad1561052d84a9ccd3a5 Mon Sep 17 00:00:00 2001 From: Mat Schaffer Date: Fri, 27 Jul 2018 17:15:39 +0900 Subject: [PATCH 1/1] Update github.com/DreamItGetIT/statuscake to PR-28 Will rebase this commit once the PR is merged --- .../DreamItGetIT/statuscake/errors.go | 8 +- .../DreamItGetIT/statuscake/responses.go | 80 +++++++++++-------- .../DreamItGetIT/statuscake/tests.go | 13 +-- vendor/vendor.json | 6 +- 4 files changed, 65 insertions(+), 42 deletions(-) diff --git a/vendor/github.com/DreamItGetIT/statuscake/errors.go b/vendor/github.com/DreamItGetIT/statuscake/errors.go index 4c51991..c336647 100644 --- a/vendor/github.com/DreamItGetIT/statuscake/errors.go +++ b/vendor/github.com/DreamItGetIT/statuscake/errors.go @@ -34,12 +34,15 @@ func (e ValidationError) Error() string { } type updateError struct { - Issues interface{} + Issues interface{} + Message string } func (e *updateError) Error() string { var messages []string + messages = append(messages, e.Message) + if issues, ok := e.Issues.(map[string]interface{}); ok { for k, v := range issues { m := fmt.Sprintf("%s %s", k, v) @@ -50,6 +53,9 @@ func (e *updateError) Error() string { m := fmt.Sprint(v) messages = append(messages, m) } + } else if issue, ok := e.Issues.(interface{}); ok { + m := fmt.Sprint(issue) + messages = append(messages, m) } return strings.Join(messages, ", ") diff --git a/vendor/github.com/DreamItGetIT/statuscake/responses.go b/vendor/github.com/DreamItGetIT/statuscake/responses.go index 3cbf36d..e8d4af4 100644 --- a/vendor/github.com/DreamItGetIT/statuscake/responses.go +++ b/vendor/github.com/DreamItGetIT/statuscake/responses.go @@ -1,6 +1,7 @@ package statuscake import ( + "strconv" "strings" ) @@ -21,43 +22,55 @@ type deleteResponse struct { Error string `json:"Error"` } +type contactGroupDetailResponse struct { + ID int `json:"ID"` + Name string `json:"Name"` + Email string `json:"Email"` +} + type detailResponse struct { - Method string `json:"Method"` - TestID int `json:"TestID"` - TestType string `json:"TestType"` - Paused bool `json:"Paused"` - WebsiteName string `json:"WebsiteName"` - URI string `json:"URI"` - ContactID int `json:"ContactID"` - Status string `json:"Status"` - Uptime float64 `json:"Uptime"` - CustomHeader string `json:"CustomHeader"` - UserAgent string `json:"UserAgent"` - CheckRate int `json:"CheckRate"` - Timeout int `json:"Timeout"` - LogoImage string `json:"LogoImage"` - Confirmation int `json:"Confirmation,string"` - WebsiteHost string `json:"WebsiteHost"` - NodeLocations []string `json:"NodeLocations"` - FindString string `json:"FindString"` - DoNotFind bool `json:"DoNotFind"` - LastTested string `json:"LastTested"` - NextLocation string `json:"NextLocation"` - Port int `json:"Port"` - Processing bool `json:"Processing"` - ProcessingState string `json:"ProcessingState"` - ProcessingOn string `json:"ProcessingOn"` - DownTimes int `json:"DownTimes,string"` - Sensitive bool `json:"Sensitive"` - TriggerRate int `json:"TriggerRate,string"` - UseJar int `json:"UseJar"` - PostRaw string `json:"PostRaw"` - FinalEndpoint string `json:"FinalEndpoint"` - FollowRedirect bool `json:"FollowRedirect"` - StatusCodes []string `json:"StatusCodes"` + Method string `json:"Method"` + TestID int `json:"TestID"` + TestType string `json:"TestType"` + Paused bool `json:"Paused"` + WebsiteName string `json:"WebsiteName"` + URI string `json:"URI"` + ContactID int `json:"ContactID"` + ContactGroups []contactGroupDetailResponse `json:"ContactGroups"` + Status string `json:"Status"` + Uptime float64 `json:"Uptime"` + CustomHeader string `json:"CustomHeader"` + UserAgent string `json:"UserAgent"` + CheckRate int `json:"CheckRate"` + Timeout int `json:"Timeout"` + LogoImage string `json:"LogoImage"` + Confirmation int `json:"Confirmation,string"` + WebsiteHost string `json:"WebsiteHost"` + NodeLocations []string `json:"NodeLocations"` + FindString string `json:"FindString"` + DoNotFind bool `json:"DoNotFind"` + LastTested string `json:"LastTested"` + NextLocation string `json:"NextLocation"` + Port int `json:"Port"` + Processing bool `json:"Processing"` + ProcessingState string `json:"ProcessingState"` + ProcessingOn string `json:"ProcessingOn"` + DownTimes int `json:"DownTimes,string"` + Sensitive bool `json:"Sensitive"` + TriggerRate int `json:"TriggerRate,string"` + UseJar int `json:"UseJar"` + PostRaw string `json:"PostRaw"` + FinalEndpoint string `json:"FinalEndpoint"` + FollowRedirect bool `json:"FollowRedirect"` + StatusCodes []string `json:"StatusCodes"` } func (d *detailResponse) test() *Test { + contactGroupIds := make([]string, len(d.ContactGroups)) + for i, v := range d.ContactGroups { + contactGroupIds[i] = strconv.Itoa(v.ID) + } + return &Test{ TestID: d.TestID, TestType: d.TestType, @@ -67,6 +80,7 @@ func (d *detailResponse) test() *Test { CustomHeader: d.CustomHeader, UserAgent: d.UserAgent, ContactID: d.ContactID, + ContactGroup: contactGroupIds, Status: d.Status, Uptime: d.Uptime, CheckRate: d.CheckRate, diff --git a/vendor/github.com/DreamItGetIT/statuscake/tests.go b/vendor/github.com/DreamItGetIT/statuscake/tests.go index a41b0bd..b003d4c 100644 --- a/vendor/github.com/DreamItGetIT/statuscake/tests.go +++ b/vendor/github.com/DreamItGetIT/statuscake/tests.go @@ -12,7 +12,7 @@ const queryStringTag = "querystring" // Test represents a statuscake Test type Test struct { - // ThiTestID is an int, use this to get more details about this test. If not provided will insert a new check, else will update + // TestID is an int, use this to get more details about this test. If not provided will insert a new check, else will update TestID int `json:"TestID" querystring:"TestID" querystringoptions:"omitempty"` // Sent tfalse To Unpause and true To Pause. @@ -33,8 +33,11 @@ type Test struct { // A Port to use on TCP Tests Port int `json:"Port" querystring:"Port"` - // Contact group ID - will return int of contact group used else 0 - ContactID int `json:"ContactID" querystring:"ContactGroup"` + // Contact group ID - deprecated in favor of ContactGroup but still provided in the API detail response + ContactID int `json:"ContactID"` + + // Contact group IDs - will return list of ints or empty if not provided + ContactGroup []string `json:"ContactGroup" querystring:"ContactGroup"` // Current status at last test Status string `json:"Status"` @@ -93,7 +96,7 @@ type Test struct { TriggerRate int `json:"TriggerRate" querystring:"TriggerRate"` // Tags should be seperated by a comma - no spacing between tags (this,is,a set,of,tags) - TestTags string `json:"TestTags" querystring:"TestTags"` + TestTags []string `json:"TestTags" querystring:"TestTags"` // Comma Seperated List of StatusCodes to Trigger Error on (on Update will replace, so send full list each time) StatusCodes string `json:"StatusCodes" querystring:"StatusCodes"` @@ -283,7 +286,7 @@ func (tt *tests) Update(t *Test) (*Test, error) { } if !ur.Success { - return nil, &updateError{Issues: ur.Issues} + return nil, &updateError{Issues: ur.Issues, Message: ur.Message} } t2 := *t diff --git a/vendor/vendor.json b/vendor/vendor.json index 61dd8f3..8342c9b 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -3,10 +3,10 @@ "ignore": "appengine test github.com/hashicorp/nomad/ github.com/hashicorp/terraform/backend", "package": [ { - "checksumSHA1": "6Fo7YzTT+MDviHOsqg6dNw8WrV4=", + "checksumSHA1": "AGuqyTuduSvlOIZ9z0eduvFx3qk=", "path": "github.com/DreamItGetIT/statuscake", - "revision": "f69198f958d7326f3c110dd9be1c21abbd8a87a7", - "revisionTime": "2018-01-30T22:14:43Z" + "revision": "a89107babf68135a67bea923d24e0f4d77b5b3a4", + "revisionTime": "2018-07-27T06:02:48Z" }, { "checksumSHA1": "FIL83loX9V9APvGQIjJpbxq53F0=", -- 2.41.0