mirror of
https://github.com/helm/helm.git
synced 2026-08-04 15:10:47 +00:00
Merge pull request #3519 from liamawhite/master
Fix linting bug with charts containing more than one hyphen
This commit is contained in:
@@ -149,7 +149,11 @@ func lintChart(path string, vals []byte, namespace string, strict bool) (support
|
||||
return linter, err
|
||||
}
|
||||
|
||||
base := strings.Split(filepath.Base(path), "-")[0]
|
||||
lastHyphenIndex := strings.LastIndex(filepath.Base(path), "-")
|
||||
if lastHyphenIndex <= 0 {
|
||||
return linter, fmt.Errorf("unable to parse chart archive %q, missing '-'", filepath.Base(path))
|
||||
}
|
||||
base := filepath.Base(path)[:lastHyphenIndex]
|
||||
chartPath = filepath.Join(tempDir, base)
|
||||
} else {
|
||||
chartPath = path
|
||||
|
||||
@@ -21,11 +21,13 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
values = []byte{}
|
||||
namespace = "testNamespace"
|
||||
strict = false
|
||||
archivedChartPath = "testdata/testcharts/compressedchart-0.1.0.tgz"
|
||||
chartDirPath = "testdata/testcharts/decompressedchart/"
|
||||
values = []byte{}
|
||||
namespace = "testNamespace"
|
||||
strict = false
|
||||
archivedChartPath = "testdata/testcharts/compressedchart-0.1.0.tgz"
|
||||
archivedChartPathWithHyphens = "testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz"
|
||||
invalidArchivedChartPath = "testdata/testcharts/invalidcompressedchart0.1.0.tgz"
|
||||
chartDirPath = "testdata/testcharts/decompressedchart/"
|
||||
)
|
||||
|
||||
func TestLintChart(t *testing.T) {
|
||||
@@ -37,4 +39,11 @@ func TestLintChart(t *testing.T) {
|
||||
t.Errorf("%s", err)
|
||||
}
|
||||
|
||||
if _, err := lintChart(archivedChartPathWithHyphens, values, namespace, strict); err != nil {
|
||||
t.Errorf("%s", err)
|
||||
}
|
||||
|
||||
if _, err := lintChart(invalidArchivedChartPath, values, namespace, strict); err == nil {
|
||||
t.Errorf("Expected a chart parsing error")
|
||||
}
|
||||
}
|
||||
|
||||
BIN
cmd/helm/testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz
vendored
Normal file
BIN
cmd/helm/testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user