Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove pkg/errors import in favour of stdlib errors #211

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/mittwald/go-helm-client
go 1.22.0

require (
github.com/pkg/errors v0.9.1
github.com/spf13/pflag v1.0.5
go.uber.org/mock v0.4.0
helm.sh/helm/v3 v3.15.2
Expand Down Expand Up @@ -96,6 +95,7 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc6 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
Expand Down
7 changes: 4 additions & 3 deletions spec.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package helmclient

import (
"github.com/pkg/errors"
"fmt"

"helm.sh/helm/v3/pkg/getter"
"sigs.k8s.io/yaml"

Expand All @@ -15,12 +16,12 @@ func (spec *ChartSpec) GetValuesMap(p getter.Providers) (map[string]interface{},

err := yaml.Unmarshal([]byte(spec.ValuesYaml), &valuesYaml)
if err != nil {
return nil, errors.Wrap(err, "Failed to Parse ValuesYaml")
return nil, fmt.Errorf("failed to parse ValuesYaml: %w", err)
}

valuesOptions, err := spec.ValuesOptions.MergeValues(p)
if err != nil {
return nil, errors.Wrap(err, "Failed to Parse ValuesOptions")
return nil, fmt.Errorf("failed to parse ValuesOptions: %w", err)
}

return values.MergeMaps(valuesYaml, valuesOptions), nil
Expand Down
12 changes: 6 additions & 6 deletions values/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ Changes:
package values

import (
"fmt"
"io"
"net/url"
"os"
"strings"

"github.com/pkg/errors"
"sigs.k8s.io/yaml"

"helm.sh/helm/v3/pkg/getter"
Expand Down Expand Up @@ -65,7 +65,7 @@ func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, er
}

if err := yaml.Unmarshal(bytes, &currentMap); err != nil {
return nil, errors.Wrapf(err, "failed to parse %s", filePath)
return nil, fmt.Errorf("failed to parse %s: %w", filePath, err)
}
// Merge with the previous map
base = MergeMaps(base, currentMap)
Expand All @@ -74,21 +74,21 @@ func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, er
// User specified a value via --set-json
for _, value := range opts.JSONValues {
if err := strvals.ParseJSON(value, base); err != nil {
return nil, errors.Errorf("failed parsing --set-json data %s", value)
return nil, fmt.Errorf("failed parsing --set-json data %s: %w", value, err)
}
}

// User specified a value via --set
for _, value := range opts.Values {
if err := strvals.ParseInto(value, base); err != nil {
return nil, errors.Wrap(err, "failed parsing --set data")
return nil, fmt.Errorf("failed parsing --set data: %w", err)
}
}

// User specified a value via --set-string
for _, value := range opts.StringValues {
if err := strvals.ParseIntoString(value, base); err != nil {
return nil, errors.Wrap(err, "failed parsing --set-string data")
return nil, fmt.Errorf("failed parsing --set-string data: %w", err)
}
}

Expand All @@ -102,7 +102,7 @@ func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, er
return string(bytes), err
}
if err := strvals.ParseIntoFile(value, base, reader); err != nil {
return nil, errors.Wrap(err, "failed parsing --set-file data")
return nil, fmt.Errorf("failed parsing --set-file data: %w", err)
}
}

Expand Down
Loading