Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MON-3654: use Go standard errors package instead of github.com/pkg/errors #2224

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
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:
Copy link
Contributor Author

@machine424 machine424 Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see if we could enable strict unmarshalling in golangci

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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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