Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9c1be9d

Browse files
committedOct 4, 2022
Optional eventsource on dependent resources (#1479)
1 parent bc13183 commit 9c1be9d

File tree

53 files changed

+941
-300
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+941
-300
lines changed
 

‎operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/AnnotationControllerConfiguration.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ public List<DependentResourceSpec> getDependentResources() {
247247
Set.of(dependent.dependsOn()),
248248
instantiateIfNotDefault(dependent.readyPostcondition(), Condition.class, context),
249249
instantiateIfNotDefault(dependent.reconcilePrecondition(), Condition.class, context),
250-
instantiateIfNotDefault(dependent.deletePostcondition(), Condition.class, context));
250+
instantiateIfNotDefault(dependent.deletePostcondition(), Condition.class, context),
251+
dependent.provideEventSource());
251252
specsMap.put(name, spec);
252253
}
253254

@@ -286,13 +287,13 @@ private Object createKubernetesResourceConfig(Class<? extends DependentResource>
286287
OnDeleteFilter<? extends HasMetadata> onDeleteFilter = null;
287288
GenericFilter<? extends HasMetadata> genericFilter = null;
288289
ResourceDiscriminator<?, ? extends HasMetadata> resourceDiscriminator = null;
290+
String eventSourceNameToUse = null;
289291
if (kubeDependent != null) {
290292
if (!Arrays.equals(KubernetesDependent.DEFAULT_NAMESPACES,
291293
kubeDependent.namespaces())) {
292294
namespaces = Set.of(kubeDependent.namespaces());
293295
configuredNS = true;
294296
}
295-
296297
final var fromAnnotation = kubeDependent.labelSelector();
297298
labelSelector = Constants.NO_VALUE_SET.equals(fromAnnotation) ? null : fromAnnotation;
298299

@@ -313,12 +314,14 @@ private Object createKubernetesResourceConfig(Class<? extends DependentResource>
313314
resourceDiscriminator =
314315
instantiateIfNotDefault(kubeDependent.resourceDiscriminator(),
315316
ResourceDiscriminator.class, context);
317+
eventSourceNameToUse = Constants.NO_VALUE_SET.equals(kubeDependent.eventSourceToUse()) ? null
318+
: kubeDependent.eventSourceToUse();
316319
}
317320

318321
config =
319322
new KubernetesDependentResourceConfig(namespaces, labelSelector, configuredNS,
320323
resourceDiscriminator, onAddFilter,
321-
onUpdateFilter, onDeleteFilter, genericFilter);
324+
onUpdateFilter, onDeleteFilter, genericFilter, eventSourceNameToUse);
322325

323326
return config;
324327
}

‎operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ControllerConfigurationOverrider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private void replaceConfig(String name, Object newConfig, DependentResourceSpec<
174174
namedDependentResourceSpecs.put(name,
175175
new DependentResourceSpec<>(current.getDependentResourceClass(), newConfig, name,
176176
current.getDependsOn(), current.getReadyCondition(), current.getReconcileCondition(),
177-
current.getDeletePostCondition()));
177+
current.getDeletePostCondition(), current.provideEventSource()));
178178
}
179179

180180
@SuppressWarnings("unchecked")
@@ -220,7 +220,7 @@ public ControllerConfiguration<R> build() {
220220
KubernetesDependentResourceConfig c) {
221221
return new DependentResourceSpec(spec.getDependentResourceClass(),
222222
c.setNamespaces(namespaces), name, spec.getDependsOn(), spec.getReadyCondition(),
223-
spec.getReconcileCondition(), spec.getDeletePostCondition());
223+
spec.getReconcileCondition(), spec.getDeletePostCondition(), spec.provideEventSource());
224224
}
225225

226226
public static <R extends HasMetadata> ControllerConfigurationOverrider<R> override(

0 commit comments

Comments
 (0)
Please sign in to comment.