Class KubernetesConfigMapWatcher

java.lang.Object
io.micronaut.kubernetes.configuration.KubernetesConfigMapWatcher
All Implemented Interfaces:
io.kubernetes.client.informer.ResourceEventHandler<io.kubernetes.client.openapi.models.V1ConfigMap>

@Context @Requires(env="k8s") @Requires(beans=io.micronaut.kubernetes.client.reactor.CoreV1ApiReactorClient.class) @Requires(property="micronaut.config-client.enabled",value="true",defaultValue="false") @Requires(condition=KubernetesConfigMapWatcherCondition.class) public final class KubernetesConfigMapWatcher extends Object implements io.kubernetes.client.informer.ResourceEventHandler<io.kubernetes.client.openapi.models.V1ConfigMap>
Watches for ConfigMap changes and makes the appropriate changes to the Environment by adding or removing PropertySources.
Since:
1.0.0
Author:
Álvaro Sánchez-Mariscal
  • Constructor Details

    • KubernetesConfigMapWatcher

      public KubernetesConfigMapWatcher(io.micronaut.context.env.Environment environment, io.kubernetes.client.openapi.ApiClient apiClient, io.kubernetes.client.openapi.apis.CoreV1Api coreV1Api, io.micronaut.kubernetes.client.reactor.CoreV1ApiReactorClient coreV1ApiReactorClient, KubernetesConfiguration configuration, @Named("io") ExecutorService executorService, io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.runtime.context.scope.refresh.RefreshEvent> eventPublisher)
      Parameters:
      environment - the Environment
      apiClient - the ApiClient
      coreV1Api - the CoreV1Api
      coreV1ApiReactorClient - the CoreV1ApiReactorClient
      configuration - the KubernetesConfiguration
      executorService - the IO ExecutorService where the watch publisher will be scheduled on
      eventPublisher - the ApplicationEventPublisher
    • KubernetesConfigMapWatcher

      @Inject public KubernetesConfigMapWatcher(io.micronaut.context.env.Environment environment, KubernetesConfiguration configuration, io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.runtime.context.scope.refresh.RefreshEvent> eventPublisher)
  • Method Details

    • onApplicationEvent

      @EventListener public void onApplicationEvent(io.micronaut.discovery.event.ServiceReadyEvent event)
    • onAdd

      public void onAdd(io.kubernetes.client.openapi.models.V1ConfigMap configMap)
      Specified by:
      onAdd in interface io.kubernetes.client.informer.ResourceEventHandler<io.kubernetes.client.openapi.models.V1ConfigMap>
    • onUpdate

      public void onUpdate(io.kubernetes.client.openapi.models.V1ConfigMap oldObj, io.kubernetes.client.openapi.models.V1ConfigMap configMap)
      Specified by:
      onUpdate in interface io.kubernetes.client.informer.ResourceEventHandler<io.kubernetes.client.openapi.models.V1ConfigMap>
    • onDelete

      public void onDelete(io.kubernetes.client.openapi.models.V1ConfigMap configMap, boolean deletedFinalStateUnknown)
      Specified by:
      onDelete in interface io.kubernetes.client.informer.ResourceEventHandler<io.kubernetes.client.openapi.models.V1ConfigMap>