From 7bb448b5eb585544d8bf8af98417c7d0af069f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Sun, 12 Feb 2023 14:40:32 +0100 Subject: [PATCH] Refactor structs to use map[string]string --- main.go | 20 ++++++++++---------- silence.go | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index 97c297b..ea9396c 100644 --- a/main.go +++ b/main.go @@ -30,19 +30,19 @@ type receiver struct { } type payload struct { - Status string `json:"status"` - Alerts []alert `json:"alerts"` - GroupLabels map[string]interface{} `json:"groupLabels"` - CommonLabels map[string]interface{} `json:"commonLabels"` - CommonAnnotations map[string]interface{} `json:"commonAnnotations"` - ExternalURL string `json:"externalURL"` + Status string `json:"status"` + Alerts []alert `json:"alerts"` + GroupLabels map[string]string `json:"groupLabels"` + CommonLabels map[string]string `json:"commonLabels"` + CommonAnnotations map[string]string `json:"commonAnnotations"` + ExternalURL string `json:"externalURL"` } type alert struct { - Status string `json:"status"` - Labels map[string]interface{} `json:"labels"` - Annotations map[string]interface{} `json:"annotations"` - Fingerprint fingerprint `json:"fingerprint"` + Status string `json:"status"` + Labels map[string]string `json:"labels"` + Annotations map[string]string `json:"annotations"` + Fingerprint fingerprint `json:"fingerprint"` } type notification struct { diff --git a/silence.go b/silence.go index ffc23db..b5c5a6b 100644 --- a/silence.go +++ b/silence.go @@ -28,8 +28,8 @@ type matcher struct { } type silenceBody struct { - AlertManagerURL string `json:"alertmanagerURL"` - Labels map[string]interface{} `json:"labels"` + AlertManagerURL string `json:"alertmanagerURL"` + Labels map[string]string `json:"labels"` } func (rcv *receiver) handleSilences(w http.ResponseWriter, r *http.Request) { @@ -64,7 +64,7 @@ func (rcv *receiver) handleSilences(w http.ResponseWriter, r *http.Request) { for key, value := range sb.Labels { m := matcher{ Name: key, - Value: value.(string), + Value: value, IsRegex: false, IsEqual: true, }