Skip to content

Commit f307c5f

Browse files
committed
Encode client key to Base64
1 parent 020d333 commit f307c5f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/cd/go/contrib/elasticagent/KubernetesClientFactory.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
2121
import io.fabric8.kubernetes.client.KubernetesClient;
2222

23+
import java.util.Base64;
24+
2325
import static cd.go.contrib.elasticagent.KubernetesPlugin.LOG;
2426
import static cd.go.contrib.elasticagent.model.AuthenticationStrategy.CLUSTER_CERTS;
2527
import static cd.go.contrib.elasticagent.model.AuthenticationStrategy.OAUTH_TOKEN;
@@ -58,10 +60,14 @@ private KubernetesClient createClientFor(PluginSettings pluginSettings) {
5860
configBuilder
5961
.withMasterUrl(pluginSettings.getClusterUrl())
6062
.withCaCertData(pluginSettings.getCaCertData())
61-
.withClientKeyData(pluginSettings.getClientKeyData())
63+
.withClientKeyData(encodeToBase64(pluginSettings.getClientKeyData()))
6264
.withClientCertData(pluginSettings.getClientCertData());
6365
}
6466

6567
return new DefaultKubernetesClient(configBuilder.build());
6668
}
69+
70+
private String encodeToBase64(String stringToEncode) {
71+
return Base64.getEncoder().encodeToString(stringToEncode.getBytes());
72+
}
6773
}

0 commit comments

Comments
 (0)