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