@@ -17,10 +17,10 @@ limitations under the License.
17
17
package client
18
18
19
19
import (
20
- jsonpatch "github.com/evanphx/json-patch"
21
20
"k8s.io/apimachinery/pkg/runtime"
22
21
"k8s.io/apimachinery/pkg/types"
23
22
"k8s.io/apimachinery/pkg/util/json"
23
+ "k8s.io/apimachinery/pkg/util/strategicpatch"
24
24
)
25
25
26
26
type patch struct {
@@ -47,9 +47,9 @@ type mergeFromPatch struct {
47
47
from runtime.Object
48
48
}
49
49
50
- // Type implements patch .
50
+ // Type implements Patch .
51
51
func (s * mergeFromPatch ) Type () types.PatchType {
52
- return types .MergePatchType
52
+ return types .StrategicMergePatchType
53
53
}
54
54
55
55
// Data implements Patch.
@@ -64,10 +64,11 @@ func (s *mergeFromPatch) Data(obj runtime.Object) ([]byte, error) {
64
64
return nil , err
65
65
}
66
66
67
- return jsonpatch . CreateMergePatch (originalJSON , modifiedJSON )
67
+ return strategicpatch . CreateTwoWayMergePatch (originalJSON , modifiedJSON , obj )
68
68
}
69
69
70
- // MergeFrom creates a Patch that patches using the merge-patch strategy with the given object as base.
70
+ // MergeFrom creates a Patch that patches using the strategic
71
+ // merge-patch strategy with the given object as base.
71
72
func MergeFrom (obj runtime.Object ) Patch {
72
73
return & mergeFromPatch {obj }
73
74
}
0 commit comments