feature: add kubernetes context in configuration

This commit is contained in:
RouxAntoine 2023-07-24 19:20:05 +02:00
parent f1466e88a4
commit 0c4e87d1ab
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
3 changed files with 4 additions and 2 deletions

View File

@ -11,7 +11,7 @@ trim_trailing_whitespace = true
tab_width = 2
indent_size = 2
[*.java]
[{*.java,*.js}]
indent_size = 4
ij_continuation_indent_size = 4

View File

@ -8,6 +8,6 @@ public record BackofficeProperties(String apiPrefix, Kubernetes kubernetes) {
public record Kubernetes(Api api) {
}
public record Api(String kubeconfig) {
public record Api(String kubeconfig, String context) {
}
}

View File

@ -30,6 +30,7 @@ public class KubernetesClientConfiguration {
@Profile("dev")
public ApiClient devClient(BackofficeProperties backofficeProperties) throws IOException {
String kubeConfigPath = backofficeProperties.kubernetes().api().kubeconfig();
String context = backofficeProperties.kubernetes().api().context();
File kubeConfigFile = new File(kubeConfigPath);
try (BufferedReader kubeConfigReader =
new BufferedReader(
@ -38,6 +39,7 @@ public class KubernetesClientConfiguration {
KubeConfig kubeConfig = KubeConfig.loadKubeConfig(kubeConfigReader);
kubeConfig.setFile(kubeConfigFile);
kubeConfig.setContext(context);
return ClientBuilder.kubeconfig(kubeConfig).setPingInterval(Duration.ofSeconds(2)).build();
}