@@ -238,7 +238,6 @@ private Condition toCondition(ConditionSpec condition) {
238
238
throw new IllegalStateException ("Unknown condition: " + condition );
239
239
}
240
240
241
- // todo docs
242
241
private void addFinalizersToParentResource (Glue primary , Context <Glue > context ) {
243
242
var parent = getParentRelatedResource (primary , context );
244
243
@@ -249,12 +248,7 @@ private void addFinalizersToParentResource(Glue primary, Context<Glue> context)
249
248
if (!p .getMetadata ().getFinalizers ().contains (finalizer )) {
250
249
var res = getResourceForSSAFrom (p );
251
250
res .getMetadata ().getFinalizers ().add (finalizer );
252
- context .getClient ().resource (res )
253
- .patch (new PatchContext .Builder ()
254
- .withFieldManager (context .getControllerConfiguration ().fieldManager ())
255
- .withForce (true )
256
- .withPatchType (PatchType .SERVER_SIDE_APPLY )
257
- .build ());
251
+ patchResource (res , context );
258
252
}
259
253
});
260
254
}
@@ -267,18 +261,23 @@ private void removeFinalizerForParent(Glue primary, Context<Glue> context) {
267
261
String finalizer = parentFinalizer (primary .getMetadata ().getName ());
268
262
if (p .getMetadata ().getFinalizers ().contains (finalizer )) {
269
263
var res = getResourceForSSAFrom (p );
270
- context .getClient ().resource (res )
271
- .patch (new PatchContext .Builder ()
272
- .withFieldManager (context .getControllerConfiguration ().fieldManager ())
273
- .withForce (true )
274
- .withPatchType (PatchType .SERVER_SIDE_APPLY )
275
- .build ());
264
+ patchResource (res , context );
276
265
}
277
266
}, () -> log .warn (
278
267
"Parent resource expected to be present on cleanup. Glue name: {} namespace: {}" ,
279
268
primary .getMetadata ().getName (), primary .getMetadata ().getNamespace ()));
280
269
}
281
270
271
+ private GenericKubernetesResource patchResource (GenericKubernetesResource res ,
272
+ Context <Glue > context ) {
273
+ return context .getClient ().resource (res )
274
+ .patch (new PatchContext .Builder ()
275
+ .withFieldManager (context .getControllerConfiguration ().fieldManager ())
276
+ .withForce (true )
277
+ .withPatchType (PatchType .SERVER_SIDE_APPLY )
278
+ .build ());
279
+ }
280
+
282
281
private Optional <GenericKubernetesResource > getParentRelatedResource (Glue primary ,
283
282
Context <Glue > context ) {
284
283
var parentRelated = primary .getSpec ().getRelatedResources ().stream ()
0 commit comments