-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move controller informer-related configuration to InformerConfig (
#2455) * feat: move controller informer-related configuration to InformerConfig Signed-off-by: Chris Laprun <[email protected]> * refactor: start isolating ResourceConfiguration Signed-off-by: Chris Laprun <[email protected]> * fix: initFromAnnotation now properly inits the current instance Signed-off-by: Chris Laprun <[email protected]> * fix: default onDeleteFilter implementation Signed-off-by: Chris Laprun <[email protected]> * fix: properly set default namespaces in controller case Signed-off-by: Chris Laprun <[email protected]> * refactor: remove KubernetesDependentInformerConfigBuilder Signed-off-by: Chris Laprun <[email protected]> * refactor: use InformerConfigHolder in more places, unifying handling Signed-off-by: Chris Laprun <[email protected]> * fix: properly propagate name to informer config Signed-off-by: Chris Laprun <[email protected]> * feat: add factory method to init builder from an extising configuation Signed-off-by: Chris Laprun <[email protected]> * fix: remove potentially problematic default implementation Signed-off-by: Chris Laprun <[email protected]> --------- Signed-off-by: Chris Laprun <[email protected]>
- Loading branch information
Showing
42 changed files
with
710 additions
and
867 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 6 additions & 57 deletions
63
...re/src/main/java/io/javaoperatorsdk/operator/api/config/DefaultResourceConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,41 @@ | ||
package io.javaoperatorsdk.operator.api.config; | ||
|
||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
import io.fabric8.kubernetes.api.model.GenericKubernetesResource; | ||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.fabric8.kubernetes.client.informers.cache.ItemStore; | ||
import io.javaoperatorsdk.operator.ReconcilerUtils; | ||
import io.javaoperatorsdk.operator.processing.event.source.filter.GenericFilter; | ||
import io.javaoperatorsdk.operator.processing.event.source.filter.OnAddFilter; | ||
import io.javaoperatorsdk.operator.processing.event.source.filter.OnUpdateFilter; | ||
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.InformerConfigHolder; | ||
|
||
public class DefaultResourceConfiguration<R extends HasMetadata> | ||
implements ResourceConfiguration<R> { | ||
|
||
private final Class<R> resourceClass; | ||
private final String resourceTypeName; | ||
private final OnAddFilter<? super R> onAddFilter; | ||
private final OnUpdateFilter<? super R> onUpdateFilter; | ||
private final GenericFilter<? super R> genericFilter; | ||
private final String labelSelector; | ||
private final Set<String> namespaces; | ||
private final ItemStore<R> itemStore; | ||
private final Long informerListLimit; | ||
private final InformerConfigHolder<R> informerConfig; | ||
|
||
protected DefaultResourceConfiguration(Class<R> resourceClass, | ||
Set<String> namespaces, String labelSelector, OnAddFilter<? super R> onAddFilter, | ||
OnUpdateFilter<? super R> onUpdateFilter, GenericFilter<? super R> genericFilter, | ||
ItemStore<R> itemStore, Long informerListLimit) { | ||
InformerConfigHolder<R> informerConfig) { | ||
this.resourceClass = resourceClass; | ||
this.resourceTypeName = resourceClass.isAssignableFrom(GenericKubernetesResource.class) | ||
// in general this is irrelevant now for secondary resources it is used just by controller | ||
// where GenericKubernetesResource now does not apply | ||
? GenericKubernetesResource.class.getSimpleName() | ||
: ReconcilerUtils.getResourceTypeName(resourceClass); | ||
this.onAddFilter = onAddFilter; | ||
this.onUpdateFilter = onUpdateFilter; | ||
this.genericFilter = genericFilter; | ||
|
||
this.namespaces = ResourceConfiguration.ensureValidNamespaces(namespaces); | ||
this.labelSelector = ResourceConfiguration.ensureValidLabelSelector(labelSelector); | ||
this.itemStore = itemStore; | ||
this.informerListLimit = informerListLimit; | ||
this.informerConfig = informerConfig; | ||
} | ||
|
||
@Override | ||
public String getResourceTypeName() { | ||
return resourceTypeName; | ||
} | ||
|
||
@Override | ||
public String getLabelSelector() { | ||
return labelSelector; | ||
} | ||
|
||
@Override | ||
public Set<String> getNamespaces() { | ||
return namespaces; | ||
} | ||
|
||
@Override | ||
public Class<R> getResourceClass() { | ||
return resourceClass; | ||
} | ||
|
||
@Override | ||
public Optional<OnAddFilter<? super R>> onAddFilter() { | ||
return Optional.ofNullable(onAddFilter); | ||
} | ||
|
||
@Override | ||
public Optional<OnUpdateFilter<? super R>> onUpdateFilter() { | ||
return Optional.ofNullable(onUpdateFilter); | ||
public InformerConfigHolder<R> getInformerConfig() { | ||
return informerConfig; | ||
} | ||
|
||
@Override | ||
public Optional<GenericFilter<? super R>> genericFilter() { | ||
return Optional.ofNullable(genericFilter); | ||
} | ||
|
||
@Override | ||
public Optional<ItemStore<R>> getItemStore() { | ||
return Optional.ofNullable(itemStore); | ||
} | ||
|
||
@Override | ||
public Optional<Long> getInformerListLimit() { | ||
return Optional.ofNullable(informerListLimit); | ||
} | ||
|
||
} |
Oops, something went wrong.