Skip to content

Commit

Permalink
Use go standard errors instead of multierror (envoyproxy#2464)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
  • Loading branch information
mmorel-35 authored Jan 22, 2024
1 parent 0ac8c64 commit d0c12eb
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 149 deletions.
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ require (
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
github.com/telepresenceio/watchable v0.0.0-20220726211108-9bb86f92afa7
github.com/tetratelabs/multierror v1.1.1
github.com/tsaarni/certyaml v0.9.2
go.opentelemetry.io/otel v1.22.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.45.0
Expand Down Expand Up @@ -77,7 +76,6 @@ require (
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
Expand Down Expand Up @@ -465,8 +463,6 @@ github.com/telepresenceio/telepresence/rpc/v2 v2.6.8 h1:q5V85LBT9bA/c4YPa/kMvJGy
github.com/telepresenceio/telepresence/rpc/v2 v2.6.8/go.mod h1:VlgfRoXaW6Tl8IZbHmMWhITne8HY09/wOFtABHGj3ic=
github.com/telepresenceio/watchable v0.0.0-20220726211108-9bb86f92afa7 h1:GMw3nEaOVyi+tNiGko5kAeRtoiEIpXNHmISyZ7fpw14=
github.com/telepresenceio/watchable v0.0.0-20220726211108-9bb86f92afa7/go.mod h1:ihJ97e2gsd8GuzFF/I3B1qcik3XZLpXjumQifXi8Slg=
github.com/tetratelabs/multierror v1.1.1 h1:84JfJvfmnYC5y4877Ag3c4PkCUmQwq6sGI6iRfBATKI=
github.com/tetratelabs/multierror v1.1.1/go.mod h1:hAyQ/XifPOPdb0x3GsowbjsjCPgT9Fsxjety9TxmuGY=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/egctl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ package egctl
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"sync"

adminv3 "github.com/envoyproxy/go-control-plane/envoy/admin/v3"
"github.com/tetratelabs/multierror"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/reflect/protoreflect"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -81,20 +81,20 @@ func retrieveConfigDump(args []string, includeEds bool, configType envoyConfigTy
go func() {
fw, err := portForwarder(cli, pod)
if err != nil {
errs = multierror.Append(errs, err)
errs = errors.Join(errs, err)
return
}

if err := fw.Start(); err != nil {
errs = multierror.Append(errs, err)
errs = errors.Join(errs, err)
return
}
defer fw.Stop()
defer wg.Done()

configDump, err := extractConfigDump(fw, includeEds, configType)
if err != nil {
errs = multierror.Append(errs, err)
errs = errors.Join(errs, err)
return
}

Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/egctl/envoy_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ package egctl

import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"sync"

"github.com/spf13/cobra"
"github.com/tetratelabs/multierror"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/yaml"

Expand Down Expand Up @@ -74,7 +74,7 @@ func newEnvoyStatsCmd() *cobra.Command {
go func(pod types.NamespacedName) {
stats[pod.Namespace+"/"+pod.Name], err = setupEnvoyServerStatsConfig(kubeClient, pod.Name, pod.Namespace, outputFormat)
if err != nil {
errs = multierror.Append(errs, err)
errs = errors.Join(errs, err)
}
wg.Done()
}(pod)
Expand All @@ -87,7 +87,7 @@ func newEnvoyStatsCmd() *cobra.Command {
go func(pod types.NamespacedName) {
stats[pod.Namespace+"/"+pod.Name], err = setupEnvoyClusterStatsConfig(kubeClient, pod.Name, pod.Namespace, outputFormat)
if err != nil {
errs = multierror.Append(errs, err)
errs = errors.Join(errs, err)
}
wg.Done()
}(pod)
Expand Down
11 changes: 5 additions & 6 deletions internal/gatewayapi/securitypolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package gatewayapi

import (
"encoding/json"
"errors"
"fmt"
"net/http"
"net/netip"
Expand All @@ -22,8 +23,6 @@ import (
gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gwv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/tetratelabs/multierror"

egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
"github.com/envoyproxy/gateway/internal/ir"
"github.com/envoyproxy/gateway/internal/status"
Expand Down Expand Up @@ -283,13 +282,13 @@ func (t *Translator) translateSecurityPolicyForRoute(

if policy.Spec.OIDC != nil {
if oidc, err = t.buildOIDC(policy, resources); err != nil {
errs = multierror.Append(errs, err)
errs = errors.Join(errs, err)
}
}

if policy.Spec.BasicAuth != nil {
if basicAuth, err = t.buildBasicAuth(policy, resources); err != nil {
errs = multierror.Append(errs, err)
errs = errors.Join(errs, err)
}
}

Expand Down Expand Up @@ -337,13 +336,13 @@ func (t *Translator) translateSecurityPolicyForGateway(

if policy.Spec.OIDC != nil {
if oidc, err = t.buildOIDC(policy, resources); err != nil {
errs = multierror.Append(errs, err)
errs = errors.Join(errs, err)
}
}

if policy.Spec.BasicAuth != nil {
if basicAuth, err = t.buildBasicAuth(policy, resources); err != nil {
errs = multierror.Append(errs, err)
errs = errors.Join(errs, err)
}
}

Expand Down
Loading

0 comments on commit d0c12eb

Please sign in to comment.