internal: remove pkg/errors

This commit is contained in:
Jens Langhammer 2022-07-05 20:26:33 +00:00
parent 94a9667d86
commit 41eb44137e
3 changed files with 8 additions and 10 deletions

1
go.mod
View File

@ -21,7 +21,6 @@ require (
github.com/nmcclain/asn1-ber v0.0.0-20170104154839-2661553a0484 github.com/nmcclain/asn1-ber v0.0.0-20170104154839-2661553a0484
github.com/nmcclain/ldap v0.0.0-20210720162743-7f8d1e44eeba github.com/nmcclain/ldap v0.0.0-20210720162743-7f8d1e44eeba
github.com/pires/go-proxyproto v0.6.2 github.com/pires/go-proxyproto v0.6.2
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.12.2 github.com/prometheus/client_golang v1.12.2
github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b
github.com/sirupsen/logrus v1.8.1 github.com/sirupsen/logrus v1.8.1

View File

@ -1,12 +1,12 @@
package config package config
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"strings" "strings"
env "github.com/Netflix/go-env" env "github.com/Netflix/go-env"
"github.com/imdario/mergo" "github.com/imdario/mergo"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
) )
@ -35,15 +35,15 @@ func DefaultConfig() {
func LoadConfig(path string) error { func LoadConfig(path string) error {
raw, err := ioutil.ReadFile(path) raw, err := ioutil.ReadFile(path)
if err != nil { if err != nil {
return errors.Wrap(err, "Failed to load config file") return fmt.Errorf("Failed to load config file: %w", err)
} }
nc := Config{} nc := Config{}
err = yaml.Unmarshal(raw, &nc) err = yaml.Unmarshal(raw, &nc)
if err != nil { if err != nil {
return errors.Wrap(err, "Failed to parse YAML") return fmt.Errorf("Failed to parse YAML: %w", err)
} }
if err := mergo.Merge(&G, nc, mergo.WithOverride); err != nil { if err := mergo.Merge(&G, nc, mergo.WithOverride); err != nil {
return errors.Wrap(err, "failed to overlay config") return fmt.Errorf("failed to overlay config: %w", err)
} }
log.WithField("path", path).Debug("Loaded config") log.WithField("path", path).Debug("Loaded config")
return nil return nil
@ -53,10 +53,10 @@ func FromEnv() error {
nc := Config{} nc := Config{}
_, err := env.UnmarshalFromEnviron(&nc) _, err := env.UnmarshalFromEnviron(&nc)
if err != nil { if err != nil {
return errors.Wrap(err, "failed to load environment variables") return fmt.Errorf("failed to load environment variables: %w", err)
} }
if err := mergo.Merge(&G, nc, mergo.WithOverride); err != nil { if err := mergo.Merge(&G, nc, mergo.WithOverride); err != nil {
return errors.Wrap(err, "failed to overlay config") return fmt.Errorf("failed to overlay config: %w", err)
} }
log.Debug("Loaded config from environment") log.Debug("Loaded config from environment")
return nil return nil

View File

@ -17,7 +17,6 @@ import (
sentryhttp "github.com/getsentry/sentry-go/http" sentryhttp "github.com/getsentry/sentry-go/http"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/gorilla/sessions" "github.com/gorilla/sessions"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"goauthentik.io/api/v3" "goauthentik.io/api/v3"
@ -155,13 +154,13 @@ func NewApplication(p api.ProxyOutpostConfig, c *http.Client, cs *ak.CryptoStore
err = a.configureForward() err = a.configureForward()
} }
if err != nil { if err != nil {
return nil, errors.Wrap(err, "failed to configure application mode") return nil, fmt.Errorf("failed to configure application mode: %w", err)
} }
if kp := p.Certificate.Get(); kp != nil { if kp := p.Certificate.Get(); kp != nil {
err := cs.AddKeypair(*kp) err := cs.AddKeypair(*kp)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "failed to initially fetch certificate") return nil, fmt.Errorf("failed to initially fetch certificate: %w", err)
} }
a.Cert = cs.Get(*kp) a.Cert = cs.Get(*kp)
} }