mirror of
https://github.com/coreos/prometheus-operator.git
synced 2026-02-05 15:46:31 +01:00
*: fix errcheck errors
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
@@ -2,10 +2,15 @@ run:
|
||||
deadline: 10m
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- golint
|
||||
- gosimple
|
||||
- govet
|
||||
- staticcheck
|
||||
- unused
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
- path: _test.go
|
||||
linters:
|
||||
- errcheck
|
||||
|
||||
linters-settings:
|
||||
errcheck:
|
||||
exclude: scripts/errcheck_excludes.txt
|
||||
|
||||
@@ -206,7 +206,8 @@ func init() {
|
||||
|
||||
func Main() int {
|
||||
versionutil.RegisterFlags()
|
||||
flagset.Parse(os.Args[1:])
|
||||
// No need to check for errors because Parse would exit on error.
|
||||
_ = flagset.Parse(os.Args[1:])
|
||||
|
||||
if versionutil.ShouldPrintVersion() {
|
||||
versionutil.Print(os.Stdout, "prometheus-operator")
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
http.ListenAndServe(":5001", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_ = http.ListenAndServe(":5001", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Println("Alertmanager Notification Payload Received")
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -887,12 +887,15 @@ func (c *Operator) selectAlertmanagerConfigs(ctx context.Context, am *monitoring
|
||||
}
|
||||
|
||||
for _, ns := range namespaces {
|
||||
c.alrtCfgInfs.ListAllByNamespace(ns, amConfigSelector, func(obj interface{}) {
|
||||
err := c.alrtCfgInfs.ListAllByNamespace(ns, amConfigSelector, func(obj interface{}) {
|
||||
k, ok := c.keyFunc(obj)
|
||||
if ok {
|
||||
amConfigs[k] = obj.(*monitoringv1alpha1.AlertmanagerConfig)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to list alertmanager configs in namespace %s", ns)
|
||||
}
|
||||
}
|
||||
|
||||
var rejected int
|
||||
|
||||
@@ -1633,12 +1633,15 @@ func (c *Operator) selectServiceMonitors(ctx context.Context, p *monitoringv1.Pr
|
||||
level.Debug(c.logger).Log("msg", "filtering namespaces to select ServiceMonitors from", "namespaces", strings.Join(namespaces, ","), "namespace", p.Namespace, "prometheus", p.Name)
|
||||
|
||||
for _, ns := range namespaces {
|
||||
c.smonInfs.ListAllByNamespace(ns, servMonSelector, func(obj interface{}) {
|
||||
err := c.smonInfs.ListAllByNamespace(ns, servMonSelector, func(obj interface{}) {
|
||||
k, ok := c.keyFunc(obj)
|
||||
if ok {
|
||||
serviceMonitors[k] = obj.(*monitoringv1.ServiceMonitor)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to list service monitors in namespace %s", ns)
|
||||
}
|
||||
}
|
||||
|
||||
var rejected int
|
||||
@@ -1729,12 +1732,15 @@ func (c *Operator) selectPodMonitors(ctx context.Context, p *monitoringv1.Promet
|
||||
level.Debug(c.logger).Log("msg", "filtering namespaces to select PodMonitors from", "namespaces", strings.Join(namespaces, ","), "namespace", p.Namespace, "prometheus", p.Name)
|
||||
|
||||
for _, ns := range namespaces {
|
||||
c.pmonInfs.ListAllByNamespace(ns, podMonSelector, func(obj interface{}) {
|
||||
err := c.pmonInfs.ListAllByNamespace(ns, podMonSelector, func(obj interface{}) {
|
||||
k, ok := c.keyFunc(obj)
|
||||
if ok {
|
||||
podMonitors[k] = obj.(*monitoringv1.PodMonitor)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to list pod monitors in namespace %s", ns)
|
||||
}
|
||||
}
|
||||
|
||||
var rejected int
|
||||
@@ -1817,11 +1823,14 @@ func (c *Operator) selectProbes(ctx context.Context, p *monitoringv1.Prometheus,
|
||||
level.Debug(c.logger).Log("msg", "filtering namespaces to select Probes from", "namespaces", strings.Join(namespaces, ","), "namespace", p.Namespace, "prometheus", p.Name)
|
||||
|
||||
for _, ns := range namespaces {
|
||||
c.probeInfs.ListAllByNamespace(ns, bMonSelector, func(obj interface{}) {
|
||||
err := c.probeInfs.ListAllByNamespace(ns, bMonSelector, func(obj interface{}) {
|
||||
if k, ok := c.keyFunc(obj); ok {
|
||||
probes[k] = obj.(*monitoringv1.Probe)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to list probes in namespace %s", ns)
|
||||
}
|
||||
}
|
||||
|
||||
var rejected int
|
||||
|
||||
5
scripts/errcheck_excludes.txt
Normal file
5
scripts/errcheck_excludes.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
// Any error in HTTP handlers is handled by the server itself.
|
||||
(net/http.ResponseWriter).Write
|
||||
|
||||
// Never check for logger errors.
|
||||
(github.com/go-kit/kit/log.Logger).Log
|
||||
@@ -71,7 +71,7 @@ func main() {
|
||||
|
||||
fmt.Printf("listening for metric requests on '%v' protected via basic auth or bearer token\n", address)
|
||||
|
||||
http.ListenAndServe(address, nil)
|
||||
_ = http.ListenAndServe(address, nil)
|
||||
}
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user