Policy load fix

gql_cataclysm
noah metz 2023-07-31 19:44:52 -06:00
parent 5bef8d96ba
commit 5f2b97a75b
1 changed files with 6 additions and 4 deletions

@ -159,7 +159,7 @@ func (actions NodeActions) MarshalJSON() ([]byte, error) {
return json.Marshal(tmp) return json.Marshal(tmp)
} }
func (actions NodeActions) UnmarshalJSON(data []byte) error { func (actions *NodeActions) UnmarshalJSON(data []byte) error {
tmp := map[string]Actions{} tmp := map[string]Actions{}
err := json.Unmarshal(data, &tmp) err := json.Unmarshal(data, &tmp)
if err != nil { if err != nil {
@ -171,8 +171,8 @@ func (actions NodeActions) UnmarshalJSON(data []byte) error {
if err != nil { if err != nil {
return err return err
} }
ac := *actions
actions[id] = a ac[id] = a
} }
return nil return nil
@ -197,7 +197,9 @@ func AllNodesPolicyLoad(init_fn func(Actions)(Policy, error)) func(*Context, []b
func PerNodePolicyLoad(init_fn func(NodeActions)(Policy, error)) func(*Context, []byte)(Policy, error) { func PerNodePolicyLoad(init_fn func(NodeActions)(Policy, error)) func(*Context, []byte)(Policy, error) {
return func(ctx *Context, data []byte)(Policy, error){ return func(ctx *Context, data []byte)(Policy, error){
var policy PerNodePolicy policy := PerNodePolicy{
NodeActions: NodeActions{},
}
err := json.Unmarshal(data, &policy) err := json.Unmarshal(data, &policy)
if err != nil { if err != nil {
return nil, err return nil, err