From ae405d612239e273c60a8f691dfa7b0b73a594f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Tue, 21 May 2024 16:19:15 +0200 Subject: [PATCH] name in ES configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Attila Mészáros --- .../informer/InformerConfiguration.java | 23 +++++++++++++++++-- .../PerResourcePollingDependentResource.java | 3 ++- .../external/PollingDependentResource.java | 4 ++-- .../KubernetesDependentConverter.java | 7 ++++++ .../KubernetesDependentResource.java | 2 +- .../source/informer/InformerEventSource.java | 15 ++++-------- .../PerResourcePollingConfiguration.java | 7 ++++-- ...erResourcePollingConfigurationBuilder.java | 8 ++++++- .../PerResourcePollingEventSource.java | 9 +++----- .../source/polling/PollingConfiguration.java | 5 ++-- .../polling/PollingConfigurationBuilder.java | 8 ++++++- .../source/polling/PollingEventSource.java | 8 +++---- .../polling/PollingEventSourceTest.java | 2 +- .../ComplexDependentReconciler.java | 9 +++++--- ...ericEventSourceRegistrationReconciler.java | 6 +++-- ...dentSameTypeNoDiscriminatorReconciler.java | 3 ++- ...pleManagedDependentResourceReconciler.java | 3 ++- ...edExternalDependentResourceReconciler.java | 3 ++- ...PrimaryToSecondaryDependentReconciler.java | 3 ++- 19 files changed, 84 insertions(+), 44 deletions(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/informer/InformerConfiguration.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/informer/InformerConfiguration.java index e58a63266f..1cb2ed0267 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/informer/InformerConfiguration.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/informer/InformerConfiguration.java @@ -30,13 +30,16 @@ public interface InformerConfiguration class DefaultInformerConfiguration extends DefaultResourceConfiguration implements InformerConfiguration { + private final String name; private final PrimaryToSecondaryMapper primaryToSecondaryMapper; private final SecondaryToPrimaryMapper secondaryToPrimaryMapper; private final boolean followControllerNamespaceChanges; private final OnDeleteFilter onDeleteFilter; private final GroupVersionKind groupVersionKind; - protected DefaultInformerConfiguration(String labelSelector, + protected DefaultInformerConfiguration( + String name, + String labelSelector, Class resourceClass, GroupVersionKind groupVersionKind, PrimaryToSecondaryMapper primaryToSecondaryMapper, @@ -49,6 +52,7 @@ protected DefaultInformerConfiguration(String labelSelector, ItemStore itemStore, Long informerListLimit) { super(resourceClass, namespaces, labelSelector, onAddFilter, onUpdateFilter, genericFilter, itemStore, informerListLimit); + this.name = name; this.followControllerNamespaceChanges = followControllerNamespaceChanges; this.groupVersionKind = groupVersionKind; this.primaryToSecondaryMapper = primaryToSecondaryMapper; @@ -77,10 +81,16 @@ public

PrimaryToSecondaryMapper

getPrimaryToSecondary return (PrimaryToSecondaryMapper

) primaryToSecondaryMapper; } + @Override public Optional getGroupVersionKind() { return Optional.ofNullable(groupVersionKind); } + @Override + public String name() { + return name; + } + public boolean inheritsNamespacesFromController() { return InformerConfiguration.inheritsNamespacesFromController(getNamespaces()); } @@ -132,6 +142,8 @@ public Set getEffectiveNamespaces(ControllerConfiguration controllerC Optional getGroupVersionKind(); + String name(); + static boolean inheritsNamespacesFromController(Set namespaces) { return SAME_AS_CONTROLLER_NAMESPACES_SET.equals(namespaces); } @@ -142,6 +154,7 @@ class InformerConfigurationBuilder { private final Class resourceClass; private final GroupVersionKind groupVersionKind; private final Class primaryResourceClass; + private String name; private PrimaryToSecondaryMapper primaryToSecondaryMapper; private SecondaryToPrimaryMapper secondaryToPrimaryMapper; private Set namespaces = SAME_AS_CONTROLLER_NAMESPACES_SET; @@ -173,6 +186,11 @@ private InformerConfigurationBuilder(Class resourceClass, this.primaryResourceClass = primaryResourceClass; } + public InformerConfigurationBuilder withName(String name) { + this.name = name; + return this; + } + public

InformerConfigurationBuilder withPrimaryToSecondaryMapper( PrimaryToSecondaryMapper

primaryToSecondaryMapper) { this.primaryToSecondaryMapper = primaryToSecondaryMapper; @@ -288,7 +306,8 @@ public InformerConfigurationBuilder withInformerListLimit(Long informerListLi public InformerConfiguration build() { Objects.requireNonNull(secondaryToPrimaryMapper, "SecondaryToPrimaryMapper must not be null"); - return new DefaultInformerConfiguration<>(labelSelector, resourceClass, groupVersionKind, + return new DefaultInformerConfiguration<>(name, labelSelector, resourceClass, + groupVersionKind, primaryToSecondaryMapper, Objects.requireNonNullElse(secondaryToPrimaryMapper, Mappers.fromOwnerReferences(HasMetadata.getApiVersion(primaryResourceClass), diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/external/PerResourcePollingDependentResource.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/external/PerResourcePollingDependentResource.java index 581698ffd6..f315619cde 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/external/PerResourcePollingDependentResource.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/external/PerResourcePollingDependentResource.java @@ -27,10 +27,11 @@ public PerResourcePollingDependentResource(Class resourceType, Duration polli protected ExternalResourceCachingEventSource createEventSource( EventSourceContext

context) { - return new PerResourcePollingEventSource<>(name(), resourceType(), context, + return new PerResourcePollingEventSource<>(resourceType(), context, new PerResourcePollingConfigurationBuilder<>( this, getPollingPeriod()) .withCacheKeyMapper(this) + .withName(name()) .build()); } } diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/external/PollingDependentResource.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/external/PollingDependentResource.java index 519771d82d..01860cb4c5 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/external/PollingDependentResource.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/external/PollingDependentResource.java @@ -31,8 +31,8 @@ public PollingDependentResource(Class resourceType, Duration pollingPeriod, @Override protected ExternalResourceCachingEventSource createEventSource( EventSourceContext

context) { - return new PollingEventSource<>(name(), resourceType(), - new PollingConfiguration<>(this, getPollingPeriod(), cacheKeyMapper)); + return new PollingEventSource<>(resourceType(), + new PollingConfiguration<>(name(), this, getPollingPeriod(), cacheKeyMapper)); } } diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentConverter.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentConverter.java index 7509bf8626..86d94a0424 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentConverter.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentConverter.java @@ -47,6 +47,7 @@ public KubernetesDependentResourceConfig configFrom(KubernetesDependent confi } + @SuppressWarnings("unchecked") private InformerConfiguration createInformerConfiguration(KubernetesDependent configAnnotation, ControllerConfiguration controllerConfig, Class> originatingClass) { @@ -61,6 +62,12 @@ private InformerConfiguration createInformerConfiguration(KubernetesDependent if (configAnnotation != null) { + if (Constants.NO_VALUE_SET.equals(configAnnotation.informerConfig().name())) { + informerConfig.withName(dependentInstance.name()); + } else { + informerConfig.withName(configAnnotation.informerConfig().name()); + } + var namespaces = Set.of(configAnnotation.informerConfig().namespaces()); informerConfig.withNamespaces(namespaces); diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java index fe8b69dff6..b5b0701314 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java @@ -234,7 +234,7 @@ protected InformerEventSource createEventSource(EventSourceContext

cont .withSecondaryToPrimaryMapper(getSecondaryToPrimaryMapper().orElseThrow()) .build(); } - var es = new InformerEventSource<>(name(), config, context); + var es = new InformerEventSource<>(config, context); setEventSource(es); return eventSource().orElseThrow(); } diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSource.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSource.java index 571e02dbc2..67e5500b24 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSource.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSource.java @@ -76,28 +76,21 @@ public class InformerEventSource private final PrimaryToSecondaryMapper

primaryToSecondaryMapper; private final String id = UUID.randomUUID().toString(); - public InformerEventSource(String name, - InformerConfiguration configuration, EventSourceContext

context) { - this(name, configuration, context.getClient(), - context.getControllerConfiguration().getConfigurationService() - .parseResourceVersionsForEventFilteringAndCaching()); - } - public InformerEventSource( InformerConfiguration configuration, EventSourceContext

context) { - this(null, configuration, context.getClient(), + this(configuration, context.getClient(), context.getControllerConfiguration().getConfigurationService() .parseResourceVersionsForEventFilteringAndCaching()); } public InformerEventSource(InformerConfiguration configuration, KubernetesClient client) { - this(null, configuration, client, false); + this(configuration, client, false); } - public InformerEventSource(String name, InformerConfiguration configuration, + public InformerEventSource(InformerConfiguration configuration, KubernetesClient client, boolean parseResourceVersions) { - super(name, + super(configuration.name(), configuration.getGroupVersionKind() .map(gvk -> client.genericKubernetesResources(gvk.apiVersion(), gvk.getKind())) .orElseGet(() -> (MixedOperation) client.resources(configuration.getResourceClass())), diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingConfiguration.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingConfiguration.java index 23fa9e023a..52e1fbcd68 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingConfiguration.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingConfiguration.java @@ -9,17 +9,20 @@ import io.fabric8.kubernetes.api.model.HasMetadata; import io.javaoperatorsdk.operator.processing.event.source.CacheKeyMapper; -public record PerResourcePollingConfiguration(ScheduledExecutorService executorService, CacheKeyMapper cacheKeyMapper, +public record PerResourcePollingConfiguration(String name,ScheduledExecutorService executorService, CacheKeyMapper cacheKeyMapper, PerResourcePollingEventSource.ResourceFetcher resourceFetcher, Predicate

registerPredicate, Duration defaultPollingPeriod) { public static final int DEFAULT_EXECUTOR_THREAD_NUMBER = 1; - public PerResourcePollingConfiguration(ScheduledExecutorService executorService, + public PerResourcePollingConfiguration( + String name, + ScheduledExecutorService executorService, CacheKeyMapper cacheKeyMapper, PerResourcePollingEventSource.ResourceFetcher resourceFetcher, Predicate

registerPredicate, Duration defaultPollingPeriod) { + this.name = name; this.executorService = executorService == null ? new ScheduledThreadPoolExecutor(DEFAULT_EXECUTOR_THREAD_NUMBER) : executorService; this.cacheKeyMapper = cacheKeyMapper == null ? CacheKeyMapper.singleResourceCacheKeyMapper() : cacheKeyMapper; diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingConfigurationBuilder.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingConfigurationBuilder.java index ece10d347e..85b1fcf2b0 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingConfigurationBuilder.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingConfigurationBuilder.java @@ -12,6 +12,7 @@ public final class PerResourcePollingConfigurationBuilder resourceFetcher; + private String name; private Predicate

registerPredicate; private ScheduledExecutorService executorService; private CacheKeyMapper cacheKeyMapper; @@ -42,8 +43,13 @@ public PerResourcePollingConfigurationBuilder withCacheKeyMapper( return this; } + public PerResourcePollingConfigurationBuilder withName(String name) { + this.name = name; + return this; + } + public PerResourcePollingConfiguration build() { - return new PerResourcePollingConfiguration<>(executorService, cacheKeyMapper, + return new PerResourcePollingConfiguration<>(name, executorService, cacheKeyMapper, resourceFetcher, registerPredicate, defaultPollingPeriod); } } diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingEventSource.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingEventSource.java index 2288e7eb75..983679a27a 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingEventSource.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingEventSource.java @@ -50,15 +50,12 @@ public class PerResourcePollingEventSource private final Predicate

registerPredicate; private final Duration period; - public PerResourcePollingEventSource(Class resourceClass, EventSourceContext

context, - PerResourcePollingConfiguration config) { - this(null, resourceClass, context, config); - } - public PerResourcePollingEventSource(String name, Class resourceClass, + + public PerResourcePollingEventSource(Class resourceClass, EventSourceContext

context, PerResourcePollingConfiguration config) { - super(name, resourceClass, config.cacheKeyMapper()); + super(config.name(), resourceClass, config.cacheKeyMapper()); this.primaryResourceCache = context.getPrimaryCache(); this.resourceFetcher = config.resourceFetcher(); this.registerPredicate = config.registerPredicate(); diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingConfiguration.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingConfiguration.java index 516d0546f7..c66ef38c8f 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingConfiguration.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingConfiguration.java @@ -5,11 +5,12 @@ import io.javaoperatorsdk.operator.processing.event.source.CacheKeyMapper; -public record PollingConfiguration(PollingEventSource.GenericResourceFetcher genericResourceFetcher, +public record PollingConfiguration(String name,PollingEventSource.GenericResourceFetcher genericResourceFetcher, Duration period, CacheKeyMapper cacheKeyMapper) { - public PollingConfiguration(PollingEventSource.GenericResourceFetcher genericResourceFetcher, Duration period, + public PollingConfiguration(String name,PollingEventSource.GenericResourceFetcher genericResourceFetcher, Duration period, CacheKeyMapper cacheKeyMapper) { + this.name = name; this.genericResourceFetcher = Objects.requireNonNull(genericResourceFetcher); this.period = period; this.cacheKeyMapper = diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingConfigurationBuilder.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingConfigurationBuilder.java index 576f8fdb56..c6bccefa82 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingConfigurationBuilder.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingConfigurationBuilder.java @@ -8,6 +8,7 @@ public final class PollingConfigurationBuilder { private final Duration period; private final PollingEventSource.GenericResourceFetcher genericResourceFetcher; private CacheKeyMapper cacheKeyMapper; + private String name; public PollingConfigurationBuilder(PollingEventSource.GenericResourceFetcher fetcher, Duration period) { @@ -20,7 +21,12 @@ public PollingConfigurationBuilder withCacheKeyMapper(CacheKeyMapper cache return this; } + public PollingConfigurationBuilder withName(String name) { + this.name = name; + return this; + } + public PollingConfiguration build() { - return new PollingConfiguration<>(genericResourceFetcher, period, cacheKeyMapper); + return new PollingConfiguration<>(name, genericResourceFetcher, period, cacheKeyMapper); } } diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingEventSource.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingEventSource.java index 060128576c..6549030c4b 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingEventSource.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingEventSource.java @@ -52,12 +52,10 @@ public class PollingEventSource private final Duration period; private final AtomicBoolean healthy = new AtomicBoolean(true); - public PollingEventSource(Class resourceClass, PollingConfiguration config) { - this(null, resourceClass, config); - } - public PollingEventSource(String name, Class resourceClass, PollingConfiguration config) { - super(name, resourceClass, config.cacheKeyMapper()); + + public PollingEventSource(Class resourceClass, PollingConfiguration config) { + super(config.name(), resourceClass, config.cacheKeyMapper()); this.genericResourceFetcher = config.genericResourceFetcher(); this.period = config.period(); } diff --git a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingEventSourceTest.java b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingEventSourceTest.java index 5dffa65ae7..ced96e9b7d 100644 --- a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingEventSourceTest.java +++ b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/polling/PollingEventSourceTest.java @@ -32,7 +32,7 @@ class PollingEventSourceTest mock(PollingEventSource.GenericResourceFetcher.class); private final PollingEventSource pollingEventSource = new PollingEventSource<>(SampleExternalResource.class, - new PollingConfiguration<>(resourceFetcher, POLL_PERIOD, + new PollingConfiguration<>(null, resourceFetcher, POLL_PERIOD, (SampleExternalResource er) -> er.getName() + "#" + er.getValue())); @BeforeEach diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/complexdependent/ComplexDependentReconciler.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/complexdependent/ComplexDependentReconciler.java index a974ffcfa3..1937a4783e 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/complexdependent/ComplexDependentReconciler.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/complexdependent/ComplexDependentReconciler.java @@ -54,12 +54,15 @@ public UpdateControl reconcile( public List prepareEventSources( EventSourceContext context) { InformerEventSource serviceEventSource = - new InformerEventSource<>(SERVICE_EVENT_SOURCE_NAME, - InformerConfiguration.from(Service.class, ComplexDependentCustomResource.class).build(), + new InformerEventSource<>( + InformerConfiguration.from(Service.class, ComplexDependentCustomResource.class) + .withName(SERVICE_EVENT_SOURCE_NAME) + .build(), context); InformerEventSource statefulSetEventSource = - new InformerEventSource<>(STATEFUL_SET_EVENT_SOURCE_NAME, + new InformerEventSource<>( InformerConfiguration.from(StatefulSet.class, ComplexDependentCustomResource.class) + .withName(STATEFUL_SET_EVENT_SOURCE_NAME) .build(), context); return List.of(serviceEventSource, statefulSetEventSource); diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/dynamicgenericeventsourceregistration/DynamicGenericEventSourceRegistrationReconciler.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/dynamicgenericeventsourceregistration/DynamicGenericEventSourceRegistrationReconciler.java index f9581da8ce..13fc3f7e4c 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/dynamicgenericeventsourceregistration/DynamicGenericEventSourceRegistrationReconciler.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/dynamicgenericeventsourceregistration/DynamicGenericEventSourceRegistrationReconciler.java @@ -74,9 +74,11 @@ private InformerEventSource clazz, Context context) { - return new InformerEventSource<>(clazz.getSimpleName(), + return new InformerEventSource<>( InformerConfiguration - .from(gvkFor(clazz), DynamicGenericEventSourceRegistrationCustomResource.class).build(), + .from(gvkFor(clazz), DynamicGenericEventSourceRegistrationCustomResource.class) + .withName(clazz.getSimpleName()) + .build(), context.eventSourceRetriever().eventSourceContextForDynamicRegistration()); } diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/multipledrsametypenodiscriminator/MultipleManagedDependentSameTypeNoDiscriminatorReconciler.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/multipledrsametypenodiscriminator/MultipleManagedDependentSameTypeNoDiscriminatorReconciler.java index fe4ccf19cf..feec6dc727 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/multipledrsametypenodiscriminator/MultipleManagedDependentSameTypeNoDiscriminatorReconciler.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/multipledrsametypenodiscriminator/MultipleManagedDependentSameTypeNoDiscriminatorReconciler.java @@ -49,9 +49,10 @@ public int getNumberOfExecutions() { public List prepareEventSources( EventSourceContext context) { InformerEventSource ies = - new InformerEventSource<>(CONFIG_MAP_EVENT_SOURCE, + new InformerEventSource<>( InformerConfiguration.from(ConfigMap.class, MultipleManagedDependentNoDiscriminatorCustomResource.class) + .withName(CONFIG_MAP_EVENT_SOURCE) .build(), context); diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/multiplemanageddependentsametype/MultipleManagedDependentResourceReconciler.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/multiplemanageddependentsametype/MultipleManagedDependentResourceReconciler.java index 6adea63f05..53917dd593 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/multiplemanageddependentsametype/MultipleManagedDependentResourceReconciler.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/multiplemanageddependentsametype/MultipleManagedDependentResourceReconciler.java @@ -49,9 +49,10 @@ public int getNumberOfExecutions() { public List prepareEventSources( EventSourceContext context) { InformerEventSource ies = - new InformerEventSource<>(CONFIG_MAP_EVENT_SOURCE, + new InformerEventSource<>( InformerConfiguration .from(ConfigMap.class, MultipleManagedDependentResourceCustomResource.class) + .withName(CONFIG_MAP_EVENT_SOURCE) .build(), context); return List.of(ies); diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/multiplemanagedexternaldependenttype/MultipleManagedExternalDependentResourceReconciler.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/multiplemanagedexternaldependenttype/MultipleManagedExternalDependentResourceReconciler.java index 614f3a0b59..786e1c82d6 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/multiplemanagedexternaldependenttype/MultipleManagedExternalDependentResourceReconciler.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/multiplemanagedexternaldependenttype/MultipleManagedExternalDependentResourceReconciler.java @@ -71,8 +71,9 @@ public List prepareEventSources( }; PollingEventSource pollingEventSource = - new PollingEventSource<>(EVENT_SOURCE_NAME, ExternalResource.class, + new PollingEventSource<>(ExternalResource.class, new PollingConfigurationBuilder<>(fetcher, Duration.ofMillis(1000L)) + .withName(EVENT_SOURCE_NAME) .withCacheKeyMapper(ExternalResource::getId) .build()); diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/PrimaryToSecondaryDependentReconciler.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/PrimaryToSecondaryDependentReconciler.java index 52f18ace29..2b48ee0d2a 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/PrimaryToSecondaryDependentReconciler.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/PrimaryToSecondaryDependentReconciler.java @@ -66,8 +66,9 @@ public List prepareEventSources( context.getPrimaryCache().addIndexer(CONFIG_MAP_INDEX, (primary -> List .of(indexKey(primary.getSpec().getConfigMapName(), primary.getMetadata().getNamespace())))); - var es = new InformerEventSource<>(CONFIG_MAP_EVENT_SOURCE, InformerConfiguration + var es = new InformerEventSource<>(InformerConfiguration .from(ConfigMap.class, PrimaryToSecondaryDependentCustomResource.class) + .withName(CONFIG_MAP_EVENT_SOURCE) // if there is a many-to-many relationship (thus no direct owner reference) // PrimaryToSecondaryMapper needs to be added .withPrimaryToSecondaryMapper(