|
|
@ -29,8 +29,6 @@ import (
|
|
|
|
"helm.sh/helm/v3/pkg/lint/support"
|
|
|
|
"helm.sh/helm/v3/pkg/lint/support"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var errLintNoChart = errors.New("no chart found for linting (missing Chart.yaml)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Lint is the action for checking that the semantics of a chart are well-formed.
|
|
|
|
// Lint is the action for checking that the semantics of a chart are well-formed.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// It provides the implementation of 'helm lint'.
|
|
|
|
// It provides the implementation of 'helm lint'.
|
|
|
@ -56,27 +54,22 @@ func (l *Lint) Run(paths []string, vals map[string]interface{}) *LintResult {
|
|
|
|
if l.Strict {
|
|
|
|
if l.Strict {
|
|
|
|
lowestTolerance = support.WarningSev
|
|
|
|
lowestTolerance = support.WarningSev
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result := &LintResult{}
|
|
|
|
result := &LintResult{}
|
|
|
|
for _, path := range paths {
|
|
|
|
for _, path := range paths {
|
|
|
|
linter, err := lintChart(path, vals, l.Namespace, l.Strict)
|
|
|
|
linter, err := lintChart(path, vals, l.Namespace, l.Strict)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
if err == errLintNoChart {
|
|
|
|
|
|
|
|
result.Errors = append(result.Errors, err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if linter.HighestSeverity >= lowestTolerance {
|
|
|
|
|
|
|
|
result.Errors = append(result.Errors, err)
|
|
|
|
result.Errors = append(result.Errors, err)
|
|
|
|
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
result.Messages = append(result.Messages, linter.Messages...)
|
|
|
|
result.Messages = append(result.Messages, linter.Messages...)
|
|
|
|
result.TotalChartsLinted++
|
|
|
|
result.TotalChartsLinted++
|
|
|
|
for _, msg := range linter.Messages {
|
|
|
|
for _, msg := range linter.Messages {
|
|
|
|
if msg.Severity == support.ErrorSev {
|
|
|
|
if msg.Severity >= lowestTolerance {
|
|
|
|
result.Errors = append(result.Errors, msg.Err)
|
|
|
|
result.Errors = append(result.Errors, msg.Err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -87,18 +80,18 @@ func lintChart(path string, vals map[string]interface{}, namespace string, stric
|
|
|
|
if strings.HasSuffix(path, ".tgz") {
|
|
|
|
if strings.HasSuffix(path, ".tgz") {
|
|
|
|
tempDir, err := ioutil.TempDir("", "helm-lint")
|
|
|
|
tempDir, err := ioutil.TempDir("", "helm-lint")
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return linter, err
|
|
|
|
return linter, errors.Wrap(err, "unable to create temp dir to extract tarball")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer os.RemoveAll(tempDir)
|
|
|
|
defer os.RemoveAll(tempDir)
|
|
|
|
|
|
|
|
|
|
|
|
file, err := os.Open(path)
|
|
|
|
file, err := os.Open(path)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return linter, err
|
|
|
|
return linter, errors.Wrap(err, "unable to open tarball")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer file.Close()
|
|
|
|
defer file.Close()
|
|
|
|
|
|
|
|
|
|
|
|
if err = chartutil.Expand(tempDir, file); err != nil {
|
|
|
|
if err = chartutil.Expand(tempDir, file); err != nil {
|
|
|
|
return linter, err
|
|
|
|
return linter, errors.Wrap(err, "unable to extract tarball")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lastHyphenIndex := strings.LastIndex(filepath.Base(path), "-")
|
|
|
|
lastHyphenIndex := strings.LastIndex(filepath.Base(path), "-")
|
|
|
@ -113,7 +106,7 @@ func lintChart(path string, vals map[string]interface{}, namespace string, stric
|
|
|
|
|
|
|
|
|
|
|
|
// Guard: Error out if this is not a chart.
|
|
|
|
// Guard: Error out if this is not a chart.
|
|
|
|
if _, err := os.Stat(filepath.Join(chartPath, "Chart.yaml")); err != nil {
|
|
|
|
if _, err := os.Stat(filepath.Join(chartPath, "Chart.yaml")); err != nil {
|
|
|
|
return linter, errLintNoChart
|
|
|
|
return linter, errors.Wrap(err, "unable to check Chart.yaml file in chart")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return lint.All(chartPath, vals, namespace, strict), nil
|
|
|
|
return lint.All(chartPath, vals, namespace, strict), nil
|
|
|
|