forked from mittwald/go-helm-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spec.go
27 lines (21 loc) · 737 Bytes
/
spec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package helmclient
import (
"github.com/pkg/errors"
"helm.sh/helm/v3/pkg/getter"
"sigs.k8s.io/yaml"
"github.com/s4arkbyt3/go-helm-client/values"
)
// GetValuesMap returns the merged mapped out values of a chart,
// using both ValuesYaml and ValuesOptions
func (spec *ChartSpec) GetValuesMap(p getter.Providers) (map[string]interface{}, error) {
valuesYaml := map[string]interface{}{}
err := yaml.Unmarshal([]byte(spec.ValuesYaml), &valuesYaml)
if err != nil {
return nil, errors.Wrap(err, "Failed to Parse ValuesYaml")
}
valuesOptions, err := spec.ValuesOptions.MergeValues(p)
if err != nil {
return nil, errors.Wrap(err, "Failed to Parse ValuesOptions")
}
return values.MergeMaps(valuesYaml, valuesOptions), nil
}