Merge pull request #215 from evrardjp/make-lint-happier

Make go lint on cmd folder happier
This commit is contained in:
Daniel Holbach
2020-11-09 11:49:51 +01:00
committed by GitHub
4 changed files with 5 additions and 30 deletions
-1
View File
@@ -1,4 +1,3 @@
cmd/kured/kured
cmd/prom-active-alerts/prom-active-alerts
vendor
build
+3 -4
View File
@@ -149,10 +149,9 @@ func rebootRequired() bool {
if sentinelExists() {
log.Infof("Reboot required")
return true
} else {
log.Infof("Reboot not required")
return false
}
log.Infof("Reboot not required")
return false
}
func rebootBlocked(client *kubernetes.Clientset, nodeID string) bool {
@@ -332,7 +331,7 @@ func rebootAsRequired(nodeID string, window *timewindow.TimeWindow, TTL time.Dur
source := rand.NewSource(time.Now().UnixNano())
tick := delaytick.New(source, period)
for _ = range tick {
for range tick {
if window.Contains(time.Now()) && rebootRequired() && !rebootBlocked(client, nodeID) {
node, err := client.CoreV1().Nodes().Get(context.TODO(), nodeID, metav1.GetOptions{})
if err != nil {
-23
View File
@@ -1,23 +0,0 @@
package main
import (
"fmt"
"log"
"os"
"regexp"
"github.com/weaveworks/kured/pkg/alerts"
)
func main() {
if len(os.Args) != 3 {
log.Fatalf("USAGE: %s <prometheusURL> <filterRegexp>", os.Args[0])
}
count, err := alerts.PrometheusCountActive(os.Args[1], regexp.MustCompile(os.Args[2]))
if err != nil {
log.Fatal(err)
}
fmt.Println(count)
}
+2 -2
View File
@@ -12,7 +12,7 @@ import (
"github.com/prometheus/common/model"
)
// Returns a list of names of active (e.g. pending or firing) alerts, filtered
// PrometheusActiveAlerts returns a list of names of active (e.g. pending or firing) alerts, filtered
// by the supplied regexp.
func PrometheusActiveAlerts(prometheusURL string, filter *regexp.Regexp) ([]string, error) {
client, err := api.NewClient(api.Config{Address: prometheusURL})
@@ -39,7 +39,7 @@ func PrometheusActiveAlerts(prometheusURL string, filter *regexp.Regexp) ([]stri
}
var activeAlerts []string
for activeAlert, _ := range activeAlertSet {
for activeAlert := range activeAlertSet {
activeAlerts = append(activeAlerts, activeAlert)
}
sort.Sort(sort.StringSlice(activeAlerts))