Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Exorcise golanci-lint errors (#10949)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxmc99 authored May 29, 2020
1 parent 44ea971 commit 8e28d51
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions monitoring/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//go:generate go build -o /tmp/monitoring-generator
//go:generate /tmp/monitoring-generator

//nolint:golint,gocritic
package main

import (
Expand Down Expand Up @@ -204,10 +205,10 @@ func (o Observable) validate() error {
return fmt.Errorf("%s: a Warning or Critical alert MUST be defined", o.Name)
}
if err := o.Warning.validate(); err != nil && !o.Warning.isEmpty() {
return fmt.Errorf("Warning: %v", err)
return fmt.Errorf("warning: %v", err)
}
if err := o.Critical.validate(); err != nil && !o.Critical.isEmpty() {
return fmt.Errorf("Critical: %v", err)
return fmt.Errorf("critical: %v", err)
}
if l := strings.ToLower(o.PossibleSolutions); strings.Contains(l, "contact support") || strings.Contains(l, "contact us") {
return fmt.Errorf("PossibleSolutions: should not include mentions of contacting support")
Expand Down Expand Up @@ -781,7 +782,7 @@ func goMarkdown(m string) (string, error) {
baseIndention := lines[len(lines)-1]
if strings.TrimSpace(baseIndention) == "" {
if strings.Contains(baseIndention, " ") {
return "", errors.New("Go string literal indention must be tabs")
return "", errors.New("go string literal indention must be tabs")
}
indentionLevel := strings.Count(baseIndention, "\t")
removeIndention := strings.Repeat("\t", indentionLevel+1)
Expand Down Expand Up @@ -845,6 +846,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
// #nosec G306 prometheus runs as nobody
err = ioutil.WriteFile(filepath.Join(grafanaDir, container.Name+".json"), data, 0666)
if err != nil {
log.Fatal(err)
Expand All @@ -866,6 +868,7 @@ func main() {
log.Fatal(err)
}
fileName := strings.Replace(container.Name, "-", "_", -1) + "_alert_rules.yml"
// #nosec G306 grafana runs as UID 472
err = ioutil.WriteFile(filepath.Join(prometheusDir, fileName), data, 0666)
if err != nil {
log.Fatal(err)
Expand All @@ -878,6 +881,7 @@ func main() {
if err != nil {
log.Fatal("reloading Prometheus rules, got error:", err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
log.Fatal("reloading Prometheus rules, got status code:", resp.StatusCode)
}
Expand All @@ -888,6 +892,7 @@ func main() {

if docSolutionsFile != "" {
solutions := generateDocs(containers)
// #nosec G306
err := ioutil.WriteFile(docSolutionsFile, solutions, 0666)
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 8e28d51

Please sign in to comment.