File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -2228,7 +2228,7 @@ var _ = Describe("Patch", func() {
2228
2228
}
2229
2229
})
2230
2230
2231
- It ("creates a merge patch with the modifications applied during the mutation" , func () {
2231
+ It ("creates a strategic merge patch with the modifications applied during the mutation" , func () {
2232
2232
const (
2233
2233
annotationKey = "test"
2234
2234
annotationValue = "foo"
@@ -2238,7 +2238,7 @@ var _ = Describe("Patch", func() {
2238
2238
patch := client .MergeFrom (cm .DeepCopy ())
2239
2239
2240
2240
By ("returning a patch with type MergePatch" )
2241
- Expect (patch .Type ()).To (Equal (types .MergePatchType ))
2241
+ Expect (patch .Type ()).To (Equal (types .StrategicMergePatchType ))
2242
2242
2243
2243
By ("retrieving modifying the config map" )
2244
2244
metav1 .SetMetaDataAnnotation (& cm .ObjectMeta , annotationKey , annotationValue )
Original file line number Diff line number Diff line change @@ -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 {
@@ -49,7 +49,7 @@ type mergeFromPatch struct {
49
49
50
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
}
You can’t perform that action at this time.
0 commit comments