From 88622a20dac981de4d2d5eba0420004cad3d272e Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Mon, 13 Jun 2016 16:20:54 -0600 Subject: [PATCH] fix(helm): read values.yaml instead of values.toml Closes #822 --- pkg/chart/chart.go | 16 +++++++++++----- pkg/chartutil/values.go | 10 ++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index 19e76dfbf..f4a2782e5 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -27,6 +27,8 @@ import ( "os" "path/filepath" "strings" + + "k8s.io/helm/pkg/chartutil" ) // ChartfileName is the default Chart file name. @@ -34,14 +36,14 @@ const ChartfileName string = "Chart.yaml" const ( preTemplates string = "templates/" - preValues string = "values.toml" + preValues string = "values.yaml" preCharts string = "charts/" ) const defaultValues = `# Default values for %s. -# This is a TOML-formatted file. https://github.com/toml-lang/toml +# This is a YAML-formatted file. # Declare name/value pairs to be passed into your templates. -# name = "value" +# name: value ` var headerBytes = []byte("+aHR0cHM6Ly95b3V0dS5iZS96OVV6MWljandyTQo=") @@ -93,9 +95,13 @@ func (c *Chart) ChartsDir() string { return filepath.Join(c.loader.dir(), preCharts) } -// LoadValues loads the contents of values.toml into a map +// LoadValues loads the contents of values.yaml into a map func (c *Chart) LoadValues() (Values, error) { - return ReadValuesFile(filepath.Join(c.loader.dir(), preValues)) + m, err := chartutil.ReadValuesFile(filepath.Join(c.loader.dir(), preValues)) + if err != nil { + return map[string]interface{}{}, err + } + return m.AsMap(), nil } // ChartDepNames returns the list of chart names found in ChartsDir. diff --git a/pkg/chartutil/values.go b/pkg/chartutil/values.go index 2e6a90043..7319d37f7 100644 --- a/pkg/chartutil/values.go +++ b/pkg/chartutil/values.go @@ -43,6 +43,16 @@ func (v Values) Table(name string) (Values, error) { return table, err } +// AsMap is a utility function for converting Values to a map[string]interface{}. +// +// It protects against nil map panics. +func (v Values) AsMap() map[string]interface{} { + if v == nil || len(v) == 0 { + return map[string]interface{}{} + } + return v +} + // Encode writes serialized Values information to the given io.Writer. func (v Values) Encode(w io.Writer) error { //return yaml.NewEncoder(w).Encode(v)