diff --git a/pkg/helm/context.go b/pkg/helm/context.go index 5622f71..b0f319d 100644 --- a/pkg/helm/context.go +++ b/pkg/helm/context.go @@ -133,6 +133,9 @@ func getPathAndKey(path []string) ([]string, string) { } func normalize(value any) (any, error) { + if value == nil { + return nil, nil + } t := reflect.TypeOf(value) if t.Kind() == reflect.Pointer { t = t.Elem() @@ -158,24 +161,31 @@ func normalize(value any) (any, error) { func normalizeMap(values map[string]any) (map[string]any, error) { normalized := make(map[string]any) + if values == nil { + return normalized, nil + } for key, value := range values { - v, err := normalize(value) - if err != nil { - return nil, err + if value != nil { + v, err := normalize(value) + if err != nil { + return nil, err + } + normalized[key] = v } - normalized[key] = v } return normalized, nil } func normalizeSlice(values []any) ([]any, error) { - normalized := make([]any, len(values)) - for i, value := range values { - v, err := normalize(value) - if err != nil { - return nil, err + normalized := make([]any, 0, len(values)) + for _, value := range values { + if value != nil { + v, err := normalize(value) + if err != nil { + return nil, err + } + normalized = append(normalized, v) } - normalized[i] = v } return normalized, nil } diff --git a/pkg/helm/context_test.go b/pkg/helm/context_test.go index d5537fb..36bc1ad 100644 --- a/pkg/helm/context_test.go +++ b/pkg/helm/context_test.go @@ -25,6 +25,7 @@ func TestReleaseValues(t *testing.T) { "a": "b", "b": map[string]any{ "c": 1, + "d": nil, }, } defaultFiles := []string{