@@ -213,8 +213,9 @@ var computeTagsDelta = tags.ComputeTagsDelta
213
213
214
214
// customPreCompare ensures that default values of types are initialised and
215
215
// server side defaults are excluded from the delta.
216
- // The left side (`A`) of any `Spec.Routes` diff contains the routes to add, the
217
- // right side (`B`) the routes that must be deleted.
216
+ // The left side (`A`) of any `Spec.Routes` diff contains the routes that are
217
+ // desired, but do not exist. Analogously, the right side (`B`) contains the
218
+ // routes that exist, but are not desired.
218
219
func customPreCompare (
219
220
delta * ackcompare.Delta ,
220
221
a * resource ,
@@ -223,8 +224,8 @@ func customPreCompare(
223
224
a .ko .Spec .Routes = removeLocalRoute (a .ko .Spec .Routes )
224
225
b .ko .Spec .Routes = removeLocalRoute (b .ko .Spec .Routes )
225
226
226
- toAdd := []* svcapitypes.CreateRouteInput {}
227
- toDelete := b .ko .Spec .DeepCopy ().Routes
227
+ desired := []* svcapitypes.CreateRouteInput {}
228
+ latest := b .ko .Spec .DeepCopy ().Routes
228
229
229
230
remove := func (s []* svcapitypes.CreateRouteInput , i int ) []* svcapitypes.CreateRouteInput {
230
231
if i < len (s )- 1 { // if not last element just copy the last element to where the removed element was
@@ -233,24 +234,22 @@ func customPreCompare(
233
234
return s [:len (s )- 1 ]
234
235
}
235
236
236
- // Routes that are desired, but not in latest, need to be added.
237
- // Routes that are in latest, but not desired, need to be deleted.
238
- // Everything else, we don't touch.
237
+ // Routes that are desired, but already exist in latest, can be ignored.
239
238
for _ , routeA := range a .ko .Spec .Routes {
240
239
found := false
241
- for idx , routeB := range toDelete {
240
+ for idx , routeB := range latest {
242
241
if found = reflect .DeepEqual (routeA , routeB ); found {
243
- toDelete = remove (toDelete , idx )
242
+ latest = remove (latest , idx )
244
243
break
245
244
}
246
245
}
247
246
if ! found {
248
- toAdd = append (toAdd , routeA .DeepCopy ())
247
+ desired = append (desired , routeA .DeepCopy ())
249
248
}
250
249
}
251
250
252
- if len (toAdd ) > 0 || len (toDelete ) > 0 {
253
- delta .Add ("Spec.Routes" , toAdd , toDelete )
251
+ if len (desired ) > 0 || len (latest ) > 0 {
252
+ delta .Add ("Spec.Routes" , desired , latest )
254
253
}
255
254
}
256
255
0 commit comments