|
15 | 15 | import io.kubernetes.client.ApiClient; |
16 | 16 | import io.kubernetes.client.util.credentials.AccessTokenAuthentication; |
17 | 17 | import io.kubernetes.client.util.credentials.UsernamePasswordAuthentication; |
| 18 | +import java.io.BufferedReader; |
18 | 19 | import java.io.File; |
19 | | -import java.io.FileReader; |
| 20 | +import java.io.FileInputStream; |
20 | 21 | import java.io.IOException; |
21 | 22 | import java.io.InputStream; |
22 | 23 | import java.io.InputStreamReader; |
23 | 24 | import java.io.Reader; |
| 25 | +import java.nio.charset.StandardCharsets; |
24 | 26 | import org.slf4j.Logger; |
25 | 27 | import org.slf4j.LoggerFactory; |
26 | 28 |
|
@@ -74,13 +76,17 @@ public static ApiClient fromToken(String url, String token, boolean validateSSL) |
74 | 76 | } |
75 | 77 |
|
76 | 78 | public static ApiClient fromConfig(String fileName) throws IOException { |
77 | | - KubeConfig config = KubeConfig.loadKubeConfig(new FileReader(fileName)); // TODO UTF-8 |
78 | | - config.setFile(new File(fileName)); |
79 | | - return fromConfig(config); |
| 79 | + try (BufferedReader bufferedReader = |
| 80 | + new BufferedReader( |
| 81 | + new InputStreamReader(new FileInputStream(fileName), StandardCharsets.UTF_8.name()))) { |
| 82 | + KubeConfig config = KubeConfig.loadKubeConfig(bufferedReader); |
| 83 | + config.setFile(new File(fileName)); |
| 84 | + return fromConfig(config); |
| 85 | + } |
80 | 86 | } |
81 | 87 |
|
82 | 88 | public static ApiClient fromConfig(InputStream stream) throws IOException { |
83 | | - return fromConfig(new InputStreamReader(stream)); // TODO UTF-8 |
| 89 | + return fromConfig(new InputStreamReader(stream, StandardCharsets.UTF_8.name())); |
84 | 90 | } |
85 | 91 |
|
86 | 92 | public static ApiClient fromConfig(Reader input) throws IOException { |
|
0 commit comments