Skip to content

Commit 3d07b2e

Browse files
committed
docs
1 parent 50a50b9 commit 3d07b2e

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/AbstractDependentResource.java

+2-10
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ private void adjustDiscriminators(int count) {
8282
}
8383

8484
protected ReconcileResult<R> reconcileIndexAware(P primary, int i, Context<P> context) {
85-
Optional<R> maybeActual = getSecondaryResourceIndexAware(primary, i, context);
85+
Optional<R> maybeActual = bulk ? getSecondaryResourceIndexAware(primary, i, context)
86+
: getSecondaryResource(primary, context);
8687
if (creatable || updatable) {
8788
if (maybeActual.isEmpty()) {
8889
if (creatable) {
@@ -126,7 +127,6 @@ private R desiredIndexAware(P primary, int i, Context<P> context) {
126127
: desired(primary, context);
127128
}
128129

129-
// todo check
130130
protected Optional<R> getSecondaryResource(P primary, Context<P> context) {
131131
if (resourceDiscriminator.isEmpty()) {
132132
return context.getSecondaryResource(resourceType());
@@ -136,14 +136,6 @@ protected Optional<R> getSecondaryResource(P primary, Context<P> context) {
136136
}
137137

138138
protected Optional<R> getSecondaryResourceIndexAware(P primary, int index, Context<P> context) {
139-
if (index > 0 && resourceDiscriminator.isEmpty()) {
140-
throw new IllegalStateException(
141-
"Handling resources in bulk bot no resource discriminators set.");
142-
}
143-
if (!bulk) {
144-
return getSecondaryResource(primary, context);
145-
}
146-
147139
return context.getSecondaryResource(resourceType(), resourceDiscriminator.get(index));
148140
}
149141

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/BulkUpdater.java

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
import io.fabric8.kubernetes.api.model.HasMetadata;
44
import io.javaoperatorsdk.operator.api.reconciler.Context;
55

6+
/**
7+
* Helper for the Bulk Dependent Resources to make it more explicit that bulk needs to only
8+
* implement the index aware match method.
9+
*
10+
* @param <R> secondary resource type
11+
* @param <P> primary resource type
12+
*/
613
public interface BulkUpdater<R, P extends HasMetadata> extends Updater<R, P> {
714

815
default Matcher.Result<R> match(R actualResource, P primary, Context<P> context) {

0 commit comments

Comments
 (0)