Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve: naming InformerConfiguration build #2671

Merged
merged 2 commits into from
Jan 25, 2025
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 @@ -249,6 +249,7 @@ public Long getInformerListLimit() {
@SuppressWarnings("UnusedReturnValue")
public class Builder {

/** For internal usage only. Use {@link #build()} method for building for InformerEventSource */
public InformerConfiguration<R> buildForController() {
// if the informer config uses the default "same as controller" value, reset the namespaces to
// the default set for controllers
Expand All @@ -261,7 +262,8 @@ public InformerConfiguration<R> buildForController() {
return InformerConfiguration.this;
}

public InformerConfiguration<R> buildForInformerEventSource() {
/** Build for InformerEventSource */
public InformerConfiguration<R> build() {
if (namespaces == null || namespaces.isEmpty()) {
namespaces = Constants.SAME_AS_CONTROLLER_NAMESPACES_SET;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public InformerEventSourceConfiguration<R> build() {
Objects.requireNonNullElse(secondaryToPrimaryMapper,
Mappers.fromOwnerReferences(HasMetadata.getApiVersion(primaryResourceClass),
HasMetadata.getKind(primaryResourceClass), false)),
config.buildForInformerEventSource(), kubernetesClient);
config.build(), kubernetesClient);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ private InformerConfiguration<R> createInformerConfig(
configAnnotation.annotationType());
config = config.initFromAnnotation(informerConfig, context);
}
return config.buildForInformerEventSource();
return config.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void replaceNamedDependentResourceConfigShouldWork() {
final var overridingInformerConfig = InformerConfiguration.builder(ConfigMap.class)
.withNamespaces(Set.of(overriddenNS))
.withLabelSelector(labelSelector)
.buildForInformerEventSource();
.build();
final var overridden = ControllerConfigurationOverrider.override(configuration)
.replacingNamedDependentResourceConfig(
dependentResourceName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void currentNamespaceWatched() {
@Test
void nullLabelSelectorByDefault() {
final var informerConfig =
InformerConfiguration.builder(ConfigMap.class).buildForInformerEventSource();
InformerConfiguration.builder(ConfigMap.class).build();
assertNull(informerConfig.getLabelSelector());
}

Expand All @@ -61,7 +61,7 @@ void shouldWatchAllNamespacesByDefaultForControllers() {
@Test
void shouldFollowControllerNamespacesByDefaultForInformerEventSource() {
final var informerConfig =
InformerConfiguration.builder(ConfigMap.class).buildForInformerEventSource();
InformerConfiguration.builder(ConfigMap.class).build();
assertTrue(informerConfig.isFollowControllerNamespacesOnChange());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void initDependentResources(KubernetesClient client) {
.forEach(dr -> dr.configureWith(new KubernetesDependentResourceConfigBuilder()
.withKubernetesDependentInformerConfig(InformerConfiguration.builder(dr.resourceType())
.withLabelSelector(DEPENDENT_RESOURCE_LABEL_SELECTOR)
.buildForInformerEventSource())
.build())
.build()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private Workflow<WebPage> createDependentResourcesAndWorkflow() {
.forEach(dr -> dr.configureWith(new KubernetesDependentResourceConfigBuilder()
.withKubernetesDependentInformerConfig(InformerConfiguration.builder(dr.resourceType())
.withLabelSelector(SELECTOR + "=true")
.buildForInformerEventSource())
.build())
.build()));

// connect the dependent resources into a workflow, configuring them as we go
Expand Down
Loading