Skip to content

Commit

Permalink
fix: map mutation (#305)
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 11a8cc9 commit 44d153c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/engine/mutate/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ 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
var value any
var projection any
if value != nil {
mapValue := reflect.ValueOf(value).MapIndex(reflect.ValueOf(k))
if !mapValue.IsValid() {
value = mapValue.Interface()
if mapValue.IsValid() {
projection = mapValue.Interface()
}
}
if inner, err := v.mutate(ctx, path.Child(fmt.Sprint(k)), value, bindings, opts...); err != nil {
if inner, err := v.mutate(ctx, path.Child(fmt.Sprint(k)), projection, bindings, opts...); err != nil {
return nil, err
} else {
out[k] = inner
Expand Down

0 comments on commit 44d153c

Please sign in to comment.