diff --git a/cmd/helm/install.go b/cmd/helm/install.go index e2f1ada66..4a66765a8 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -32,6 +32,8 @@ import ( "github.com/ghodss/yaml" "github.com/spf13/cobra" + api_yaml "k8s.io/apimachinery/pkg/util/yaml" + "k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/downloader" "k8s.io/helm/pkg/getter" @@ -330,19 +332,20 @@ func vals(valueFiles valueFiles, values []string) ([]byte, error) { for _, filePath := range valueFiles { currentMap := map[string]interface{}{} - var bytes []byte + var readBytes []byte var err error if strings.TrimSpace(filePath) == "-" { - bytes, err = ioutil.ReadAll(os.Stdin) + readBytes, err = ioutil.ReadAll(os.Stdin) } else { - bytes, err = readFile(filePath) + readBytes, err = readFile(filePath) } if err != nil { return []byte{}, err } - if err := yaml.Unmarshal(bytes, ¤tMap); err != nil { + d := api_yaml.NewYAMLOrJSONDecoder(bytes.NewReader(readBytes), 4096) + if err := d.Decode(¤tMap); err != nil { return []byte{}, fmt.Errorf("failed to parse %s: %s", filePath, err) } // Merge with the previous map diff --git a/cmd/helm/template_test.go b/cmd/helm/template_test.go index 06c7edf9a..b825aca41 100644 --- a/cmd/helm/template_test.go +++ b/cmd/helm/template_test.go @@ -97,6 +97,13 @@ func TestTemplateCmd(t *testing.T) { expectKey: "subchart1/templates/service.yaml", expectValue: "name: apache", }, + { + name: "check_values_files_json", + desc: "verify --values files values exist", + args: []string{chartPath, "--values", chartPath + "/charts/subchartA/values.json"}, + expectKey: "subchart1/templates/service.yaml", + expectValue: "name: apache", + }, { name: "check_name_template", desc: "verify --name-template result exists", diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartA/values.json b/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartA/values.json new file mode 100644 index 000000000..9a5dc0243 --- /dev/null +++ b/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartA/values.json @@ -0,0 +1,17 @@ +{ + "service": { + "name": "apache", + "type": "ClusterIP", + "externalPort": 80, + "internalPort": 80 + }, + "SCAdata": { + "SCAbool": false, + "SCAfloat": 3.1, + "SCAint": 55, + "SCAstring": "jabba", + "SCAnested1": { + "SCAnested2": true + } + } +} \ No newline at end of file