Skip to content

improve: add InformerEventSourceConfiguration withNamespaces overloaded version #2817

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

Merged
merged 2 commits into from
May 26, 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 @@ -194,6 +194,14 @@ public Builder<R> withNamespaces(Set<String> namespaces) {
return this;
}

/**
* @since 5.1.1
*/
public Builder<R> withNamespaces(String... namespaces) {
config.withNamespaces(Set.of(namespaces));
return this;
}

public Builder<R> withNamespacesInheritedFromController() {
withNamespaces(SAME_AS_CONTROLLER_NAMESPACES_SET);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ private io.javaoperatorsdk.operator.api.config.ControllerConfiguration<?> create
return configurationService.configFor(reconciler);
}

@Test
void overridingNamespacesShouldNotThrowNPE() {
var configuration = createConfiguration(new NullReconciler());
configuration =
ControllerConfigurationOverrider.override(configuration).settingNamespaces().build();
assertTrue(configuration.getInformerConfig().watchAllNamespaces());
}

private static class NullReconciler implements Reconciler<HasMetadata> {
@Override
public UpdateControl<HasMetadata> reconcile(HasMetadata resource, Context<HasMetadata> context)
throws Exception {
return null;
}
}

@Test
void overridingNamespacesShouldWork() {
var configuration = createConfiguration(new WatchCurrentReconciler());
Expand Down
Loading