Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
Signed-off-by: Israel Blancas <[email protected]>
  • Loading branch information
iblancasa committed Sep 12, 2024
1 parent b40287d commit 678dac8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion apis/v1beta1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,22 @@ func (c *AnyConfig) MarshalJSON() ([]byte, error) {
if c == nil {
return []byte("{}"), nil
}
return json.Marshal(c.Object)
return json.Marshal(c.convertNilToEmptyMap(c.Object))
}

func (c *AnyConfig) convertNilToEmptyMap(m map[string]interface{}) map[string]interface{} {
result := make(map[string]interface{})
for k, v := range m {
switch val := v.(type) {
case nil:
result[k] = map[string]interface{}{}
case map[string]interface{}:
result[k] = c.convertNilToEmptyMap(val)
default:
result[k] = v
}
}
return result
}

// Pipeline is a struct of component type to a list of component IDs.
Expand Down

0 comments on commit 678dac8

Please sign in to comment.