Fix Adding Errors from Linter.Messages to result.Errors

This also fixes <nil> beig added to result.Errors

Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
pull/6241/head
Vibhav Bobade 5 years ago
parent 9ab927f0bb
commit 68a8f36a92

@ -59,15 +59,22 @@ func (l *Lint) Run(paths []string, vals map[string]interface{}) *LintResult {
result := &LintResult{}
for _, path := range paths {
if linter, err := lintChart(path, vals, l.Namespace, l.Strict); err != nil {
linter, err := lintChart(path, vals, l.Namespace, l.Strict)
if err != nil {
if err == errLintNoChart {
result.Errors = append(result.Errors, err)
}
if linter.HighestSeverity >= lowestTolerance {
result.Errors = append(result.Errors, err)
}
} else {
result.Messages = append(result.Messages, linter.Messages...)
result.TotalChartsLinted++
if linter.HighestSeverity >= lowestTolerance {
result.Errors = append(result.Errors, err)
for _, msg := range linter.Messages {
if msg.Severity == support.ErrorSev {
result.Errors = append(result.Errors, msg.Err)
result.Messages = append(result.Messages, msg)
}
}
}
}

@ -62,8 +62,15 @@ func TestLintChart(t *testing.T) {
func TestLint_MultipleCharts(t *testing.T) {
testCharts := []string{chart2MultipleChartLint, chart1MultipleChartLint}
testLint := NewLint()
if result := testLint.Run(testCharts, values); len(result.Errors) == 0 {
if result := testLint.Run(testCharts, values); len(result.Errors) > 0 {
t.Error(result.Errors)
}
}
func TestLint_EmptyResultErrors(t *testing.T) {
testCharts := []string{chart2MultipleChartLint}
testLint := NewLint()
if result := testLint.Run(testCharts, values); len(result.Errors) > 0 {
t.Error("Expected no error, got more")
}
}

@ -61,9 +61,7 @@ func Templates(linter *support.Linter, values map[string]interface{}, namespace
}
valuesToRender, err := chartutil.ToRenderValues(chart, cvals, options, nil)
if err != nil {
// FIXME: This seems to generate a duplicate, but I can't find where the first
// error is coming from.
//linter.RunLinterRule(support.ErrorSev, err)
linter.RunLinterRule(support.ErrorSev, path, err)
return
}
var e engine.Engine

Loading…
Cancel
Save