diff --git a/pkg/chartutil/values.go b/pkg/chartutil/values.go index a2343555e..1b4ed60d0 100644 --- a/pkg/chartutil/values.go +++ b/pkg/chartutil/values.go @@ -17,6 +17,7 @@ limitations under the License. package chartutil import ( + "errors" "fmt" "io" "io/ioutil" @@ -390,7 +391,7 @@ func istable(v interface{}) bool { // PathValue takes a yaml path with . notation and returns the value if exists func (v Values) PathValue(ypath string) (interface{}, error) { if len(ypath) == 0 { - return nil, fmt.Errorf("yaml path string cannot be zero length") + return nil, errors.New("yaml path string cannot be zero length") } yps := strings.Split(ypath, ".") if len(yps) == 1 { diff --git a/pkg/chartutil/values_test.go b/pkg/chartutil/values_test.go index 7d5750bd5..79e02d014 100644 --- a/pkg/chartutil/values_test.go +++ b/pkg/chartutil/values_test.go @@ -447,10 +447,12 @@ chapter: if _, err := d.PathValue("chapter.doesntexist.one"); err == nil { t.Errorf("Non-existent key in middle of path should return error: %s\n%v", err, d) } + if _, err := d.PathValue(""); err == nil { + t.Errorf("Empty path should return error: %s\n%v", err, d) + } if v, err := d.PathValue("title"); err == nil { if v != "Moby Dick" { t.Errorf("Failed to return values for root key title") } } - }