Skip to content

Commit 398e585

Browse files
committed
Add a bunch of simplified helper methods for creating clients from
different information.
1 parent fa6afca commit 398e585

File tree

1 file changed

+31
-0
lines changed
  • util/src/main/java/io/kubernetes/client/util

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,35 @@ public static ApiClient fromCluster() throws IOException {
3232

3333
return result;
3434
}
35+
36+
public static ApiClient fromUrl(String url) {
37+
return fromUrl(url, true);
38+
}
39+
40+
public static ApiClient fromUrl(String url, boolean validateSSL) {
41+
return new ApiClient()
42+
.setBasePath(url)
43+
.setVerifyingSsl(validateSSL);
44+
}
45+
46+
public static ApiClient fromUserPassword(String url, String user, String password) {
47+
return fromUserPassword(url, user, password, true);
48+
}
49+
50+
public static ApiClient fromUserPassword(String url, String user, String password, boolean validateSSL) {
51+
ApiClient client = fromUrl(url, validateSSL);
52+
client.setUsername(user);
53+
client.setPassword(password);
54+
return client;
55+
}
56+
57+
public static ApiClient fromToken(String url, String token) {
58+
return fromToken(url, token, true);
59+
}
60+
61+
public static ApiClient fromToken(String url, String token, boolean validateSSL) {
62+
ApiClient client = fromUrl(url, validateSSL);
63+
client.setAccessToken(token);
64+
return client;
65+
}
3566
}

0 commit comments

Comments
 (0)