Update golangci-lint and fix linting issues

update golangci-lint from version 1.43.0 to the
latest linter version 1.46.2.

Fixed linting issues:

Remove newline from error string in internal/test/test.go
and remove redundant nil / len(0) check from asMap() function
in pkg/chartutil/values.go. Guard this function by a unit test.

Signed-off-by: Felix Becker <git@felixbecker.name>
pull/11064/head
Felix Becker 3 years ago
parent 657850e44b
commit 89d2d679e6

@ -13,7 +13,7 @@ jobs:
environment:
GOCACHE: "/tmp/go/cache"
GOLANGCI_LINT_VERSION: "1.43.0"
GOLANGCI_LINT_VERSION: "1.46.2"
steps:
- checkout

@ -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
}

@ -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

@ -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"

Loading…
Cancel
Save