@@ -84,7 +84,7 @@ private PostExecutionControl<P> handleDispatch(ExecutionScope<P> executionScope)
84
84
Context <P > context =
85
85
new DefaultContext <>(executionScope .getRetryInfo (), controller , originalResource );
86
86
if (markedForDeletion ) {
87
- return handleCleanup (originalResource , resourceForExecution , context );
87
+ return handleCleanup (resourceForExecution , context );
88
88
} else {
89
89
return handleReconcile (executionScope , resourceForExecution , originalResource , context );
90
90
}
@@ -140,30 +140,31 @@ private PostExecutionControl<P> reconcileExecution(ExecutionScope<P> executionSc
140
140
P updatedCustomResource = null ;
141
141
if (updateControl .isUpdateResourceAndStatus ()) {
142
142
updatedCustomResource =
143
- updateCustomResource (updateControl .getResource ());
143
+ updateCustomResource (updateControl .getResource (), updateControl . isPatchResource () );
144
144
updateControl
145
145
.getResource ()
146
146
.getMetadata ()
147
147
.setResourceVersion (updatedCustomResource .getMetadata ().getResourceVersion ());
148
148
updatedCustomResource =
149
149
updateStatusGenerationAware (updateControl .getResource (), originalResource ,
150
- updateControl .isPatch ());
150
+ updateControl .isPatchStatus ());
151
151
} else if (updateControl .isUpdateStatus ()) {
152
152
updatedCustomResource =
153
153
updateStatusGenerationAware (updateControl .getResource (), originalResource ,
154
- updateControl .isPatch ());
154
+ updateControl .isPatchStatus ());
155
155
} else if (updateControl .isUpdateResource ()) {
156
156
updatedCustomResource =
157
- updateCustomResource (updateControl .getResource ());
157
+ updateCustomResource (updateControl .getResource (), updateControl . isPatchResource () );
158
158
if (shouldUpdateObservedGenerationAutomatically (updatedCustomResource )) {
159
159
updatedCustomResource =
160
160
updateStatusGenerationAware (updateControl .getResource (), originalResource ,
161
- updateControl .isPatch ());
161
+ updateControl .isPatchStatus ());
162
162
}
163
163
} else if (updateControl .isNoUpdate ()
164
164
&& shouldUpdateObservedGenerationAutomatically (resourceForExecution )) {
165
165
updatedCustomResource =
166
- updateStatusGenerationAware (originalResource , originalResource , updateControl .isPatch ());
166
+ updateStatusGenerationAware (originalResource , originalResource ,
167
+ updateControl .isPatchStatus ());
167
168
}
168
169
return createPostExecutionControl (updatedCustomResource , updateControl );
169
170
}
@@ -202,7 +203,8 @@ public boolean isLastAttempt() {
202
203
if (updatedResource != null ) {
203
204
return errorStatusUpdateControl .isPatch ()
204
205
? PostExecutionControl .customResourceStatusPatched (updatedResource )
205
- : PostExecutionControl .customResourceUpdated (updatedResource );
206
+ // todo review if this is ok
207
+ : PostExecutionControl .customResourceUpdated (updatedResource , false );
206
208
} else {
207
209
return PostExecutionControl .defaultDispatch ();
208
210
}
@@ -259,11 +261,12 @@ private PostExecutionControl<P> createPostExecutionControl(P updatedCustomResour
259
261
UpdateControl <P > updateControl ) {
260
262
PostExecutionControl <P > postExecutionControl ;
261
263
if (updatedCustomResource != null ) {
262
- if (updateControl .isUpdateStatus () && updateControl .isPatch ()) {
264
+ if (updateControl .isUpdateStatus () && updateControl .isPatchStatus ()) {
263
265
postExecutionControl =
264
266
PostExecutionControl .customResourceStatusPatched (updatedCustomResource );
265
267
} else {
266
- postExecutionControl = PostExecutionControl .customResourceUpdated (updatedCustomResource );
268
+ postExecutionControl = PostExecutionControl .customResourceUpdated (updatedCustomResource ,
269
+ updateControl .isPatchResource ());
267
270
}
268
271
} else {
269
272
postExecutionControl = PostExecutionControl .defaultDispatch ();
@@ -279,7 +282,7 @@ private void updatePostExecutionControlWithReschedule(
279
282
}
280
283
281
284
282
- private PostExecutionControl <P > handleCleanup (P originalResource , P resource ,
285
+ private PostExecutionControl <P > handleCleanup (P resource ,
283
286
Context <P > context ) {
284
287
log .debug (
285
288
"Executing delete for resource: {} with version: {}" ,
@@ -316,10 +319,13 @@ private P updateCustomResourceWithFinalizer(P resourceForExecution, P originalRe
316
319
r -> r .addFinalizer (configuration ().getFinalizerName ()));
317
320
}
318
321
319
- private P updateCustomResource (P resource ) {
320
- log .debug ("Updating resource: {} with version: {}" , getUID (resource ), getVersion (resource ));
322
+ private P updateCustomResource (P resource , boolean isPatch ) {
323
+ log .debug ("Updating resource: {} with version: {} patch: {}" , getUID (resource ),
324
+ getVersion (resource ), isPatch );
321
325
log .trace ("Resource before update: {}" , resource );
322
- return customResourceFacade .updateResource (resource );
326
+
327
+ return isPatch ? customResourceFacade .patchResource (resource )
328
+ : customResourceFacade .updateResource (resource );
323
329
}
324
330
325
331
ControllerConfiguration <P > configuration () {
@@ -375,6 +381,11 @@ public R getResource(String namespace, String name) {
375
381
}
376
382
}
377
383
384
+ public R patchResource (R resource ) {
385
+ // todo
386
+ return null ;
387
+ }
388
+
378
389
public R updateResource (R resource ) {
379
390
log .debug (
380
391
"Trying to replace resource {}, version: {}" ,
0 commit comments