forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#31398 from geoand/quarkusio#31395
Add the ability to customize k8s client config
- Loading branch information
Showing
5 changed files
with
90 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
40 changes: 40 additions & 0 deletions
40
...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,40 @@ | ||
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)) | ||
.overrideConfigKey("quarkus.kubernetes-client.devservices.enabled", "false"); | ||
|
||
@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