Skip to content

Commit

Permalink
fix(patch): use ordered keys when marshalling json (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
eachirei authored Jun 8, 2020
1 parent 137a7f3 commit 1c8d494
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions patch/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (a *Annotator) GetModifiedConfiguration(obj runtime.Object, annotate bool)
a.metadataAccessor.SetAnnotations(obj, nil)
}

modified, err = json.Marshal(obj)
modified, err = json.ConfigCompatibleWithStandardLibrary.Marshal(obj)
if err != nil {
return nil, err
}
Expand All @@ -126,7 +126,7 @@ func (a *Annotator) GetModifiedConfiguration(obj runtime.Object, annotate bool)
return nil, err
}

modified, err = json.Marshal(obj)
modified, err = json.ConfigCompatibleWithStandardLibrary.Marshal(obj)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions patch/deletenull.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func DeleteNullInJson(jsonBytes []byte) ([]byte, map[string]interface{}, error)
return nil, nil, emperror.Wrap(err, "could not delete null values from patch map")
}

o, err := json.Marshal(filteredMap)
o, err := json.ConfigCompatibleWithStandardLibrary.Marshal(filteredMap)
if err != nil {
return nil, nil, emperror.Wrap(err, "could not marshal filtered patch map")
}
Expand Down Expand Up @@ -183,7 +183,7 @@ func deleteStatusField(obj []byte) ([]byte, error) {
return []byte{}, emperror.Wrap(err, "could not unmarshal byte sequence")
}
delete(objectMap, "status")
obj, err = json.Marshal(objectMap)
obj, err = json.ConfigCompatibleWithStandardLibrary.Marshal(objectMap)
if err != nil {
return []byte{}, emperror.Wrap(err, "could not marshal byte sequence")
}
Expand All @@ -206,7 +206,7 @@ func deleteVolumeClaimTemplateFields(obj []byte) ([]byte, error) {
}
}

obj, err = json.Marshal(sts)
obj, err = json.ConfigCompatibleWithStandardLibrary.Marshal(sts)
if err != nil {
return []byte{}, emperror.Wrap(err, "could not marshal byte sequence")
}
Expand Down
4 changes: 2 additions & 2 deletions patch/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ func NewPatchMaker(annotator *Annotator) *PatchMaker {
}

func (p *PatchMaker) Calculate(currentObject, modifiedObject runtime.Object, opts ...CalculateOption) (*PatchResult, error) {
current, err := json.Marshal(currentObject)
current, err := json.ConfigCompatibleWithStandardLibrary.Marshal(currentObject)
if err != nil {
return nil, emperror.Wrap(err, "Failed to convert current object to byte sequence")
}

modified, err := json.Marshal(modifiedObject)
modified, err := json.ConfigCompatibleWithStandardLibrary.Marshal(modifiedObject)
if err != nil {
return nil, emperror.Wrap(err, "Failed to convert current object to byte sequence")
}
Expand Down

0 comments on commit 1c8d494

Please sign in to comment.