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

chore: remove obsolete InjectionAwareConfigurationService #496

Merged
merged 1 commit into from
Jan 8, 2024
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import io.fabric8.kubernetes.client.KubernetesClientBuilder
import io.fabric8.kubernetes.client.utils.KubernetesSerialization
import io.javaoperatorsdk.operator.Operator
import io.javaoperatorsdk.operator.RegisteredController
import io.javaoperatorsdk.operator.api.config.ConfigurationService
import io.javaoperatorsdk.operator.api.config.ConfigurationServiceOverrider
import io.javaoperatorsdk.operator.api.config.ControllerConfigurationOverrider
import io.javaoperatorsdk.operator.api.reconciler.Constants
import io.javaoperatorsdk.operator.api.reconciler.Reconciler
Expand All @@ -23,6 +23,7 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import java.security.SecureRandom
import java.util.Random
import java.util.function.Consumer

@Configuration
class OperatorConfig {
Expand All @@ -39,24 +40,35 @@ class OperatorConfig {
.withKubernetesSerialization(KubernetesSerialization(objectMapper, true))
.build()

@Bean
fun configurationServiceOverrider(
kubernetesClient: KubernetesClient,
dependentResourceFactory: InjectionAwareDependentResourceFactory
): Consumer<ConfigurationServiceOverrider> = Consumer {
it.withKubernetesClient(kubernetesClient)
it.withDependentResourceFactory(dependentResourceFactory)
}

@Bean(destroyMethod = "stop")
fun operator(configurationService: ConfigurationService, reconcilers: List<Reconciler<*>>) =
Operator(configurationService).apply {
reconcilers.forEach {
if (it !is HasRegistrationCondition || it.isRegistrationEnabled) {
registerForNamespaceOrCluster(it)
} else {
log.warn(
listOfNotNull(
"Reconciler was not registered because it's registration condition is not met: ${it.javaClass.name}.",
it.registrationConditionHint,
"Resources managed by this controller will not be reconciled!"
).joinToString(" ")
)
}
fun operator(
configurationServiceOverrider: Consumer<ConfigurationServiceOverrider>,
reconcilers: List<Reconciler<*>>
) = Operator(configurationServiceOverrider).apply {
reconcilers.forEach {
if (it !is HasRegistrationCondition || it.isRegistrationEnabled) {
registerForNamespaceOrCluster(it)
} else {
log.warn(
listOfNotNull(
"Reconciler was not registered because it's registration condition is not met: ${it.javaClass.name}.",
it.registrationConditionHint,
"Resources managed by this controller will not be reconciled!"
).joinToString(" ")
)
}
start()
}
start()
}

@Bean
fun random(): Random =
Expand Down
Loading