Skip to content

Commit af5feff

Browse files
csvirimetacosm
andauthored
improve: follow namespace changes method naming (#2672)
Signed-off-by: Attila Mészáros <[email protected]> Signed-off-by: Chris Laprun <[email protected]> Co-authored-by: Chris Laprun <[email protected]>
1 parent b25a399 commit af5feff

File tree

5 files changed

+24
-26
lines changed

5 files changed

+24
-26
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/informer/Informer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import io.javaoperatorsdk.operator.processing.event.source.filter.OnDeleteFilter;
1414
import io.javaoperatorsdk.operator.processing.event.source.filter.OnUpdateFilter;
1515

16-
import static io.javaoperatorsdk.operator.api.reconciler.Constants.DEFAULT_FOLLOW_CONTROLLER_NAMESPACES_ON_CHANGE;
16+
import static io.javaoperatorsdk.operator.api.reconciler.Constants.DEFAULT_FOLLOW_CONTROLLER_NAMESPACE_CHANGES;
1717
import static io.javaoperatorsdk.operator.api.reconciler.Constants.NO_LONG_VALUE_SET;
1818
import static io.javaoperatorsdk.operator.api.reconciler.Constants.NO_VALUE_SET;
1919

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

9393
/**
9494
* Replaces the item store used by the informer for the associated primary resource controller.

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/informer/InformerConfiguration.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class InformerConfiguration<R extends HasMetadata> {
2929
private final String resourceTypeName;
3030
private String name;
3131
private Set<String> namespaces;
32-
private Boolean followControllerNamespacesOnChange;
32+
private Boolean followControllerNamespaceChanges;
3333
private String labelSelector;
3434
private OnAddFilter<? super R> onAddFilter;
3535
private OnUpdateFilter<? super R> onUpdateFilter;
@@ -39,14 +39,14 @@ public class InformerConfiguration<R extends HasMetadata> {
3939
private Long informerListLimit;
4040

4141
protected InformerConfiguration(Class<R> resourceClass, String name, Set<String> namespaces,
42-
boolean followControllerNamespacesOnChange,
42+
boolean followControllerNamespaceChanges,
4343
String labelSelector, OnAddFilter<? super R> onAddFilter,
4444
OnUpdateFilter<? super R> onUpdateFilter, OnDeleteFilter<? super R> onDeleteFilter,
4545
GenericFilter<? super R> genericFilter, ItemStore<R> itemStore, Long informerListLimit) {
4646
this(resourceClass);
4747
this.name = name;
4848
this.namespaces = namespaces;
49-
this.followControllerNamespacesOnChange = followControllerNamespacesOnChange;
49+
this.followControllerNamespaceChanges = followControllerNamespaceChanges;
5050
this.labelSelector = labelSelector;
5151
this.onAddFilter = onAddFilter;
5252
this.onUpdateFilter = onUpdateFilter;
@@ -75,7 +75,7 @@ public static <R extends HasMetadata> InformerConfiguration<R>.Builder builder(
7575
public static <R extends HasMetadata> InformerConfiguration<R>.Builder builder(
7676
InformerConfiguration<R> original) {
7777
return new InformerConfiguration(original.resourceClass, original.name, original.namespaces,
78-
original.followControllerNamespacesOnChange, original.labelSelector, original.onAddFilter,
78+
original.followControllerNamespaceChanges, original.labelSelector, original.onAddFilter,
7979
original.onUpdateFilter, original.onDeleteFilter, original.genericFilter,
8080
original.itemStore, original.informerListLimit).builder;
8181
}
@@ -184,8 +184,8 @@ public Set<String> getEffectiveNamespaces(ControllerConfiguration<?> controllerC
184184
*
185185
* @return if namespace changes should be followed
186186
*/
187-
public boolean isFollowControllerNamespacesOnChange() {
188-
return followControllerNamespacesOnChange;
187+
public boolean getFollowControllerNamespaceChanges() {
188+
return followControllerNamespaceChanges;
189189
}
190190

191191
/**
@@ -258,7 +258,7 @@ public InformerConfiguration<R> buildForController() {
258258
namespaces = Constants.DEFAULT_NAMESPACES_SET;
259259
}
260260
// to avoid potential NPE
261-
followControllerNamespacesOnChange = false;
261+
followControllerNamespaceChanges = false;
262262
return InformerConfiguration.this;
263263
}
264264

@@ -267,9 +267,9 @@ public InformerConfiguration<R> build() {
267267
if (namespaces == null || namespaces.isEmpty()) {
268268
namespaces = Constants.SAME_AS_CONTROLLER_NAMESPACES_SET;
269269
}
270-
if (followControllerNamespacesOnChange == null) {
271-
followControllerNamespacesOnChange =
272-
DEFAULT_FOLLOW_CONTROLLER_NAMESPACES_ON_CHANGE;
270+
if (followControllerNamespaceChanges == null) {
271+
followControllerNamespaceChanges =
272+
DEFAULT_FOLLOW_CONTROLLER_NAMESPACE_CHANGES;
273273
}
274274
return InformerConfiguration.this;
275275
}
@@ -304,8 +304,8 @@ public InformerConfiguration<R>.Builder initFromAnnotation(Informer informerConf
304304
GenericFilter.class,
305305
context));
306306

307-
withFollowControllerNamespacesOnChange(
308-
informerConfig.followControllerNamespacesOnChange());
307+
withFollowControllerNamespacesChanges(
308+
informerConfig.followControllerNamespaceChanges());
309309

310310
withItemStore(Utils.instantiate(informerConfig.itemStore(),
311311
ItemStore.class, context));
@@ -344,7 +344,7 @@ public Set<String> namespaces() {
344344
* @return the builder instance so that calls can be chained fluently
345345
*/
346346
public Builder withNamespaces(Set<String> namespaces, boolean followChanges) {
347-
withNamespaces(namespaces).withFollowControllerNamespacesOnChange(followChanges);
347+
withNamespaces(namespaces).withFollowControllerNamespacesChanges(followChanges);
348348
return this;
349349
}
350350

@@ -372,8 +372,8 @@ public Builder withWatchCurrentNamespace() {
372372
* controller's namespaces are reconfigured, {@code false} otherwise
373373
* @return the builder instance so that calls can be chained fluently
374374
*/
375-
public Builder withFollowControllerNamespacesOnChange(boolean followChanges) {
376-
InformerConfiguration.this.followControllerNamespacesOnChange =
375+
public Builder withFollowControllerNamespacesChanges(boolean followChanges) {
376+
InformerConfiguration.this.followControllerNamespaceChanges =
377377
followChanges;
378378
return this;
379379
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/informer/InformerEventSourceConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static Builder<GenericKubernetesResource> from(
3535
* @return if namespace changes should be followed
3636
*/
3737
default boolean followControllerNamespaceChanges() {
38-
return getInformerConfig().isFollowControllerNamespacesOnChange();
38+
return getInformerConfig().getFollowControllerNamespaceChanges();
3939
}
4040

4141
/**
@@ -194,8 +194,8 @@ public void updateFrom(InformerConfiguration<R> informerConfig) {
194194
this.name = informerConfigName;
195195
}
196196
config.withNamespaces(informerConfig.getNamespaces())
197-
.withFollowControllerNamespacesOnChange(
198-
informerConfig.isFollowControllerNamespacesOnChange())
197+
.withFollowControllerNamespacesChanges(
198+
informerConfig.getFollowControllerNamespaceChanges())
199199
.withLabelSelector(informerConfig.getLabelSelector())
200200
.withItemStore(informerConfig.getItemStore())
201201
.withOnAddFilter(informerConfig.getOnAddFilter())

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public final class Constants {
2525

2626
public static final String RESOURCE_GVK_KEY = "josdk.resource.gvk";
2727
public static final String CONTROLLER_NAME = "controller.name";
28-
public static final boolean DEFAULT_FOLLOW_CONTROLLER_NAMESPACES_ON_CHANGE = true;
28+
public static final boolean DEFAULT_FOLLOW_CONTROLLER_NAMESPACE_CHANGES = true;
2929

3030
private Constants() {}
3131
}

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/InformerConfigurationTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ void currentNamespaceWatched() {
4747

4848
@Test
4949
void nullLabelSelectorByDefault() {
50-
final var informerConfig =
51-
InformerConfiguration.builder(ConfigMap.class).build();
50+
final var informerConfig = InformerConfiguration.builder(ConfigMap.class).build();
5251
assertNull(informerConfig.getLabelSelector());
5352
}
5453

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

6160
@Test
6261
void shouldFollowControllerNamespacesByDefaultForInformerEventSource() {
63-
final var informerConfig =
64-
InformerConfiguration.builder(ConfigMap.class).build();
65-
assertTrue(informerConfig.isFollowControllerNamespacesOnChange());
62+
final var informerConfig = InformerConfiguration.builder(ConfigMap.class).build();
63+
assertTrue(informerConfig.getFollowControllerNamespaceChanges());
6664
}
6765

6866
@Test

0 commit comments

Comments
 (0)