Skip to content

Commit

Permalink
remove pkg/errors import in favour of stdlib errors
Browse files Browse the repository at this point in the history
Signed-off-by: Tariq Ibrahim <[email protected]>
  • Loading branch information
tariq1890 committed Aug 8, 2024
1 parent 056c02c commit b4ba8cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
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
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc
Expand Down Expand Up @@ -97,6 +96,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

0 comments on commit b4ba8cd

Please sign in to comment.