mirror of
https://github.com/traefik/traefik.git
synced 2026-06-17 19:09:29 +03:00
Replace uses of hashicorp/go-multierror with stdlib errors.Join
This commit is contained in:
committed by
GitHub
parent
734cc21fb4
commit
c605e5e139
@@ -32,7 +32,6 @@ require (
|
||||
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674
|
||||
github.com/hashicorp/consul/api v1.26.1
|
||||
github.com/hashicorp/go-hclog v1.6.3
|
||||
github.com/hashicorp/go-multierror v1.1.1
|
||||
github.com/hashicorp/go-retryablehttp v0.7.8
|
||||
github.com/hashicorp/go-version v1.8.0
|
||||
github.com/hashicorp/nomad/api v0.0.0-20231213195942-64e3dca9274b // No tag on the repo.
|
||||
@@ -248,6 +247,7 @@ require (
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
|
||||
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
||||
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
||||
|
||||
+18
-18
@@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/rs/zerolog/log"
|
||||
"golang.org/x/mod/module"
|
||||
)
|
||||
@@ -84,29 +83,30 @@ func SetupLocalPlugins(plugins map[string]LocalDescriptor) error {
|
||||
|
||||
uniq := make(map[string]struct{})
|
||||
|
||||
var errs *multierror.Error
|
||||
var errs []error
|
||||
for pAlias, descriptor := range plugins {
|
||||
if descriptor.ModuleName == "" {
|
||||
errs = multierror.Append(errs, fmt.Errorf("%s: plugin name is missing", pAlias))
|
||||
errs = append(errs, fmt.Errorf("%s: plugin name is missing", pAlias))
|
||||
}
|
||||
|
||||
if strings.HasPrefix(descriptor.ModuleName, "/") || strings.HasSuffix(descriptor.ModuleName, "/") {
|
||||
errs = multierror.Append(errs, fmt.Errorf("%s: plugin name should not start or end with a /", pAlias))
|
||||
errs = append(errs, fmt.Errorf("%s: plugin name should not start or end with a /", pAlias))
|
||||
continue
|
||||
}
|
||||
|
||||
if _, ok := uniq[descriptor.ModuleName]; ok {
|
||||
errs = multierror.Append(errs, fmt.Errorf("only one version of a plugin is allowed, there is a duplicate of %s", descriptor.ModuleName))
|
||||
errs = append(errs, fmt.Errorf("only one version of a plugin is allowed, there is a duplicate of %s", descriptor.ModuleName))
|
||||
continue
|
||||
}
|
||||
|
||||
uniq[descriptor.ModuleName] = struct{}{}
|
||||
|
||||
err := checkLocalPluginManifest(descriptor)
|
||||
errs = multierror.Append(errs, err)
|
||||
if err := checkLocalPluginManifest(descriptor); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
||||
return errs.ErrorOrNil()
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
||||
func checkLocalPluginManifest(descriptor LocalDescriptor) error {
|
||||
@@ -115,44 +115,44 @@ func checkLocalPluginManifest(descriptor LocalDescriptor) error {
|
||||
return err
|
||||
}
|
||||
|
||||
var errs *multierror.Error
|
||||
var errs []error
|
||||
|
||||
switch m.Type {
|
||||
case typeMiddleware:
|
||||
if m.Runtime != runtimeYaegi && m.Runtime != runtimeWasm && m.Runtime != "" {
|
||||
errs = multierror.Append(errs, fmt.Errorf("%s: unsupported runtime '%q'", descriptor.ModuleName, m.Runtime))
|
||||
errs = append(errs, fmt.Errorf("%s: unsupported runtime '%q'", descriptor.ModuleName, m.Runtime))
|
||||
}
|
||||
|
||||
case typeProvider:
|
||||
if m.Runtime != runtimeYaegi && m.Runtime != "" {
|
||||
errs = multierror.Append(errs, fmt.Errorf("%s: unsupported runtime '%q'", descriptor.ModuleName, m.Runtime))
|
||||
errs = append(errs, fmt.Errorf("%s: unsupported runtime '%q'", descriptor.ModuleName, m.Runtime))
|
||||
}
|
||||
|
||||
default:
|
||||
errs = multierror.Append(errs, fmt.Errorf("%s: unsupported type %q", descriptor.ModuleName, m.Type))
|
||||
errs = append(errs, fmt.Errorf("%s: unsupported type %q", descriptor.ModuleName, m.Type))
|
||||
}
|
||||
|
||||
if m.IsYaegiPlugin() {
|
||||
if m.Import == "" {
|
||||
errs = multierror.Append(errs, fmt.Errorf("%s: missing import", descriptor.ModuleName))
|
||||
errs = append(errs, fmt.Errorf("%s: missing import", descriptor.ModuleName))
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(m.Import, descriptor.ModuleName) {
|
||||
errs = multierror.Append(errs, fmt.Errorf("the import %q must be related to the module name %q", m.Import, descriptor.ModuleName))
|
||||
errs = append(errs, fmt.Errorf("the import %q must be related to the module name %q", m.Import, descriptor.ModuleName))
|
||||
}
|
||||
}
|
||||
|
||||
if m.DisplayName == "" {
|
||||
errs = multierror.Append(errs, fmt.Errorf("%s: missing DisplayName", descriptor.ModuleName))
|
||||
errs = append(errs, fmt.Errorf("%s: missing DisplayName", descriptor.ModuleName))
|
||||
}
|
||||
|
||||
if m.Summary == "" {
|
||||
errs = multierror.Append(errs, fmt.Errorf("%s: missing Summary", descriptor.ModuleName))
|
||||
errs = append(errs, fmt.Errorf("%s: missing Summary", descriptor.ModuleName))
|
||||
}
|
||||
|
||||
if m.TestData == nil {
|
||||
errs = multierror.Append(errs, fmt.Errorf("%s: missing TestData", descriptor.ModuleName))
|
||||
errs = append(errs, fmt.Errorf("%s: missing TestData", descriptor.ModuleName))
|
||||
}
|
||||
|
||||
return errs.ErrorOrNil()
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/cenkalti/backoff/v4"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/mitchellh/hashstructure"
|
||||
"github.com/rs/zerolog/log"
|
||||
ptypes "github.com/traefik/paerser/types"
|
||||
@@ -409,7 +408,7 @@ func (p *Provider) loadConfigurationFromGateways(ctx context.Context) *dynamic.C
|
||||
}
|
||||
var conditionsErr error
|
||||
for message := range messages {
|
||||
conditionsErr = multierror.Append(conditionsErr, errors.New(message))
|
||||
conditionsErr = errors.Join(conditionsErr, errors.New(message))
|
||||
}
|
||||
logger.Error().
|
||||
Err(conditionsErr).
|
||||
|
||||
Reference in New Issue
Block a user