From 6af93cd2bd89d38ade8d9384fe3798aed1a38a65 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sat, 4 Feb 2023 20:48:57 -0500 Subject: Remove uses of pkg/errors Signed-off-by: Dave Henderson --- data/datasource.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'data/datasource.go') diff --git a/data/datasource.go b/data/datasource.go index 6e8117d9..93dc51b9 100644 --- a/data/datasource.go +++ b/data/datasource.go @@ -12,8 +12,6 @@ import ( "github.com/spf13/afero" - "github.com/pkg/errors" - "github.com/hairyhenderson/gomplate/v3/internal/config" "github.com/hairyhenderson/gomplate/v3/libkv" "github.com/hairyhenderson/gomplate/v3/vault" @@ -70,7 +68,7 @@ func (d *Data) lookupReader(scheme string) (func(context.Context, *Source, ...st } r, ok := d.sourceReaders[scheme] if !ok { - return nil, errors.Errorf("scheme %s not registered", scheme) + return nil, fmt.Errorf("scheme %s not registered", scheme) } return r, nil } @@ -219,7 +217,7 @@ func (s *Source) mimeType(arg string) (mimeType string, err error) { if mediatype != "" { t, _, err := mime.ParseMediaType(mediatype) if err != nil { - return "", errors.Wrapf(err, "MIME type was %q", mediatype) + return "", fmt.Errorf("MIME type was %q: %w", mediatype, err) } mediatype = t return mediatype, nil @@ -237,7 +235,7 @@ func (s *Source) String() string { // DefineDatasource - func (d *Data) DefineDatasource(alias, value string) (string, error) { if alias == "" { - return "", errors.New("datasource alias must be provided") + return "", fmt.Errorf("datasource alias must be provided") } if d.DatasourceExists(alias) { return "", nil @@ -269,7 +267,7 @@ func (d *Data) lookupSource(alias string) (*Source, error) { if !ok { srcURL, err := url.Parse(alias) if err != nil || !srcURL.IsAbs() { - return nil, errors.Errorf("Undefined datasource '%s'", alias) + return nil, fmt.Errorf("undefined datasource '%s': %w", alias, err) } source = &Source{ Alias: alias, @@ -291,7 +289,7 @@ func (d *Data) readDataSource(ctx context.Context, alias string, args ...string) } b, err := d.readSource(ctx, source, args...) if err != nil { - return "", "", errors.Wrapf(err, "Couldn't read datasource '%s'", alias) + return "", "", fmt.Errorf("couldn't read datasource '%s': %w", alias, err) } subpath := "" @@ -346,7 +344,7 @@ func parseData(mimeType, s string) (out interface{}, err error) { case textMimetype: out = s default: - return nil, errors.Errorf("Datasources of type %s not yet supported", mimeType) + return nil, fmt.Errorf("datasources of type %s not yet supported", mimeType) } return out, err } @@ -378,7 +376,7 @@ func (d *Data) readSource(ctx context.Context, source *Source, args ...string) ( } r, err := d.lookupReader(source.URL.Scheme) if err != nil { - return nil, errors.Wrap(err, "Datasource not yet supported") + return nil, fmt.Errorf("Datasource not yet supported") } data, err := r(ctx, source, args...) if err != nil { -- cgit v1.2.3