Skip to content

Commit

Permalink
fix: map mutation (#304)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly authored Feb 9, 2024
1 parent 60f879c commit 11a8cc9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/engine/mutate/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ func (n mapNode) mutate(ctx context.Context, path *field.Path, value any, bindin
out := map[any]any{}
for k, v := range n {
// TODO: very simple implementation
mapValue := reflect.ValueOf(value).MapIndex(reflect.ValueOf(k))
if !mapValue.IsValid() {
continue
var value any
if value != nil {
mapValue := reflect.ValueOf(value).MapIndex(reflect.ValueOf(k))
if !mapValue.IsValid() {
value = mapValue.Interface()
}
}
value := mapValue.Interface()
// TODO: does it make sense to take valueOf.Index(i).Interface() here ?
if inner, err := v.mutate(ctx, path.Child(fmt.Sprint(k)), value, bindings, opts...); err != nil {
return nil, err
} else {
Expand Down

0 comments on commit 11a8cc9

Please sign in to comment.