Skip to content

Commit 1c8d494

Browse files
authored
fix(patch): use ordered keys when marshalling json (#29)
1 parent 137a7f3 commit 1c8d494

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

patch/annotation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func (a *Annotator) GetModifiedConfiguration(obj runtime.Object, annotate bool)
115115
a.metadataAccessor.SetAnnotations(obj, nil)
116116
}
117117

118-
modified, err = json.Marshal(obj)
118+
modified, err = json.ConfigCompatibleWithStandardLibrary.Marshal(obj)
119119
if err != nil {
120120
return nil, err
121121
}
@@ -126,7 +126,7 @@ func (a *Annotator) GetModifiedConfiguration(obj runtime.Object, annotate bool)
126126
return nil, err
127127
}
128128

129-
modified, err = json.Marshal(obj)
129+
modified, err = json.ConfigCompatibleWithStandardLibrary.Marshal(obj)
130130
if err != nil {
131131
return nil, err
132132
}

patch/deletenull.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func DeleteNullInJson(jsonBytes []byte) ([]byte, map[string]interface{}, error)
101101
return nil, nil, emperror.Wrap(err, "could not delete null values from patch map")
102102
}
103103

104-
o, err := json.Marshal(filteredMap)
104+
o, err := json.ConfigCompatibleWithStandardLibrary.Marshal(filteredMap)
105105
if err != nil {
106106
return nil, nil, emperror.Wrap(err, "could not marshal filtered patch map")
107107
}
@@ -183,7 +183,7 @@ func deleteStatusField(obj []byte) ([]byte, error) {
183183
return []byte{}, emperror.Wrap(err, "could not unmarshal byte sequence")
184184
}
185185
delete(objectMap, "status")
186-
obj, err = json.Marshal(objectMap)
186+
obj, err = json.ConfigCompatibleWithStandardLibrary.Marshal(objectMap)
187187
if err != nil {
188188
return []byte{}, emperror.Wrap(err, "could not marshal byte sequence")
189189
}
@@ -206,7 +206,7 @@ func deleteVolumeClaimTemplateFields(obj []byte) ([]byte, error) {
206206
}
207207
}
208208

209-
obj, err = json.Marshal(sts)
209+
obj, err = json.ConfigCompatibleWithStandardLibrary.Marshal(sts)
210210
if err != nil {
211211
return []byte{}, emperror.Wrap(err, "could not marshal byte sequence")
212212
}

patch/patch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ func NewPatchMaker(annotator *Annotator) *PatchMaker {
3939
}
4040

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

47-
modified, err := json.Marshal(modifiedObject)
47+
modified, err := json.ConfigCompatibleWithStandardLibrary.Marshal(modifiedObject)
4848
if err != nil {
4949
return nil, emperror.Wrap(err, "Failed to convert current object to byte sequence")
5050
}

0 commit comments

Comments
 (0)