Skip to content

Commit

Permalink
fixed serialization of val
Browse files Browse the repository at this point in the history
  • Loading branch information
xadhatter committed Aug 29, 2024
1 parent 6c1bcfd commit 51d708f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 1 addition & 5 deletions api/val_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func ValArrayString(val []string) *Val {
}

func ValMapArrayString(val map[string][]string) *Val {
return &Val{Type: ArrayString, mapStrVal: val}
return &Val{Type: MapArrayString, mapStrVal: val}
}

func (val *Val) Any() any {
Expand Down Expand Up @@ -325,10 +325,6 @@ func (val *Val) EnvVarType() EnvVarType {
func (val *Val) UnmarshalJSON(value []byte) error {
defErr := errors.New("value must be type boolean, number, string, []number, or []string; nested objects are not supported")

if value[0] == '{' {
return defErr
}

switch value[0] {
case '{':
// try to unmarshal map of strings
Expand Down
4 changes: 3 additions & 1 deletion components/broker/engine/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package engine

import (
"context"
"encoding/json"
"errors"
"sync"
"time"
Expand Down Expand Up @@ -92,7 +93,8 @@ func (ctx *BrokerEventContext) MatchedEvent() *core.MatchedEvent {
// Only include vars that target declared as dependencies.
m.Env = make(map[string]string, len(def.EnvVarSchema))
for k := range def.EnvVarSchema {
m.Env[k] = ctx.Data.Vars[k].String()
b, _ := json.Marshal(ctx.Data.Vars[k])
m.Env[k] = string(b)
}

return m
Expand Down
2 changes: 2 additions & 0 deletions core/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ func (evt *Event) SetValueMapKey(valKey, key, value string, overwrite bool) {
} else {
v.MapArrayString()[key] = append(a, value)
}
evt.SetValueV(valKey, v)
}

func (evt *Event) DelValueMapKey(valKey, key string) {
Expand All @@ -327,6 +328,7 @@ func (evt *Event) DelValueMapKey(valKey, key string) {
}

delete(v.MapArrayString(), key)
evt.SetValueV(valKey, v)
}

func (evt *Event) SetSpec(spec any) error {
Expand Down

0 comments on commit 51d708f

Please sign in to comment.