Fail linting when `required` function fails.

This is a revert of the original change that was made as a result of: https://github.com/helm/helm/issues/2347
And was made in: https://github.com/helm/helm/pull/4221

I believe this original change to be incorrect, hence the revert.

Signed-off-by: Michael McCord <michael.mccord@mdbuyline.com>
pull/5259/head
Michael McCord 7 years ago
parent 1984f436af
commit f68f2dff84

@ -19,7 +19,6 @@ package engine
import (
"bytes"
"fmt"
"log"
"path"
"sort"
"strings"
@ -156,20 +155,10 @@ func (e *Engine) alterFuncMap(t *template.Template, referenceTpls map[string]ren
// Add the 'required' function here
funcMap["required"] = func(warn string, val interface{}) (interface{}, error) {
if val == nil {
if e.LintMode {
// Don't fail on missing required values when linting
log.Printf("[INFO] Missing required value: %s", warn)
return "", nil
}
// Convert nil to "" in case required is piped into other functions
return "", fmt.Errorf(warn)
} else if _, ok := val.(string); ok {
if val == "" {
if e.LintMode {
// Don't fail on missing required values when linting
log.Printf("[INFO] Missing required value: %s", warn)
return val, nil
}
return val, fmt.Errorf(warn)
}
}

Loading…
Cancel
Save