Skip to content

Commit

Permalink
Add a custom marshal function to the jsondiff.Compare call
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinguidee committed Sep 19, 2023
1 parent 546e99d commit fca1d1d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions services/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ func (s *InstanceService) CheckForServiceUpdate(uuid uuid.UUID) error {
patch, err := jsondiff.Compare(current, latest, jsondiff.UnmarshalFunc(func(b []byte, v any) error {
dec := jsoniter.NewDecoder(bytes.NewReader(b))
return dec.Decode(v)
}), jsondiff.MarshalFunc(func(v any) ([]byte, error) {
var buf bytes.Buffer
enc := jsoniter.NewEncoder(&buf)
err := enc.Encode(v)
return buf.Bytes(), err
}))
if err != nil {
return err
Expand Down

0 comments on commit fca1d1d

Please sign in to comment.