@@ -81,6 +81,40 @@ func TestUpdateLeaf(t *testing.T) {
81
81
},
82
82
},
83
83
},
84
+ "apply_twice_different_versions" : {
85
+ Ops : []Operation {
86
+ Apply {
87
+ Manager : "default" ,
88
+ Object : `
89
+ numeric: 1
90
+ string: "string"
91
+ ` ,
92
+ APIVersion : "v1" ,
93
+ },
94
+ Apply {
95
+ Manager : "default" ,
96
+ Object : `
97
+ numeric: 2
98
+ string: "string"
99
+ bool: false
100
+ ` ,
101
+ APIVersion : "v2" ,
102
+ },
103
+ },
104
+ Object : `
105
+ numeric: 2
106
+ string: "string"
107
+ bool: false
108
+ ` ,
109
+ Managed : fieldpath.ManagedFields {
110
+ "default" : & fieldpath.VersionedSet {
111
+ Set : _NS (
112
+ _P ("numeric" ), _P ("string" ), _P ("bool" ),
113
+ ),
114
+ APIVersion : "v2" ,
115
+ },
116
+ },
117
+ },
84
118
"apply_update_apply_no_conflict" : {
85
119
Ops : []Operation {
86
120
Apply {
@@ -129,6 +163,54 @@ func TestUpdateLeaf(t *testing.T) {
129
163
},
130
164
},
131
165
},
166
+ "apply_update_apply_no_conflict_different_version" : {
167
+ Ops : []Operation {
168
+ Apply {
169
+ Manager : "default" ,
170
+ APIVersion : "v1" ,
171
+ Object : `
172
+ numeric: 1
173
+ string: "string"
174
+ ` ,
175
+ },
176
+ Update {
177
+ Manager : "controller" ,
178
+ APIVersion : "v2" ,
179
+ Object : `
180
+ numeric: 1
181
+ string: "string"
182
+ bool: true
183
+ ` ,
184
+ },
185
+ Apply {
186
+ Manager : "default" ,
187
+ APIVersion : "v1" ,
188
+ Object : `
189
+ numeric: 2
190
+ string: "string"
191
+ ` ,
192
+ },
193
+ },
194
+ Object : `
195
+ numeric: 2
196
+ string: "string"
197
+ bool: true
198
+ ` ,
199
+ Managed : fieldpath.ManagedFields {
200
+ "default" : & fieldpath.VersionedSet {
201
+ Set : _NS (
202
+ _P ("numeric" ), _P ("string" ),
203
+ ),
204
+ APIVersion : "v1" ,
205
+ },
206
+ "controller" : & fieldpath.VersionedSet {
207
+ Set : _NS (
208
+ _P ("bool" ),
209
+ ),
210
+ APIVersion : "v2" ,
211
+ },
212
+ },
213
+ },
132
214
"apply_update_apply_with_conflict" : {
133
215
Ops : []Operation {
134
216
Apply {
@@ -188,6 +270,65 @@ func TestUpdateLeaf(t *testing.T) {
188
270
},
189
271
},
190
272
},
273
+ "apply_update_apply_with_conflict_across_version" : {
274
+ Ops : []Operation {
275
+ Apply {
276
+ Manager : "default" ,
277
+ APIVersion : "v1" ,
278
+ Object : `
279
+ numeric: 1
280
+ string: "string"
281
+ ` ,
282
+ },
283
+ Update {
284
+ Manager : "controller" ,
285
+ APIVersion : "v2" ,
286
+ Object : `
287
+ numeric: 1
288
+ string: "controller string"
289
+ bool: true
290
+ ` ,
291
+ },
292
+ Apply {
293
+ Manager : "default" ,
294
+ APIVersion : "v1" ,
295
+ Object : `
296
+ numeric: 2
297
+ string: "user string"
298
+ ` ,
299
+ Conflicts : merge.Conflicts {
300
+ merge.Conflict {Manager : "controller" , Path : _P ("string" )},
301
+ },
302
+ },
303
+ ForceApply {
304
+ Manager : "default" ,
305
+ APIVersion : "v1" ,
306
+ Object : `
307
+ numeric: 2
308
+ string: "user string"
309
+ ` ,
310
+ },
311
+ },
312
+ Object : `
313
+ numeric: 2
314
+ string: "user string"
315
+ bool: true
316
+ ` ,
317
+ Managed : fieldpath.ManagedFields {
318
+ "default" : & fieldpath.VersionedSet {
319
+ Set : _NS (
320
+ _P ("numeric" ), _P ("string" ),
321
+ ),
322
+ APIVersion : "v1" ,
323
+ },
324
+ "controller" : & fieldpath.VersionedSet {
325
+ Set : _NS (
326
+ _P ("bool" ),
327
+ ),
328
+ APIVersion : "v2" ,
329
+ },
330
+ },
331
+ },
191
332
"apply_twice_dangling" : {
192
333
Ops : []Operation {
193
334
Apply {
@@ -221,6 +362,39 @@ func TestUpdateLeaf(t *testing.T) {
221
362
},
222
363
},
223
364
},
365
+ "apply_twice_dangling_different_version" : {
366
+ Ops : []Operation {
367
+ Apply {
368
+ Manager : "default" ,
369
+ APIVersion : "v1" ,
370
+ Object : `
371
+ numeric: 1
372
+ string: "string"
373
+ bool: false
374
+ ` ,
375
+ },
376
+ Apply {
377
+ Manager : "default" ,
378
+ APIVersion : "v2" ,
379
+ Object : `
380
+ string: "new string"
381
+ ` ,
382
+ },
383
+ },
384
+ Object : `
385
+ numeric: 1
386
+ string: "new string"
387
+ bool: false
388
+ ` ,
389
+ Managed : fieldpath.ManagedFields {
390
+ "default" : & fieldpath.VersionedSet {
391
+ Set : _NS (
392
+ _P ("string" ),
393
+ ),
394
+ APIVersion : "v2" ,
395
+ },
396
+ },
397
+ },
224
398
"update_remove_empty_set" : {
225
399
Ops : []Operation {
226
400
Apply {
0 commit comments