From 75835c5fa4a5a3d849d7a5b4e1a88f9cda527456 Mon Sep 17 00:00:00 2001 From: Ryan Hartje Date: Wed, 28 Mar 2018 18:51:26 -0400 Subject: [PATCH 1/2] return a non 0 exit code when lint fails due to missing Chart.yaml --- cmd/helm/lint.go | 8 ++++++++ cmd/helm/lint_test.go | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go index 6e08f2747..e83026117 100644 --- a/cmd/helm/lint.go +++ b/cmd/helm/lint.go @@ -97,10 +97,14 @@ func (l *lintCmd) run() error { var total int var failures int + rc := 0 for _, path := range l.paths { if linter, err := lintChart(path, rvals, l.namespace, l.strict); err != nil { fmt.Println("==> Skipping", path) fmt.Println(err) + if err == errLintNoChart { + rc = 1 + } } else { fmt.Println("==> Linting", path) @@ -127,6 +131,10 @@ func (l *lintCmd) run() error { fmt.Fprintf(l.out, "%s, no failures\n", msg) + if rc != 0 { + os.Exit(rc) + } + return nil } diff --git a/cmd/helm/lint_test.go b/cmd/helm/lint_test.go index 7f045153c..973af9b63 100644 --- a/cmd/helm/lint_test.go +++ b/cmd/helm/lint_test.go @@ -28,6 +28,7 @@ var ( archivedChartPathWithHyphens = "testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz" invalidArchivedChartPath = "testdata/testcharts/invalidcompressedchart0.1.0.tgz" chartDirPath = "testdata/testcharts/decompressedchart/" + chartMissingManifest = "testdata/testcharts/chart-missing-manifest" ) func TestLintChart(t *testing.T) { @@ -46,4 +47,8 @@ func TestLintChart(t *testing.T) { if _, err := lintChart(invalidArchivedChartPath, values, namespace, strict); err == nil { t.Errorf("Expected a chart parsing error") } + + if _, err := lintChart(chartMissingManifest, values, namespace, strict); err == nil { + t.Errorf("Expected a chart parsing error") + } } From 33f3238cd89ad5e95d813ed0da2b53b813354a0d Mon Sep 17 00:00:00 2001 From: Ryan Hartje Date: Tue, 3 Apr 2018 20:17:54 -0400 Subject: [PATCH 2/2] using existing mechanism to flag for failures --- cmd/helm/lint.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go index e83026117..63f11c062 100644 --- a/cmd/helm/lint.go +++ b/cmd/helm/lint.go @@ -97,13 +97,12 @@ func (l *lintCmd) run() error { var total int var failures int - rc := 0 for _, path := range l.paths { if linter, err := lintChart(path, rvals, l.namespace, l.strict); err != nil { fmt.Println("==> Skipping", path) fmt.Println(err) if err == errLintNoChart { - rc = 1 + failures = failures + 1 } } else { fmt.Println("==> Linting", path) @@ -131,10 +130,6 @@ func (l *lintCmd) run() error { fmt.Fprintf(l.out, "%s, no failures\n", msg) - if rc != 0 { - os.Exit(rc) - } - return nil }