Skip to content

Commit 558864f

Browse files
committed
Also handle client.authentication.k8s.io/v1alpha1.
1 parent 2d22dce commit 558864f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

util/src/main/java/io/kubernetes/client/util/KubeConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ private String tokenViaExecCredential(Map<String, Object> execMap) {
257257
return null;
258258
}
259259
String apiVersion = (String) execMap.get("apiVersion");
260-
if (!"client.authentication.k8s.io/v1beta1".equals(apiVersion)) {
261-
// TODO or v1alpha1 is apparently identical and could be supported
260+
if (!"client.authentication.k8s.io/v1beta1".equals(apiVersion)
261+
&& !"client.authentication.k8s.io/v1alpha1".equals(apiVersion)) {
262262
log.error("Unrecognized user.exec.apiVersion: {}", apiVersion);
263263
return null;
264264
}

util/src/test/java/io/kubernetes/client/util/KubeConfigTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,13 @@ public void testExecCredentials() throws Exception {
298298
assertEquals("abc123", kc.getAccessToken());
299299
}
300300

301+
@Test
302+
public void testExecCredentialsAlpha1() throws Exception {
303+
KubeConfig kc =
304+
KubeConfig.loadKubeConfig(new StringReader(KUBECONFIG_EXEC.replace("v1beta1", "v1alpha1")));
305+
assertEquals("abc123", kc.getAccessToken());
306+
}
307+
301308
private static final String KUBECONFIG_EXEC_ENV =
302309
"apiVersion: v1\n"
303310
+ "current-context: c\n"

0 commit comments

Comments
 (0)