Skip to content

Commit c4ed450

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

2 files changed

Lines changed: 7 additions & 24 deletions

File tree

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -747,11 +747,8 @@ public <R extends HasMetadata> R resourcePatch(
747747
UnaryOperator<R> updateOperation,
748748
ManagedInformerEventSource<R, P, ?> ies,
749749
Options options) {
750-
R originalResource = null;
751-
if (options.getMatcher().isPresent()) {
752-
originalResource = ies.get(ResourceID.fromResource(desired)).orElse(null);
753-
}
754-
return resourcePatch(desired, originalResource, updateOperation, ies, options);
750+
751+
return resourcePatch(desired, null, updateOperation, ies, options);
755752
}
756753

757754
public <R extends HasMetadata> R resourcePatch(
@@ -765,9 +762,12 @@ public <R extends HasMetadata> R resourcePatch(
765762
boolean matches = false;
766763
if (matcher != null) {
767764
if (actualResource == null) {
768-
throw new IllegalArgumentException("Actual most be present for matching update/patch.");
765+
actualResource = ies.get(ResourceID.fromResource(desiredResource)).orElse(null);
766+
}
767+
// todo describe might require optimistic locking
768+
if (actualResource != null) {
769+
matches = matcher.matches(desiredResource, actualResource, context);
769770
}
770-
matches = matcher.matches(desiredResource, actualResource, context);
771771
}
772772
if (options.requiresMatcher() && matcher == null) {
773773
throw new IllegalArgumentException("Mode : " + options.mode + " requires matcher");

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -384,23 +384,6 @@ void matcherNotMatchingProceedsToEventFilteringUpdate() {
384384
.eventFilteringUpdateAndCacheResource(eq(desired), any(UnaryOperator.class));
385385
}
386386

387-
@Test
388-
void matcherRequiresActualToBePresent() {
389-
var desired = TestUtils.testCustomResource1();
390-
var ies = mock(ManagedInformerEventSource.class);
391-
var matcher = mock(Matcher.class);
392-
393-
assertThrows(
394-
IllegalArgumentException.class,
395-
() ->
396-
resourceOperations.resourcePatch(
397-
desired,
398-
null,
399-
UnaryOperator.identity(),
400-
ies,
401-
ResourceOperations.Options.matchAndFilter(matcher)));
402-
}
403-
404387
@Test
405388
void onlyCacheModeSkipsEventFiltering() {
406389
var desired = TestUtils.testCustomResource1();

0 commit comments

Comments
 (0)