Refactor structs to use map[string]string
This commit is contained in:
parent
1b986078f0
commit
7bb448b5eb
2 changed files with 13 additions and 13 deletions
10
main.go
10
main.go
|
@ -32,16 +32,16 @@ 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"`
|
||||
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"`
|
||||
Labels map[string]string `json:"labels"`
|
||||
Annotations map[string]string `json:"annotations"`
|
||||
Fingerprint fingerprint `json:"fingerprint"`
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ type matcher struct {
|
|||
|
||||
type silenceBody struct {
|
||||
AlertManagerURL string `json:"alertmanagerURL"`
|
||||
Labels map[string]interface{} `json:"labels"`
|
||||
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,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue