Skip to content

Commit 40d18e2

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent c9ced8a commit 40d18e2

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/ResourceOperations.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public ResourceOperations(Context<P> context) {
6161
*/
6262
public <R extends HasMetadata> R serverSideApply(R resource) {
6363
return resourcePatch(
64-
context,
6564
resource,
6665
r ->
6766
context
@@ -92,7 +91,6 @@ public <R extends HasMetadata> R serverSideApply(R resource) {
9291
*/
9392
public <R extends HasMetadata> R serverSideApplyStatus(R resource) {
9493
return resourcePatch(
95-
context,
9694
resource,
9795
r ->
9896
context
@@ -184,7 +182,7 @@ public <P extends HasMetadata> P serverSideApplyPrimaryStatus(P resource) {
184182
* @param <R> resource type
185183
*/
186184
public <R extends HasMetadata> R update(R resource) {
187-
return resourcePatch(context, resource, r -> context.getClient().resource(r).update());
185+
return resourcePatch(resource, r -> context.getClient().resource(r).update());
188186
}
189187

190188
/**
@@ -203,7 +201,7 @@ public <R extends HasMetadata> R update(R resource) {
203201
* @param <R> resource type
204202
*/
205203
public <R extends HasMetadata> R updateStatus(R resource) {
206-
return resourcePatch(context, resource, r -> context.getClient().resource(r).updateStatus());
204+
return resourcePatch(resource, r -> context.getClient().resource(r).updateStatus());
207205
}
208206

209207
/**
@@ -268,8 +266,7 @@ public <R extends HasMetadata> R updatePrimaryStatus(R resource) {
268266
* @param <R> resource type
269267
*/
270268
public <R extends HasMetadata> R jsonPatch(R resource, UnaryOperator<R> unaryOperator) {
271-
return resourcePatch(
272-
context, resource, r -> context.getClient().resource(r).edit(unaryOperator));
269+
return resourcePatch(resource, r -> context.getClient().resource(r).edit(unaryOperator));
273270
}
274271

275272
/**
@@ -290,8 +287,7 @@ public <R extends HasMetadata> R jsonPatch(R resource, UnaryOperator<R> unaryOpe
290287
* @param <R> resource type
291288
*/
292289
public <R extends HasMetadata> R jsonPatchStatus(R resource, UnaryOperator<R> unaryOperator) {
293-
return resourcePatch(
294-
context, resource, r -> context.getClient().resource(r).editStatus(unaryOperator));
290+
return resourcePatch(resource, r -> context.getClient().resource(r).editStatus(unaryOperator));
295291
}
296292

297293
/**
@@ -358,7 +354,7 @@ public <R extends HasMetadata> R jsonPatchPrimaryStatus(
358354
* @param <R> resource type
359355
*/
360356
public <R extends HasMetadata> R jsonMergePatch(R resource) {
361-
return resourcePatch(context, resource, r -> context.getClient().resource(r).patch());
357+
return resourcePatch(resource, r -> context.getClient().resource(r).patch());
362358
}
363359

364360
/**
@@ -377,7 +373,7 @@ public <R extends HasMetadata> R jsonMergePatch(R resource) {
377373
* @param <R> resource type
378374
*/
379375
public <R extends HasMetadata> R jsonMergePatchStatus(R resource) {
380-
return resourcePatch(context, resource, r -> context.getClient().resource(r).patchStatus());
376+
return resourcePatch(resource, r -> context.getClient().resource(r).patchStatus());
381377
}
382378

383379
/**
@@ -431,15 +427,13 @@ public <R extends HasMetadata> R jsonMergePatchPrimaryStatus(R resource) {
431427
* source for the resource type and delegates to {@link #resourcePatch(HasMetadata, UnaryOperator,
432428
* ManagedInformerEventSource)}.
433429
*
434-
* @param context of reconciler
435430
* @param resource resource to patch
436431
* @param updateOperation operation to perform (update, patch, edit, etc.)
437432
* @return updated resource
438433
* @param <R> resource type
439434
* @throws IllegalStateException if no event source or multiple event sources are found
440435
*/
441-
public <R extends HasMetadata> R resourcePatch(
442-
Context<?> context, R resource, UnaryOperator<R> updateOperation) {
436+
public <R extends HasMetadata> R resourcePatch(R resource, UnaryOperator<R> updateOperation) {
443437

444438
var esList = context.eventSourceRetriever().getEventSourcesFor(resource.getClass());
445439
if (esList.isEmpty()) {

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/reconciler/ResourceOperationsTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void resourcePatchWithSingleEventSource() {
264264
when(managedEventSource.eventFilteringUpdateAndCacheResource(any(), any(UnaryOperator.class)))
265265
.thenReturn(updatedResource);
266266

267-
var result = resourceOperations.resourcePatch(context, resource, UnaryOperator.identity());
267+
var result = resourceOperations.resourcePatch(resource, UnaryOperator.identity());
268268

269269
assertThat(result).isNotNull();
270270
assertThat(result.getMetadata().getResourceVersion()).isEqualTo("2");
@@ -284,7 +284,7 @@ void resourcePatchThrowsWhenNoEventSourceFound() {
284284
var exception =
285285
assertThrows(
286286
IllegalStateException.class,
287-
() -> resourceOperations.resourcePatch(context, resource, UnaryOperator.identity()));
287+
() -> resourceOperations.resourcePatch(resource, UnaryOperator.identity()));
288288

289289
assertThat(exception.getMessage()).contains("No event source found for type");
290290
}
@@ -303,7 +303,7 @@ void resourcePatchThrowsWhenMultipleEventSourcesFound() {
303303
var exception =
304304
assertThrows(
305305
IllegalStateException.class,
306-
() -> resourceOperations.resourcePatch(context, resource, UnaryOperator.identity()));
306+
() -> resourceOperations.resourcePatch(resource, UnaryOperator.identity()));
307307

308308
assertThat(exception.getMessage()).contains("Multiple event sources found for");
309309
assertThat(exception.getMessage()).contains("please provide the target event source");
@@ -322,7 +322,7 @@ void resourcePatchThrowsWhenEventSourceIsNotManagedInformer() {
322322
var exception =
323323
assertThrows(
324324
IllegalStateException.class,
325-
() -> resourceOperations.resourcePatch(context, resource, UnaryOperator.identity()));
325+
() -> resourceOperations.resourcePatch(resource, UnaryOperator.identity()));
326326

327327
assertThat(exception.getMessage()).contains("Target event source must be a subclass off");
328328
assertThat(exception.getMessage()).contains("ManagedInformerEventSource");

0 commit comments

Comments
 (0)