Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh committed Feb 8, 2025
1 parent 0e761a5 commit 7e18a4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/helm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ func (h *HelmClient) getRESTClientGetter(namespace string) genericclioptions.RES
}

func cleanUpGenericMap(m map[string]interface{}) (map[string]interface{}, error) {
// we must first use yaml marshal to convert the map[interface{}]interface{} to a []byte
// otherwise we will get an error "unsupported type: map[interface {}]interface {}"
b, err := yaml.Marshal(m)
if err != nil {
return nil, fmt.Errorf("yaml marshal: %w", err)
Expand Down
8 changes: 7 additions & 1 deletion pkg/helm/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
k8syaml "sigs.k8s.io/yaml"
)

func Test_cleanUpGenericMap(t *testing.T) {
Expand Down Expand Up @@ -150,8 +151,13 @@ func Test_cleanUpGenericMap(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
req := require.New(t)
out, err := cleanUpGenericMap(tt.in)
req.NoError(err)
req.NoError(err, "cleanUpGenericMap failed")
req.Equal(tt.want, out)

// ultimately helm calls k8syaml.Marshal so we must make sure that the output is compatible
// https://github.com/helm/helm/blob/v3.17.0/pkg/chartutil/values.go#L39
_, err = k8syaml.Marshal(out)
req.NoError(err, "yaml marshal failed")
})
}
}

0 comments on commit 7e18a4e

Please sign in to comment.