Skip to content

Commit

Permalink
Add the ability to customize k8s client config
Browse files Browse the repository at this point in the history
This gives users the ability to alter the
configuration provided by Quarkus in arbitrary ways

The pattern implemented is exactly the same as the
one used in other extensions

Relates to: #31395
  • Loading branch information
geoand committed Feb 24, 2023
1 parent 1b8fc61 commit 2d29198
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.quarkus.kubernetes.client.runtime;

import java.util.List;

import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.quarkus.runtime.TlsConfig;

/**
* Meant to be implemented by a CDI bean that provided arbitrary customization for the default {@link Config} created by
* Quarkus.
* <p>
* The {@link Config} is in turn used to produce the default {@link KubernetesClient}
* <p>
*
* @see KubernetesConfigProducer#config(KubernetesClientBuildConfig, TlsConfig, List) }
* @see KubernetesClientProducer#kubernetesClient(Config) }
*/
public interface KubernetesConfigCustomizer {

void customize(Config config);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package io.quarkus.kubernetes.client.runtime;

import java.util.List;

import jakarta.enterprise.inject.Produces;
import jakarta.inject.Singleton;

import io.fabric8.kubernetes.client.Config;
import io.quarkus.arc.All;
import io.quarkus.arc.DefaultBean;
import io.quarkus.runtime.TlsConfig;

Expand All @@ -13,7 +16,13 @@ public class KubernetesConfigProducer {
@DefaultBean
@Singleton
@Produces
public Config config(KubernetesClientBuildConfig buildConfig, TlsConfig tlsConfig) {
return KubernetesClientUtils.createConfig(buildConfig, tlsConfig);
public Config config(KubernetesClientBuildConfig buildConfig,
TlsConfig tlsConfig,
@All List<KubernetesConfigCustomizer> customizers) {
var result = KubernetesClientUtils.createConfig(buildConfig, tlsConfig);
for (KubernetesConfigCustomizer customizer : customizers) {
customizer.customize(result);
}
return result;
}
}

0 comments on commit 2d29198

Please sign in to comment.