Skip to content

Commit ba64e8b

Browse files
chore(deps): code cleanup, do not use pkg/errors (#5335)
Signed-off-by: ivan katliarchuk <[email protected]>
1 parent adf9fb2 commit ba64e8b

16 files changed

+46
-39
lines changed

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,7 @@ helm-template:
201201
helm-lint:
202202
scripts/helm-tools.sh --schema
203203
scripts/helm-tools.sh --docs
204+
205+
.PHONY: go-dependency
206+
go-dependency: ## Dependency maintanance
207+
go mod tidy

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ require (
5050
github.com/oracle/oci-go-sdk/v65 v65.89.1
5151
github.com/ovh/go-ovh v1.7.0
5252
github.com/patrickmn/go-cache v2.1.0+incompatible
53-
github.com/pkg/errors v0.9.1
5453
github.com/pluralsh/gqlclient v1.12.2
5554
github.com/projectcontour/contour v1.30.3
5655
github.com/prometheus/client_golang v1.22.0
@@ -170,6 +169,7 @@ require (
170169
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
171170
github.com/peterhellberg/link v1.1.0 // indirect
172171
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
172+
github.com/pkg/errors v0.9.1 // indirect
173173
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
174174
github.com/prometheus/client_model v0.6.1 // indirect
175175
github.com/prometheus/common v0.62.0 // indirect

provider/oci/oci.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package oci
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223
"os"
2324
"strings"
@@ -27,7 +28,6 @@ import (
2728
"github.com/oracle/oci-go-sdk/v65/common"
2829
"github.com/oracle/oci-go-sdk/v65/common/auth"
2930
"github.com/oracle/oci-go-sdk/v65/dns"
30-
"github.com/pkg/errors"
3131
log "github.com/sirupsen/logrus"
3232

3333
"sigs.k8s.io/external-dns/endpoint"

provider/oci/oci_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ package oci
1818

1919
import (
2020
"context"
21+
"errors"
22+
"fmt"
2123
"sort"
2224
"strings"
2325
"testing"
2426
"time"
2527

2628
"github.com/oracle/oci-go-sdk/v65/common"
2729
"github.com/oracle/oci-go-sdk/v65/dns"
28-
"github.com/pkg/errors"
2930
"github.com/stretchr/testify/require"
3031

3132
"sigs.k8s.io/external-dns/endpoint"
@@ -621,7 +622,7 @@ func (c *mutableMockOCIDNSClient) PatchZoneRecords(ctx context.Context, request
621622
case dns.RecordOperationOperationRemove:
622623
delete(records, k)
623624
default:
624-
err = errors.Errorf("unsupported operation %q", op.Operation)
625+
err = fmt.Errorf("unsupported operation %q", op.Operation)
625626
return
626627
}
627628
}

source/ambassador_host.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ package source
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223
"sort"
2324
"strings"
2425

2526
ambassador "github.com/datawire/ambassador/pkg/api/getambassador.io/v2"
26-
"github.com/pkg/errors"
2727
log "github.com/sirupsen/logrus"
2828
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2929
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -96,7 +96,7 @@ func NewAmbassadorHostSource(
9696

9797
uc, err := newUnstructuredConverter()
9898
if err != nil {
99-
return nil, errors.Wrapf(err, "failed to setup Unstructured Converter")
99+
return nil, fmt.Errorf("failed to setup Unstructured Converter: %w", err)
100100
}
101101

102102
return &ambassadorHostSource{
@@ -137,10 +137,10 @@ func (sc *ambassadorHostSource) Endpoints(ctx context.Context) ([]*endpoint.Endp
137137
// Filter Ambassador Hosts
138138
ambassadorHosts, err = sc.filterByAnnotations(ambassadorHosts)
139139
if err != nil {
140-
return nil, errors.Wrap(err, "failed to filter Ambassador Hosts by annotation")
140+
return nil, fmt.Errorf("failed to filter Ambassador Hosts by annotation: %w", err)
141141
}
142142

143-
endpoints := []*endpoint.Endpoint{}
143+
var endpoints []*endpoint.Endpoint
144144

145145
for _, host := range ambassadorHosts {
146146
fullname := fmt.Sprintf("%s/%s", host.Namespace, host.Name)
@@ -260,7 +260,7 @@ func parseAmbLoadBalancerService(service string) (namespace, name string, err er
260260
}
261261

262262
// If we got here, this string is simply ill-formatted. Return an error.
263-
return "", "", errors.New(fmt.Sprintf("invalid external-dns service: %s", service))
263+
return "", "", fmt.Errorf("invalid external-dns service: %s", service)
264264
}
265265

266266
func (sc *ambassadorHostSource) AddEventHandler(ctx context.Context, handler func()) {

source/contour_httpproxy.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ package source
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223
"sort"
2324
"text/template"
2425

25-
"github.com/pkg/errors"
2626
projectcontour "github.com/projectcontour/contour/apis/projectcontour/v1"
2727
log "github.com/sirupsen/logrus"
2828
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -87,7 +87,7 @@ func NewContourHTTPProxySource(
8787

8888
uc, err := NewUnstructuredConverter()
8989
if err != nil {
90-
return nil, errors.Wrap(err, "failed to setup Unstructured Converter")
90+
return nil, fmt.Errorf("failed to setup Unstructured Converter: %w", err)
9191
}
9292

9393
return &httpProxySource{
@@ -121,14 +121,14 @@ func (sc *httpProxySource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint,
121121
hpConverted := &projectcontour.HTTPProxy{}
122122
err := sc.unstructuredConverter.scheme.Convert(unstructuredHP, hpConverted, nil)
123123
if err != nil {
124-
return nil, errors.Wrap(err, "failed to convert to HTTPProxy")
124+
return nil, fmt.Errorf("failed to convert to HTTPProxy: %w", err)
125125
}
126126
httpProxies = append(httpProxies, hpConverted)
127127
}
128128

129129
httpProxies, err = sc.filterByAnnotations(httpProxies)
130130
if err != nil {
131-
return nil, errors.Wrap(err, "failed to filter HTTPProxies")
131+
return nil, fmt.Errorf("failed to filter HTTPProxies: %w", err)
132132
}
133133

134134
endpoints := []*endpoint.Endpoint{}
@@ -144,14 +144,14 @@ func (sc *httpProxySource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint,
144144

145145
hpEndpoints, err := sc.endpointsFromHTTPProxy(hp)
146146
if err != nil {
147-
return nil, errors.Wrap(err, "failed to get endpoints from HTTPProxy")
147+
return nil, fmt.Errorf("failed to get endpoints from HTTPProxy: %w", err)
148148
}
149149

150150
// apply template if fqdn is missing on HTTPProxy
151151
if (sc.combineFQDNAnnotation || len(hpEndpoints) == 0) && sc.fqdnTemplate != nil {
152152
tmplEndpoints, err := sc.endpointsFromTemplate(hp)
153153
if err != nil {
154-
return nil, errors.Wrap(err, "failed to get endpoints from template")
154+
return nil, fmt.Errorf("failed to get endpoints from template: %w", err)
155155
}
156156

157157
if sc.combineFQDNAnnotation {

source/contour_httpproxy_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ package source
1818

1919
import (
2020
"context"
21+
"errors"
2122
"testing"
2223

2324
fakeDynamic "k8s.io/client-go/dynamic/fake"
2425

25-
"github.com/pkg/errors"
2626
projectcontour "github.com/projectcontour/contour/apis/projectcontour/v1"
2727
"github.com/stretchr/testify/assert"
2828
"github.com/stretchr/testify/require"

source/f5_transportserver.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ package source
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223
"strings"
2324

24-
"github.com/pkg/errors"
2525
log "github.com/sirupsen/logrus"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -82,7 +82,7 @@ func NewF5TransportServerSource(
8282

8383
uc, err := newTSUnstructuredConverter()
8484
if err != nil {
85-
return nil, errors.Wrapf(err, "failed to setup unstructured converter")
85+
return nil, fmt.Errorf("failed to setup unstructured converter: %w", err)
8686
}
8787

8888
return &f5TransportServerSource{
@@ -120,7 +120,7 @@ func (ts *f5TransportServerSource) Endpoints(ctx context.Context) ([]*endpoint.E
120120

121121
transportServers, err = ts.filterByAnnotations(transportServers)
122122
if err != nil {
123-
return nil, errors.Wrap(err, "failed to filter TransportServers")
123+
return nil, fmt.Errorf("failed to filter TransportServers: %w", err)
124124
}
125125

126126
endpoints, err := ts.endpointsFromTransportServers(transportServers)

source/f5_virtualserver.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ package source
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223
"sort"
2324
"strings"
2425

25-
"github.com/pkg/errors"
2626
log "github.com/sirupsen/logrus"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2828
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -83,7 +83,7 @@ func NewF5VirtualServerSource(
8383

8484
uc, err := newVSUnstructuredConverter()
8585
if err != nil {
86-
return nil, errors.Wrapf(err, "failed to setup unstructured converter")
86+
return nil, fmt.Errorf("failed to setup unstructured converter: %w", err)
8787
}
8888

8989
return &f5VirtualServerSource{
@@ -121,7 +121,7 @@ func (vs *f5VirtualServerSource) Endpoints(ctx context.Context) ([]*endpoint.End
121121

122122
virtualServers, err = vs.filterByAnnotations(virtualServers)
123123
if err != nil {
124-
return nil, errors.Wrap(err, "failed to filter VirtualServers")
124+
return nil, fmt.Errorf("failed to filter VirtualServers: %w", err)
125125
}
126126

127127
endpoints, err := vs.endpointsFromVirtualServers(virtualServers)

source/istio_gateway_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ package source
1818

1919
import (
2020
"context"
21+
"errors"
2122
"testing"
2223

23-
"github.com/pkg/errors"
2424
"github.com/stretchr/testify/assert"
2525
"github.com/stretchr/testify/require"
2626
"github.com/stretchr/testify/suite"

source/istio_virtualservice_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ package source
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223
"testing"
2324

24-
"github.com/pkg/errors"
2525
"github.com/stretchr/testify/assert"
2626
"github.com/stretchr/testify/require"
2727
"github.com/stretchr/testify/suite"

source/kong_tcpingress.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ package source
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223
"sort"
2324

24-
"github.com/pkg/errors"
2525
log "github.com/sirupsen/logrus"
2626
corev1 "k8s.io/api/core/v1"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -82,7 +82,7 @@ func NewKongTCPIngressSource(ctx context.Context, dynamicKubeClient dynamic.Inte
8282

8383
uc, err := newKongUnstructuredConverter()
8484
if err != nil {
85-
return nil, errors.Wrapf(err, "failed to setup Unstructured Converter")
85+
return nil, fmt.Errorf("failed to setup Unstructured Converter: %w", err)
8686
}
8787

8888
return &kongTCPIngressSource{
@@ -121,7 +121,7 @@ func (sc *kongTCPIngressSource) Endpoints(ctx context.Context) ([]*endpoint.Endp
121121

122122
tcpIngresses, err = sc.filterByAnnotations(tcpIngresses)
123123
if err != nil {
124-
return nil, errors.Wrap(err, "failed to filter TCPIngresses")
124+
return nil, fmt.Errorf("failed to filter TCPIngresses: %w", err)
125125
}
126126

127127
var endpoints []*endpoint.Endpoint

source/skipper_routegroup_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ package source
1818

1919
import (
2020
"context"
21+
"errors"
2122
"testing"
2223

23-
"github.com/pkg/errors"
2424
"github.com/stretchr/testify/assert"
2525
"sigs.k8s.io/external-dns/endpoint"
2626
)

source/store.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package source
1818

1919
import (
2020
"context"
21+
"errors"
22+
"fmt"
2123
"net/http"
2224
"os"
2325
"strings"
@@ -27,7 +29,6 @@ import (
2729
"github.com/cloudfoundry-community/go-cfclient"
2830
"github.com/linki/instrumented_http"
2931
openshift "github.com/openshift/client-go/route/clientset/versioned"
30-
"github.com/pkg/errors"
3132
log "github.com/sirupsen/logrus"
3233
istioclient "istio.io/client-go/pkg/clientset/versioned"
3334
"k8s.io/apimachinery/pkg/labels"
@@ -509,7 +510,7 @@ func NewIstioClient(kubeConfig string, apiServerURL string) (*istioclient.Client
509510

510511
ic, err := istioclient.NewForConfig(restCfg)
511512
if err != nil {
512-
return nil, errors.Wrap(err, "Failed to create istio client")
513+
return nil, fmt.Errorf("failed to create istio client: %w", err)
513514
}
514515

515516
return ic, nil

0 commit comments

Comments
 (0)