Skip to content

Commit

Permalink
Merge pull request #2224 from machine424/errors
Browse files Browse the repository at this point in the history
MON-3654: use Go standard errors package instead of github.com/pkg/errors
  • Loading branch information
openshift-merge-bot[bot] committed Jan 12, 2024
2 parents 482dccc + 06fa2cf commit 7ffd018
Show file tree
Hide file tree
Showing 55 changed files with 1,231 additions and 1,037 deletions.
18 changes: 14 additions & 4 deletions .golangci.yaml
Expand Up @@ -9,7 +9,9 @@ run:
linters:
disable-all: true
enable:
- depguard
- errcheck
- errorlint
- bodyclose
- exportloopref
- gosimple
Expand All @@ -27,8 +29,16 @@ linters:
- whitespace
- gci

linter-settings:
linters-settings:
depguard:
rules:
# Name of a rule.
main:
deny:
- pkg: "github.com/pkg/errors"
desc: "Use 'errors' or 'fmt' instead of github.com/pkg/errors"
gci:
- standard
- default
- prefix(github.com/openshift/cluster-monitoring-operator)
sections:
- standard
- default
- prefix(github.com/openshift/cluster-monitoring-operator)
7 changes: 4 additions & 3 deletions cmd/operator/main.go
Expand Up @@ -25,13 +25,14 @@ import (
"strings"
"syscall"

"github.com/openshift/cluster-monitoring-operator/pkg/manifests"
"github.com/openshift/cluster-monitoring-operator/pkg/metrics"
cmo "github.com/openshift/cluster-monitoring-operator/pkg/operator"
"golang.org/x/sync/errgroup"
"k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog/v2"

"github.com/openshift/cluster-monitoring-operator/pkg/manifests"
"github.com/openshift/cluster-monitoring-operator/pkg/metrics"
cmo "github.com/openshift/cluster-monitoring-operator/pkg/operator"
)

type images map[string]string
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -12,7 +12,6 @@ require (
github.com/openshift/api v0.0.0-20231109185848-6cd72e415ddb
github.com/openshift/client-go v0.0.0-20230926161409-848405da69e1
github.com/openshift/library-go v0.0.0-20231128230659-785a9313da6c
github.com/pkg/errors v0.9.1
github.com/prometheus-operator/prometheus-operator v0.70.0
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.70.0
github.com/prometheus-operator/prometheus-operator/pkg/client v0.70.0
Expand Down Expand Up @@ -107,6 +106,7 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus-community/prom-label-proxy v0.7.0 // indirect
github.com/prometheus/alertmanager v0.26.0 // indirect
Expand Down
7 changes: 3 additions & 4 deletions pkg/alert/relabel_controller.go
Expand Up @@ -21,8 +21,6 @@ import (
"strings"

osmv1 "github.com/openshift/api/monitoring/v1"
"github.com/openshift/cluster-monitoring-operator/pkg/client"
"github.com/pkg/errors"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/relabel"
"gopkg.in/yaml.v3"
Expand All @@ -32,6 +30,8 @@ import (
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"

"github.com/openshift/cluster-monitoring-operator/pkg/client"
)

const (
Expand Down Expand Up @@ -182,8 +182,7 @@ func (c *RelabelConfigController) processNextWorkItem(ctx context.Context) bool
defer c.queue.Done(key)

if err := c.sync(ctx, key.(string)); err != nil {
utilruntime.HandleError(errors.Wrap(err,
fmt.Sprintf("Error syncing AlertRelabelConfig (%s)", key.(string))))
utilruntime.HandleError(fmt.Errorf("Error syncing AlertRelabelConfig (%s): %w", key.(string), err))

// Re-queue failed sync.
c.queue.AddRateLimited(key)
Expand Down
7 changes: 3 additions & 4 deletions pkg/alert/rule_controller.go
Expand Up @@ -22,8 +22,6 @@ import (
"time"

osmv1 "github.com/openshift/api/monitoring/v1"
"github.com/openshift/cluster-monitoring-operator/pkg/client"
"github.com/pkg/errors"
monv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -33,6 +31,8 @@ import (
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
"k8s.io/utils/ptr"

"github.com/openshift/cluster-monitoring-operator/pkg/client"
)

const (
Expand Down Expand Up @@ -229,8 +229,7 @@ func (rc *RuleController) processNextWorkItem(ctx context.Context) bool {
defer rc.queue.Done(key)

if err := rc.sync(ctx, key.(string)); err != nil {
utilruntime.HandleError(errors.Wrap(err,
fmt.Sprintf("Error syncing AlertingRule (%s)", key.(string))))
utilruntime.HandleError(fmt.Errorf("Error syncing AlertingRule (%s): %w", key.(string), err))

// Re-queue failed sync.
rc.queue.AddRateLimited(key)
Expand Down

0 comments on commit 7ffd018

Please sign in to comment.