|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|
|
|
|
package values
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"bytes"
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"io"
|
|
|
|
|
"net/url"
|
|
|
|
@ -24,7 +25,7 @@ import (
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
|
"sigs.k8s.io/yaml"
|
|
|
|
|
utilyaml "k8s.io/apimachinery/pkg/util/yaml"
|
|
|
|
|
|
|
|
|
|
"helm.sh/helm/v4/pkg/getter"
|
|
|
|
|
"helm.sh/helm/v4/pkg/strvals"
|
|
|
|
@ -47,18 +48,23 @@ func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, er
|
|
|
|
|
|
|
|
|
|
// User specified a values files via -f/--values
|
|
|
|
|
for _, filePath := range opts.ValueFiles {
|
|
|
|
|
currentMap := map[string]interface{}{}
|
|
|
|
|
|
|
|
|
|
bytes, err := readFile(filePath, p)
|
|
|
|
|
raw, err := readFile(filePath, p)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := yaml.Unmarshal(bytes, ¤tMap); err != nil {
|
|
|
|
|
return nil, errors.Wrapf(err, "failed to parse %s", filePath)
|
|
|
|
|
decoder := utilyaml.NewYAMLOrJSONDecoder(bytes.NewReader(raw), 4096)
|
|
|
|
|
for {
|
|
|
|
|
currentMap := map[string]interface{}{}
|
|
|
|
|
if err := decoder.Decode(¤tMap); err != nil {
|
|
|
|
|
if err == io.EOF {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
return nil, errors.Wrapf(err, "failed to parse %s", filePath)
|
|
|
|
|
}
|
|
|
|
|
// Merge with the previous map
|
|
|
|
|
base = mergeMaps(base, currentMap)
|
|
|
|
|
}
|
|
|
|
|
// Merge with the previous map
|
|
|
|
|
base = mergeMaps(base, currentMap)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// User specified a value via --set-json
|
|
|
|
|