diff --git a/pkg/action/lint.go b/pkg/action/lint.go index a86dd796a..f7fe905fd 100644 --- a/pkg/action/lint.go +++ b/pkg/action/lint.go @@ -54,7 +54,7 @@ func NewLint() *Lint { // Run executes 'helm Lint' against the given chart. func (l *Lint) Run(paths []string, vals map[string]interface{}) *LintResult { lowestTolerance := support.ErrorSev - if l.Strict || l.Quiet { + if l.Strict { lowestTolerance = support.WarningSev } result := &LintResult{} @@ -65,12 +65,16 @@ func (l *Lint) Run(paths []string, vals map[string]interface{}) *LintResult { continue } + result.Messages = append(result.Messages, linter.Messages...) result.TotalChartsLinted++ - for _, msg := range linter.Messages { + for i, msg := range linter.Messages { // Unknown(0), Info(1), Warning(2), Error(3) if msg.Severity >= lowestTolerance { result.Errors = append(result.Errors, msg.Err) - result.Messages = append(result.Messages, msg) + } + // Remove INFO or UNKNOWN messages if --quiet flag is set, keeping the order of the messages + if l.Quiet && (msg.Severity <= support.InfoSev) { + result.Messages = append(result.Messages[:i], result.Messages[i+1:]...) } } } diff --git a/pkg/action/lint_test.go b/pkg/action/lint_test.go index 5e626a2a2..0942ced2c 100644 --- a/pkg/action/lint_test.go +++ b/pkg/action/lint_test.go @@ -172,4 +172,12 @@ func TestLint_ChartWithInfo(t *testing.T) { } } }) + + t.Run("should pass with INFO messages without quiet", func(t *testing.T) { + testCharts := []string{chart1MultipleChartLint} + testLint := NewLint() + if result := testLint.Run(testCharts, values); len(result.Errors) != 0 { + t.Error("expected no errors, but got", len(result.Errors)) + } + }) }