-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to customize k8s client config
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
Showing
5 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...oyment/src/test/java/io/quarkus/kubernetes/client/deployment/KubernetesClientCDITest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.quarkus.kubernetes.client.deployment; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.fabric8.kubernetes.client.Config; | ||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import io.quarkus.kubernetes.client.KubernetesConfigCustomizer; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class KubernetesClientCDITest { | ||
|
||
@Inject | ||
KubernetesClient client; | ||
|
||
@Test | ||
public void test() { | ||
assertEquals("-1", client.getConfiguration().getApiVersion()); | ||
} | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Customizer.class)); | ||
|
||
@Singleton | ||
public static class Customizer implements KubernetesConfigCustomizer { | ||
@Override | ||
public void customize(Config config) { | ||
config.setApiVersion("-1"); | ||
} | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...client/runtime/src/main/java/io/quarkus/kubernetes/client/KubernetesConfigCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.quarkus.kubernetes.client; | ||
|
||
import java.util.List; | ||
|
||
import io.fabric8.kubernetes.client.Config; | ||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import io.quarkus.kubernetes.client.runtime.KubernetesClientBuildConfig; | ||
import io.quarkus.kubernetes.client.runtime.KubernetesClientProducer; | ||
import io.quarkus.kubernetes.client.runtime.KubernetesConfigProducer; | ||
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters