File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
main/java/io/kubernetes/client/util
test/java/io/kubernetes/client/util Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -277,6 +277,9 @@ public static ClientBuilder kubeconfig(KubeConfig config) throws IOException {
277277 final ClientBuilder builder = new ClientBuilder ();
278278
279279 String server = config .getServer ();
280+ if (server == null ) {
281+ throw new IllegalArgumentException ("No server in kubeconfig" );
282+ }
280283 if (!server .contains ("://" )) {
281284 if (server .contains (":443" )) {
282285 server = "https://" + server ;
Original file line number Diff line number Diff line change 1818import static org .hamcrest .MatcherAssert .assertThat ;
1919import static org .hamcrest .core .Is .is ;
2020import static org .junit .Assert .assertEquals ;
21+ import static org .junit .Assert .assertThrows ;
2122import static org .mockito .Mockito .mock ;
2223import static org .mockito .Mockito .verify ;
2324
@@ -299,4 +300,16 @@ public void testSettingPassphraseForKubeConfigShouldWork() throws IOException {
299300 ((ClientCertificateAuthentication ) receivingAuthn .getDelegateAuthentication ())
300301 .getPassphrase ());
301302 }
303+
304+ @ Test
305+ public void testDetectsServerNotSet () {
306+ assertThrows (
307+ "No server in kubeconfig" ,
308+ IllegalArgumentException .class ,
309+ () -> {
310+ KubeConfig kubeConfigWithoutServer = mock (KubeConfig .class );
311+
312+ ClientBuilder .kubeconfig (kubeConfigWithoutServer );
313+ });
314+ }
302315}
You can’t perform that action at this time.
0 commit comments