Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import io.javaoperatorsdk.operator.processing.event.source.filter.OnDeleteFilter;
import io.javaoperatorsdk.operator.processing.event.source.filter.OnUpdateFilter;

import static io.javaoperatorsdk.operator.api.reconciler.Constants.DEFAULT_FOLLOW_CONTROLLER_NAMESPACES_ON_CHANGE;
import static io.javaoperatorsdk.operator.api.reconciler.Constants.DEFAULT_FOLLOW_CONTROLLER_NAMESPACE_CHANGES;
import static io.javaoperatorsdk.operator.api.reconciler.Constants.NO_LONG_VALUE_SET;
import static io.javaoperatorsdk.operator.api.reconciler.Constants.NO_VALUE_SET;

Expand Down Expand Up @@ -88,7 +88,7 @@
* Set that in case of a runtime controller namespace changes, the informer should also follow the
* new namespace set.
*/
boolean followControllerNamespacesOnChange() default DEFAULT_FOLLOW_CONTROLLER_NAMESPACES_ON_CHANGE;
boolean followControllerNamespaceChanges() default DEFAULT_FOLLOW_CONTROLLER_NAMESPACE_CHANGES;

/**
* Replaces the item store used by the informer for the associated primary resource controller.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class InformerConfiguration<R extends HasMetadata> {
private final String resourceTypeName;
private String name;
private Set<String> namespaces;
private Boolean followControllerNamespacesOnChange;
private Boolean followControllerNamespaceChanges;
private String labelSelector;
private OnAddFilter<? super R> onAddFilter;
private OnUpdateFilter<? super R> onUpdateFilter;
Expand All @@ -39,14 +39,14 @@ public class InformerConfiguration<R extends HasMetadata> {
private Long informerListLimit;

protected InformerConfiguration(Class<R> resourceClass, String name, Set<String> namespaces,
boolean followControllerNamespacesOnChange,
boolean followControllerNamespaceChanges,
String labelSelector, OnAddFilter<? super R> onAddFilter,
OnUpdateFilter<? super R> onUpdateFilter, OnDeleteFilter<? super R> onDeleteFilter,
GenericFilter<? super R> genericFilter, ItemStore<R> itemStore, Long informerListLimit) {
this(resourceClass);
this.name = name;
this.namespaces = namespaces;
this.followControllerNamespacesOnChange = followControllerNamespacesOnChange;
this.followControllerNamespaceChanges = followControllerNamespaceChanges;
this.labelSelector = labelSelector;
this.onAddFilter = onAddFilter;
this.onUpdateFilter = onUpdateFilter;
Expand Down Expand Up @@ -75,7 +75,7 @@ public static <R extends HasMetadata> InformerConfiguration<R>.Builder builder(
public static <R extends HasMetadata> InformerConfiguration<R>.Builder builder(
InformerConfiguration<R> original) {
return new InformerConfiguration(original.resourceClass, original.name, original.namespaces,
original.followControllerNamespacesOnChange, original.labelSelector, original.onAddFilter,
original.followControllerNamespaceChanges, original.labelSelector, original.onAddFilter,
original.onUpdateFilter, original.onDeleteFilter, original.genericFilter,
original.itemStore, original.informerListLimit).builder;
}
Expand Down Expand Up @@ -184,8 +184,8 @@ public Set<String> getEffectiveNamespaces(ControllerConfiguration<?> controllerC
*
* @return if namespace changes should be followed
*/
public boolean isFollowControllerNamespacesOnChange() {
return followControllerNamespacesOnChange;
public boolean getFollowControllerNamespaceChanges() {
return followControllerNamespaceChanges;
}

/**
Expand Down Expand Up @@ -258,7 +258,7 @@ public InformerConfiguration<R> buildForController() {
namespaces = Constants.DEFAULT_NAMESPACES_SET;
}
// to avoid potential NPE
followControllerNamespacesOnChange = false;
followControllerNamespaceChanges = false;
return InformerConfiguration.this;
}

Expand All @@ -267,9 +267,9 @@ public InformerConfiguration<R> build() {
if (namespaces == null || namespaces.isEmpty()) {
namespaces = Constants.SAME_AS_CONTROLLER_NAMESPACES_SET;
}
if (followControllerNamespacesOnChange == null) {
followControllerNamespacesOnChange =
DEFAULT_FOLLOW_CONTROLLER_NAMESPACES_ON_CHANGE;
if (followControllerNamespaceChanges == null) {
followControllerNamespaceChanges =
DEFAULT_FOLLOW_CONTROLLER_NAMESPACE_CHANGES;
}
return InformerConfiguration.this;
}
Expand Down Expand Up @@ -304,8 +304,8 @@ public InformerConfiguration<R>.Builder initFromAnnotation(Informer informerConf
GenericFilter.class,
context));

withFollowControllerNamespacesOnChange(
informerConfig.followControllerNamespacesOnChange());
withFollowControllerNamespacesChanges(
informerConfig.followControllerNamespaceChanges());

withItemStore(Utils.instantiate(informerConfig.itemStore(),
ItemStore.class, context));
Expand Down Expand Up @@ -344,7 +344,7 @@ public Set<String> namespaces() {
* @return the builder instance so that calls can be chained fluently
*/
public Builder withNamespaces(Set<String> namespaces, boolean followChanges) {
withNamespaces(namespaces).withFollowControllerNamespacesOnChange(followChanges);
withNamespaces(namespaces).withFollowControllerNamespacesChanges(followChanges);
return this;
}

Expand Down Expand Up @@ -372,8 +372,8 @@ public Builder withWatchCurrentNamespace() {
* controller's namespaces are reconfigured, {@code false} otherwise
* @return the builder instance so that calls can be chained fluently
*/
public Builder withFollowControllerNamespacesOnChange(boolean followChanges) {
InformerConfiguration.this.followControllerNamespacesOnChange =
public Builder withFollowControllerNamespacesChanges(boolean followChanges) {
InformerConfiguration.this.followControllerNamespaceChanges =
followChanges;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static Builder<GenericKubernetesResource> from(
* @return if namespace changes should be followed
*/
default boolean followControllerNamespaceChanges() {
return getInformerConfig().isFollowControllerNamespacesOnChange();
return getInformerConfig().getFollowControllerNamespaceChanges();
}

/**
Expand Down Expand Up @@ -194,8 +194,8 @@ public void updateFrom(InformerConfiguration<R> informerConfig) {
this.name = informerConfigName;
}
config.withNamespaces(informerConfig.getNamespaces())
.withFollowControllerNamespacesOnChange(
informerConfig.isFollowControllerNamespacesOnChange())
.withFollowControllerNamespacesChanges(
informerConfig.getFollowControllerNamespaceChanges())
.withLabelSelector(informerConfig.getLabelSelector())
.withItemStore(informerConfig.getItemStore())
.withOnAddFilter(informerConfig.getOnAddFilter())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class Constants {

public static final String RESOURCE_GVK_KEY = "josdk.resource.gvk";
public static final String CONTROLLER_NAME = "controller.name";
public static final boolean DEFAULT_FOLLOW_CONTROLLER_NAMESPACES_ON_CHANGE = true;
public static final boolean DEFAULT_FOLLOW_CONTROLLER_NAMESPACE_CHANGES = true;

private Constants() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ void currentNamespaceWatched() {

@Test
void nullLabelSelectorByDefault() {
final var informerConfig =
InformerConfiguration.builder(ConfigMap.class).build();
final var informerConfig = InformerConfiguration.builder(ConfigMap.class).build();
assertNull(informerConfig.getLabelSelector());
}

Expand All @@ -60,9 +59,8 @@ void shouldWatchAllNamespacesByDefaultForControllers() {

@Test
void shouldFollowControllerNamespacesByDefaultForInformerEventSource() {
final var informerConfig =
InformerConfiguration.builder(ConfigMap.class).build();
assertTrue(informerConfig.isFollowControllerNamespacesOnChange());
final var informerConfig = InformerConfiguration.builder(ConfigMap.class).build();
assertTrue(informerConfig.getFollowControllerNamespaceChanges());
}

@Test
Expand Down
Loading