cnabio / cnab-go

A Go implementation of CNAB Core 1.0
MIT License
69 stars 35 forks source link

Cannot validate a parameter whose default is {} #270

Closed carolynvs closed 2 years ago

carolynvs commented 3 years ago

When we set a parameter to its default value, we are using fmt.Sprintf which isn't the correct logic as it doesn't take into account objects. Here is an example of the bug that causes https://github.com/getporter/porter/issues/1738

We should use the same custom logic that we use elsewhere in cnab-go when working with a parameter value, depending on its type we have special handling for strings, primitives and objects.

carolynvs commented 2 years ago

I think this is caused by the yaml parser that we are using in Porter to set the parameter default. It's importing the default, {} as map[interface{}]interface{} when it should be map[string]interface{} because that's the correct json representation. It's not a cnab-go bug.