Skip to content

Commit

Permalink
ensure no public functions signatures are changed
Browse files Browse the repository at this point in the history
Signed-off-by: Antoine Deschênes <antoine@antoinedeschenes.com>
  • Loading branch information
antoinedeschenes committed Jun 22, 2022
1 parent b604206 commit 7e4445f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pkg/action/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,5 @@ func lintChart(path string, vals map[string]interface{}, namespace string, stric
return linter, errors.Wrap(err, "unable to check Chart.yaml file in chart")
}

return lint.All(chartPath, vals, namespace, strict, kubeVersion), nil
return lint.AllWithVersion(chartPath, vals, namespace, strict, kubeVersion), nil
}
9 changes: 7 additions & 2 deletions pkg/lint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ import (
)

// All runs all of the available linters on the given base directory.
func All(basedir string, values map[string]interface{}, namespace string, strict bool, kubeVersion *chartutil.KubeVersion) support.Linter {
func All(basedir string, values map[string]interface{}, namespace string, strict bool) support.Linter {
return AllWithVersion(basedir, values, namespace, strict, nil)
}

// AllWithVersion runs all of the available linters on the given base directory, allowing to specify the kubernetes version.
func AllWithVersion(basedir string, values map[string]interface{}, namespace string, strict bool, kubeVersion *chartutil.KubeVersion) support.Linter {
// Using abs path to get directory context
chartDir, _ := filepath.Abs(basedir)

linter := support.Linter{ChartDir: chartDir}
rules.Chartfile(&linter)
rules.ValuesWithOverrides(&linter, values)
rules.Templates(&linter, values, namespace, strict, kubeVersion)
rules.TemplatesWithVersion(&linter, values, namespace, strict, kubeVersion)
rules.Dependencies(&linter)
return linter
}
12 changes: 6 additions & 6 deletions pkg/lint/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const goodChartDir = "rules/testdata/goodone"
const subChartValuesDir = "rules/testdata/withsubchart"

func TestBadChart(t *testing.T) {
m := All(badChartDir, values, namespace, strict, nil).Messages
m := All(badChartDir, values, namespace, strict).Messages
if len(m) != 8 {
t.Errorf("Number of errors %v", len(m))
t.Errorf("All didn't fail with expected errors, got %#v", m)
Expand Down Expand Up @@ -85,7 +85,7 @@ func TestBadChart(t *testing.T) {
}

func TestInvalidYaml(t *testing.T) {
m := All(badYamlFileDir, values, namespace, strict, nil).Messages
m := All(badYamlFileDir, values, namespace, strict).Messages
if len(m) != 1 {
t.Fatalf("All didn't fail with expected errors, got %#v", m)
}
Expand All @@ -95,7 +95,7 @@ func TestInvalidYaml(t *testing.T) {
}

func TestBadValues(t *testing.T) {
m := All(badValuesFileDir, values, namespace, strict, nil).Messages
m := All(badValuesFileDir, values, namespace, strict).Messages
if len(m) < 1 {
t.Fatalf("All didn't fail with expected errors, got %#v", m)
}
Expand All @@ -105,7 +105,7 @@ func TestBadValues(t *testing.T) {
}

func TestGoodChart(t *testing.T) {
m := All(goodChartDir, values, namespace, strict, nil).Messages
m := All(goodChartDir, values, namespace, strict).Messages
if len(m) != 0 {
t.Error("All returned linter messages when it shouldn't have")
for i, msg := range m {
Expand All @@ -129,7 +129,7 @@ func TestHelmCreateChart(t *testing.T) {

// Note: we test with strict=true here, even though others have
// strict = false.
m := All(createdChart, values, namespace, true, nil).Messages
m := All(createdChart, values, namespace, true).Messages
if ll := len(m); ll != 1 {
t.Errorf("All should have had exactly 1 error. Got %d", ll)
for i, msg := range m {
Expand All @@ -143,7 +143,7 @@ func TestHelmCreateChart(t *testing.T) {
// lint ignores import-values
// See https://github.com/helm/helm/issues/9658
func TestSubChartValuesChart(t *testing.T) {
m := All(subChartValuesDir, values, namespace, strict, nil).Messages
m := All(subChartValuesDir, values, namespace, strict).Messages
if len(m) != 0 {
t.Error("All returned linter messages when it shouldn't have")
for i, msg := range m {
Expand Down
7 changes: 6 additions & 1 deletion pkg/lint/rules/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ var (
)

// Templates lints the templates in the Linter.
func Templates(linter *support.Linter, values map[string]interface{}, namespace string, strict bool, kubeVersion *chartutil.KubeVersion) {
func Templates(linter *support.Linter, values map[string]interface{}, namespace string, strict bool) {
TemplatesWithVersion(linter, values, namespace, strict, nil)
}

// TemplatesWithVersion lints the templates in the Linter, allowing to specify the kubernetes version.
func TemplatesWithVersion(linter *support.Linter, values map[string]interface{}, namespace string, strict bool, kubeVersion *chartutil.KubeVersion) {
fpath := "templates/"
templatesPath := filepath.Join(linter.ChartDir, fpath)

Expand Down
14 changes: 7 additions & 7 deletions pkg/lint/rules/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const strict = false

func TestTemplateParsing(t *testing.T) {
linter := support.Linter{ChartDir: templateTestBasedir}
Templates(&linter, values, namespace, strict, nil)
Templates(&linter, values, namespace, strict)
res := linter.Messages

if len(res) != 1 {
Expand All @@ -78,7 +78,7 @@ func TestTemplateIntegrationHappyPath(t *testing.T) {
defer os.Rename(ignoredTemplatePath, wrongTemplatePath)

linter := support.Linter{ChartDir: templateTestBasedir}
Templates(&linter, values, namespace, strict, nil)
Templates(&linter, values, namespace, strict)
res := linter.Messages

if len(res) != 0 {
Expand All @@ -88,7 +88,7 @@ func TestTemplateIntegrationHappyPath(t *testing.T) {

func TestV3Fail(t *testing.T) {
linter := support.Linter{ChartDir: "./testdata/v3-fail"}
Templates(&linter, values, namespace, strict, nil)
Templates(&linter, values, namespace, strict)
res := linter.Messages

if len(res) != 3 {
Expand All @@ -108,7 +108,7 @@ func TestV3Fail(t *testing.T) {

func TestMultiTemplateFail(t *testing.T) {
linter := support.Linter{ChartDir: "./testdata/multi-template-fail"}
Templates(&linter, values, namespace, strict, nil)
Templates(&linter, values, namespace, strict)
res := linter.Messages

if len(res) != 1 {
Expand Down Expand Up @@ -229,7 +229,7 @@ func TestDeprecatedAPIFails(t *testing.T) {
}

linter := support.Linter{ChartDir: filepath.Join(tmpdir, mychart.Name())}
Templates(&linter, values, namespace, strict, nil)
Templates(&linter, values, namespace, strict)
if l := len(linter.Messages); l != 1 {
for i, msg := range linter.Messages {
t.Logf("Message %d: %s", i, msg)
Expand Down Expand Up @@ -286,7 +286,7 @@ func TestStrictTemplateParsingMapError(t *testing.T) {
linter := &support.Linter{
ChartDir: filepath.Join(dir, ch.Metadata.Name),
}
Templates(linter, ch.Values, namespace, strict, nil)
Templates(linter, ch.Values, namespace, strict)
if len(linter.Messages) != 0 {
t.Errorf("expected zero messages, got %d", len(linter.Messages))
for i, msg := range linter.Messages {
Expand Down Expand Up @@ -416,7 +416,7 @@ func TestEmptyWithCommentsManifests(t *testing.T) {
}

linter := support.Linter{ChartDir: filepath.Join(tmpdir, mychart.Name())}
Templates(&linter, values, namespace, strict, nil)
Templates(&linter, values, namespace, strict)
if l := len(linter.Messages); l > 0 {
for i, msg := range linter.Messages {
t.Logf("Message %d: %s", i, msg)
Expand Down

0 comments on commit 7e4445f

Please sign in to comment.