add changelog

Signed-off-by: lou <alex1988@outlook.com>
This commit is contained in:
lou
2023-10-04 16:02:23 +08:00
parent d8b9328310
commit 06ed9dcc71
4 changed files with 5 additions and 9 deletions

View File

@@ -23,21 +23,20 @@ func (p *JSONMergePatcher) Patch(u *unstructured.Unstructured, _ logrus.FieldLog
return nil, fmt.Errorf("error in marshaling object %s", err)
}
var modifiedObjBytes []byte
for _, patch := range p.patches {
patchBytes, err := yaml.YAMLToJSON(patch.PatchBytes)
if err != nil {
return nil, fmt.Errorf("error in converting YAML to JSON %s", err)
}
modifiedObjBytes, err = jsonpatch.MergePatch(objBytes, patchBytes)
objBytes, err = jsonpatch.MergePatch(objBytes, patchBytes)
if err != nil {
return nil, fmt.Errorf("error in applying JSON Patch %s", err.Error())
}
}
updated := &unstructured.Unstructured{}
err = updated.UnmarshalJSON(modifiedObjBytes)
err = updated.UnmarshalJSON(objBytes)
if err != nil {
return nil, fmt.Errorf("error in unmarshalling modified object %s", err.Error())
}

View File

@@ -33,10 +33,6 @@ func (p *StrategicMergePatcher) Patch(u *unstructured.Unstructured, _ logrus.Fie
return nil, err
}
if err != nil {
return nil, fmt.Errorf("error in unmarshaling object %s", err.Error())
}
origin := u.DeepCopy()
updated := u.DeepCopy()
for _, patch := range p.patches {
@@ -47,7 +43,7 @@ func (p *StrategicMergePatcher) Patch(u *unstructured.Unstructured, _ logrus.Fie
err = strategicPatchObject(origin, patchBytes, updated, schemaReferenceObj, metav1.FieldValidationStrict)
if err != nil {
return nil, fmt.Errorf("error in applying JSON Patch %s", err.Error())
return nil, fmt.Errorf("error in applying Strategic Patch %s", err.Error())
}
origin = updated.DeepCopy()