Skip to content

Commit

Permalink
Fix minor linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
silkeh committed Aug 7, 2022
1 parent 83d918e commit a21e5b3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cmd/alertmanager_matrix/alertmanager_matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func setStringFromEnv(target *string, env string) {
}

func loadFile(fileName string) string {
contents, err := os.ReadFile(fileName) // nolint:gosec // contents inclusion is the point
contents, err := os.ReadFile(fileName) //nolint:gosec // contents inclusion is the point
if err != nil {
log.Fatalf("Unable to read file %q: %s", fileName, err)
}
Expand All @@ -59,7 +59,7 @@ func loadFile(fileName string) string {
}

func mapFromYAMLFile(fileName string) map[string]string {
file, err := os.Open(fileName) // nolint:gosec // file inclusion is the point
file, err := os.Open(fileName) //nolint:gosec // file inclusion is the point
if err != nil {
log.Fatalf("Unable to open YAML file %q: %s", fileName, err)
}
Expand Down
19 changes: 9 additions & 10 deletions pkg/bot/formatting.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (

// Default alert template values.
const (
DefaultTextTemplate = "{{ range .Alerts }}{{.StatusString|icon}} {{.StatusString|upper}} {{.AlertName}}: {{.Summary}}{{if ne .Fingerprint \"\"}} ({{.Fingerprint}}){{end}}{{if $.ShowLabels}}, labels: {{.LabelString}}{{end}}\n{{ end -}}" // nolint:lll
DefaultHTMLTemplate = `{{ range .Alerts }}<font color="{{.StatusString|color}}">{{.StatusString|icon}} <b>{{.StatusString|upper}}</b> {{.AlertName}}:</font> {{.Summary}}{{if ne .Fingerprint ""}} ({{.Fingerprint}}){{end}}{{if $.ShowLabels}}<br/><b>Labels:</b> <code>{{.LabelString}}</code>{{end}}<br/>{{- end -}}` // nolint:lll
DefaultTextTemplate = "{{ range .Alerts }}{{.StatusString|icon}} {{.StatusString|upper}} {{.AlertName}}: {{.Summary}}{{if ne .Fingerprint \"\"}} ({{.Fingerprint}}){{end}}{{if $.ShowLabels}}, labels: {{.LabelString}}{{end}}\n{{ end -}}" //nolint:lll
DefaultHTMLTemplate = `{{ range .Alerts }}<font color="{{.StatusString|color}}">{{.StatusString|icon}} <b>{{.StatusString|upper}}</b> {{.AlertName}}:</font> {{.Summary}}{{if ne .Fingerprint ""}} ({{.Fingerprint}}){{end}}{{if $.ShowLabels}}<br/><b>Labels:</b> <code>{{.LabelString}}</code>{{end}}<br/>{{- end -}}` //nolint:lll
)

// Default color and icon values.
var (
DefaultColors = map[string]string{ // nolint:gochecknoglobals
DefaultColors = map[string]string{ //nolint:gochecknoglobals
"alert": "black",
"information": "blue",
"warning": "orange",
Expand All @@ -28,7 +28,7 @@ var (
"silenced": "gray",
}

DefaultIcons = map[string]string{ // nolint:gochecknoglobals
DefaultIcons = map[string]string{ //nolint:gochecknoglobals
"alert": "🔔️",
"information": "ℹ️",
"warning": "⚠️",
Expand All @@ -51,12 +51,11 @@ type Formatter struct {
//
// The following functions are registered for use in the templates:
//
// icon: returns the icon for the given string.
// color: returns the color for the given string.
// upper: converts the given string to uppercase.
// lower: converts the given string to lowercase.
// title: converts the given string to title case.
//
// icon: returns the icon for the given string.
// color: returns the color for the given string.
// upper: converts the given string to uppercase.
// lower: converts the given string to lowercase.
// title: converts the given string to title case.
func NewFormatter(textTemplate, htmlTemplate string, colors, icons map[string]string) *Formatter {
if textTemplate == "" {
textTemplate = DefaultTextTemplate
Expand Down
1 change: 0 additions & 1 deletion pkg/bot/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/prometheus/alertmanager/pkg/labels"
"github.com/prometheus/alertmanager/types"

bot "gitlab.com/silkeh/matrix-bot"

"github.com/silkeh/alertmanager_matrix/pkg/alertmanager"
Expand Down

0 comments on commit a21e5b3

Please sign in to comment.