From 85cbb2caa1b602308e1c3aac23a5eb736f059beb Mon Sep 17 00:00:00 2001 From: Silke Hofstra Date: Sun, 15 Oct 2023 14:40:56 +0200 Subject: [PATCH] Fix linting issues --- .golangci.yaml | 5 +++++ pkg/alertmanager/message.go | 18 +++++++++--------- pkg/bot/matrix.go | 6 +++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index c45e4c9..42f3170 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -98,6 +98,11 @@ linters-settings: stylecheck: checks: [all] + tagliatelle: + case: + rules: + json: goCamel + wrapcheck: ignoreSigs: - .Errorf( diff --git a/pkg/alertmanager/message.go b/pkg/alertmanager/message.go index 60f1812..bb3d0af 100644 --- a/pkg/alertmanager/message.go +++ b/pkg/alertmanager/message.go @@ -20,15 +20,15 @@ const ( // Message represents a message received from Alertmanager via webhook. type Message struct { - Version string - GroupKey string - Status string - Receiver string - GroupLabels map[string]string - CommonLabels map[string]string - CommonAnnotations map[string]string - ExternalURL string - Alerts []*Alert + Version string `json:"version"` + GroupKey string `json:"groupKey"` + Status string `json:"status"` + Receiver string `json:"receiver"` + GroupLabels map[string]string `json:"groupLabels"` + CommonLabels map[string]string `json:"commonLabels"` + CommonAnnotations map[string]string `json:"commonAnnotations"` + ExternalURL string `json:"externalURL"` + Alerts []*Alert `json:"alerts"` } // Alert represents an Alert received from Alertmanager via webhook. diff --git a/pkg/bot/matrix.go b/pkg/bot/matrix.go index 0ec8b9d..f55536b 100644 --- a/pkg/bot/matrix.go +++ b/pkg/bot/matrix.go @@ -52,7 +52,7 @@ func NewClient(config *ClientConfig, formatter *Formatter) (client *Client, err // Create Alertmanager client client.Alertmanager, err = alertmanager.NewClient(config.AlertManagerURL) if err != nil { - return + return nil, fmt.Errorf("error creating Alertmanager client: %w", err) } // Matrix bot config @@ -65,7 +65,7 @@ func NewClient(config *ClientConfig, formatter *Formatter) (client *Client, err // Create Matrix client client.Matrix, err = bot.NewClient(config.Homeserver, config.UserID, config.Token, matrixConfig) if err != nil { - return + return nil, fmt.Errorf("error creating Matrix client: %w", err) } // Create room list @@ -78,7 +78,7 @@ func NewClient(config *ClientConfig, formatter *Formatter) (client *Client, err client.Matrix.SetCommand("list", client.listCommand()) client.Matrix.SetCommand("silence", client.silenceCommand()) - return + return client, nil } // mainCommand returns the `alert` bot command.