pagerduty-cachet

git clone git://archive.git.mtrnord.blog/MTRNord/pagerduty-cachet.git
Log | Files | Refs | README

commit a42845fea60890fcfb564bb4e0182cc7af9f7896
parent bd350f044de1067f4264acc8fc2af581dd716dcb
Author: MTRNord <mtrnord1@gmail.com>
Date:   Wed, 12 Mar 2025 18:35:50 +0100

Fix component status when an issue gets resolved

Diffstat:
Mserver.go | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/server.go b/server.go @@ -435,6 +435,26 @@ func handler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) return } + + // Update the component status to operational + _, cachetResp, err = client.Components.Update(cachetIncident.ComponentID, &cachet_go.Component{ + ID: cachetIncident.ComponentID, + Status: cachet_go.ComponentStatusOperational, + }) + if err != nil { + log.Println(err) + // Print the cachetResp body as a string to the console + bytedata, err := io.ReadAll(cachetResp.Body) + r.Body.Close() + if err != nil { + log.Println("error reading cachetResp body") + w.WriteHeader(http.StatusInternalServerError) + return + } + log.Println(string(bytedata)) + w.WriteHeader(http.StatusInternalServerError) + return + } } else { log.Println("unknown event type")