diff --git a/.circleci/config.yml b/.circleci/config.yml index 7a9c4874d..49356131c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,7 +13,7 @@ jobs: environment: GOCACHE: "/tmp/go/cache" - GOLANGCI_LINT_VERSION: "1.43.0" + GOLANGCI_LINT_VERSION: "1.46.2" steps: - checkout diff --git a/internal/test/test.go b/internal/test/test.go index 0de3210c4..e25463f28 100644 --- a/internal/test/test.go +++ b/internal/test/test.go @@ -79,7 +79,7 @@ func compare(actual []byte, filename string) error { } expected = normalize(expected) if !bytes.Equal(expected, actual) { - return errors.Errorf("does not match golden file %s\n\nWANT:\n'%s'\n\nGOT:\n'%s'\n", filename, expected, actual) + return errors.Errorf("does not match golden file %s\n\nWANT:\n'%s'\n\nGOT:\n'%s'", filename, expected, actual) } return nil } diff --git a/pkg/chartutil/values.go b/pkg/chartutil/values.go index e1cdf4642..97bf44217 100644 --- a/pkg/chartutil/values.go +++ b/pkg/chartutil/values.go @@ -68,7 +68,7 @@ func (v Values) Table(name string) (Values, error) { // // It protects against nil map panics. func (v Values) AsMap() map[string]interface{} { - if v == nil || len(v) == 0 { + if len(v) == 0 { return map[string]interface{}{} } return v diff --git a/pkg/chartutil/values_test.go b/pkg/chartutil/values_test.go index c95fa503a..fa6efd7aa 100644 --- a/pkg/chartutil/values_test.go +++ b/pkg/chartutil/values_test.go @@ -25,6 +25,22 @@ import ( "helm.sh/helm/v3/pkg/chart" ) +func TestAsMap(t *testing.T) { + var nilValues Values + asMap := nilValues.AsMap() + if asMap == nil { + t.Error("nilValues.AsMap() must not be nil") + } + asMap["foo"] = "bar" + nilValuesPtr := &nilValues + nilPtrAsMap := nilValuesPtr.AsMap() + if nilPtrAsMap == nil { + t.Error("nilValuesPtr.AsMap() must not be nil") + } + nilPtrAsMap["foo"] = "bar" + +} + func TestReadValues(t *testing.T) { doc := `# Test YAML parse poet: "Coleridge"