Skip to content

Commit

Permalink
improve: follow namespace changes method naming
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
  • Loading branch information
csviri authored and metacosm committed Jan 25, 2025
1 parent b25a399 commit b406787
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
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 followControllerNamespacesChanges;
private String labelSelector;
private OnAddFilter<? super R> onAddFilter;
private OnUpdateFilter<? super R> onUpdateFilter;
Expand All @@ -46,7 +46,7 @@ protected InformerConfiguration(Class<R> resourceClass, String name, Set<String>
this(resourceClass);
this.name = name;
this.namespaces = namespaces;
this.followControllerNamespacesOnChange = followControllerNamespacesOnChange;
this.followControllerNamespacesChanges = followControllerNamespacesOnChange;
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.followControllerNamespacesChanges, 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 getFollowControllerNamespacesChanges() {
return followControllerNamespacesChanges;
}

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

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

withFollowControllerNamespacesOnChange(
withFollowControllerNamespacesChanges(
informerConfig.followControllerNamespacesOnChange());

withItemStore(Utils.instantiate(informerConfig.itemStore(),
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.followControllerNamespacesChanges =
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().getFollowControllerNamespacesChanges();
}

/**
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.getFollowControllerNamespacesChanges())
.withLabelSelector(informerConfig.getLabelSelector())
.withItemStore(informerConfig.getItemStore())
.withOnAddFilter(informerConfig.getOnAddFilter())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,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.getFollowControllerNamespacesChanges());
}

@Test
Expand Down

0 comments on commit b406787

Please sign in to comment.