From 6afd0b4c6c25f2000cd496886490812a3fdf9059 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 21 Feb 2020 13:59:42 -0700 Subject: [PATCH] fix: add new static linter and fix issues it found Signed-off-by: Matt Butcher --- .golangci.yml | 1 + go.mod | 1 + internal/experimental/registry/client_test.go | 4 ++-- pkg/lint/rules/template.go | 8 +++----- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 2c3b6234d..491e648a1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -17,6 +17,7 @@ linters: - structcheck - unused - varcheck + - staticcheck linters-settings: gofmt: diff --git a/go.mod b/go.mod index 9c22ea9e5..ccf99886c 100644 --- a/go.mod +++ b/go.mod @@ -29,6 +29,7 @@ require ( github.com/stretchr/testify v1.4.0 github.com/xeipuuv/gojsonschema v1.1.0 golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d + honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc // indirect k8s.io/api v0.17.3 k8s.io/apiextensions-apiserver v0.17.3 k8s.io/apimachinery v0.17.3 diff --git a/internal/experimental/registry/client_test.go b/internal/experimental/registry/client_test.go index 33799f5fa..6e9d5db36 100644 --- a/internal/experimental/registry/client_test.go +++ b/internal/experimental/registry/client_test.go @@ -162,13 +162,13 @@ func (suite *RegistryClientTestSuite) Test_2_LoadChart() { // non-existent ref ref, err := ParseReference(fmt.Sprintf("%s/testrepo/whodis:9.9.9", suite.DockerRegistryHost)) suite.Nil(err) - ch, err := suite.RegistryClient.LoadChart(ref) + _, err = suite.RegistryClient.LoadChart(ref) suite.NotNil(err) // existing ref ref, err = ParseReference(fmt.Sprintf("%s/testrepo/testchart:1.2.3", suite.DockerRegistryHost)) suite.Nil(err) - ch, err = suite.RegistryClient.LoadChart(ref) + ch, err := suite.RegistryClient.LoadChart(ref) suite.Nil(err) suite.Equal("testchart", ch.Metadata.Name) suite.Equal("1.2.3", ch.Metadata.Version) diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go index 5c6cd7336..3d388f81b 100644 --- a/pkg/lint/rules/template.go +++ b/pkg/lint/rules/template.go @@ -116,11 +116,9 @@ func Templates(linter *support.Linter, values map[string]interface{}, namespace // key will be raised as well err := yaml.Unmarshal([]byte(renderedContent), &yamlStruct) - validYaml := linter.RunLinterRule(support.ErrorSev, path, validateYamlContent(err)) - - if !validYaml { - continue - } + // If YAML linting fails, we sill progress. So we don't capture the returned state + // on this linter run. + linter.RunLinterRule(support.ErrorSev, path, validateYamlContent(err)) } }