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 <tibrahim@nvidia.com>
  • Loading branch information
tariq1890 committed Jun 26, 2024
1 parent e7c4238 commit 7e5a011
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
4 changes: 1 addition & 3 deletions 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 @@ -40,7 +39,6 @@ require (
github.com/docker/docker-credential-helpers v0.8.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.1 // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
Expand Down Expand Up @@ -93,12 +91,12 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
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 7e5a011

Please sign in to comment.