Search in sources :

Example 11 with ApiClient

use of io.kubernetes.client.openapi.ApiClient in project java by kubernetes-client.

the class ClientBuilderTest method testHomeDirPreferredOverKubeConfig.

@Test
public void testHomeDirPreferredOverKubeConfig() throws Exception {
    String path = withEnvironmentVariable("HOME", HOME_PATH).and("KUBEDIR", KUBEDIR).and("KUBECONFIG", KUBECONFIG).execute(() -> {
        final ApiClient client = ClientBuilder.standard().build();
        return client.getBasePath();
    });
    assertEquals(path, "http://home.dir.com");
}
Also used : ApiClient(io.kubernetes.client.openapi.ApiClient) Test(org.junit.Test)

Example 12 with ApiClient

use of io.kubernetes.client.openapi.ApiClient in project java by kubernetes-client.

the class ClientBuilderTest method testKubeconfigAddsSchemeHttps.

@Test
public void testKubeconfigAddsSchemeHttps() throws Exception {
    String path = withEnvironmentVariable("KUBECONFIG", KUBECONFIG_HTTPS_FILE_PATH).execute(() -> {
        final ApiClient client = ClientBuilder.standard().build();
        return client.getBasePath();
    });
    assertThat(path, is("https://localhost:443"));
}
Also used : ApiClient(io.kubernetes.client.openapi.ApiClient) Test(org.junit.Test)

Example 13 with ApiClient

use of io.kubernetes.client.openapi.ApiClient in project java by kubernetes-client.

the class ClientBuilderTest method testDefaultClientReadsHomeDir.

@Test
public void testDefaultClientReadsHomeDir() throws Exception {
    String path = withEnvironmentVariable("HOME", HOME_PATH).execute(() -> {
        ApiClient client = ClientBuilder.defaultClient();
        return client.getBasePath();
    });
    assertEquals("http://home.dir.com", path);
}
Also used : ApiClient(io.kubernetes.client.openapi.ApiClient) Test(org.junit.Test)

Example 14 with ApiClient

use of io.kubernetes.client.openapi.ApiClient in project java by kubernetes-client.

the class ClientBuilderTest method testStandardVerifiesSsl.

@Test
public void testStandardVerifiesSsl() throws Exception {
    boolean isVerifyingSsl = withEnvironmentVariable("HOME", "/non-existent").execute(() -> {
        final ApiClient client = ClientBuilder.standard().build();
        return client.isVerifyingSsl();
    });
    assertThat(isVerifyingSsl, is(true));
}
Also used : ApiClient(io.kubernetes.client.openapi.ApiClient) Test(org.junit.Test)

Example 15 with ApiClient

use of io.kubernetes.client.openapi.ApiClient in project java by kubernetes-client.

the class ClientBuilderTest method testKubeconfigPreferredOverHomeDir.

@Test
public void testKubeconfigPreferredOverHomeDir() throws Exception {
    String path = withEnvironmentVariable("HOME", HOME_PATH).and("KUBECONFIG", KUBECONFIG_FILE_PATH).execute(() -> {
        final ApiClient client = ClientBuilder.standard().build();
        return client.getBasePath();
    });
    // $KUBECONFIG should take precedence over $HOME/.kube/config
    assertEquals("http://kubeconfig.dir.com", path);
}
Also used : ApiClient(io.kubernetes.client.openapi.ApiClient) Test(org.junit.Test)

Aggregations

ApiClient (io.kubernetes.client.openapi.ApiClient)61 Test (org.junit.Test)28 CoreV1Api (io.kubernetes.client.openapi.apis.CoreV1Api)13 V1Pod (io.kubernetes.client.openapi.models.V1Pod)12 IOException (java.io.IOException)11 V1PodList (io.kubernetes.client.openapi.models.V1PodList)9 ClientBuilder (io.kubernetes.client.util.ClientBuilder)6 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)5 Before (org.junit.Before)5 ApiException (io.kubernetes.client.openapi.ApiException)4 SharedInformerFactory (io.kubernetes.client.informer.SharedInformerFactory)3 V1Job (io.kubernetes.client.openapi.models.V1Job)3 V1JobList (io.kubernetes.client.openapi.models.V1JobList)3 V1Namespace (io.kubernetes.client.openapi.models.V1Namespace)3 OkHttpClient (okhttp3.OkHttpClient)3 NodeMetrics (io.kubernetes.client.custom.NodeMetrics)2 PodMetrics (io.kubernetes.client.custom.PodMetrics)2 V1Patch (io.kubernetes.client.custom.V1Patch)2 LeaderElectionConfig (io.kubernetes.client.extended.leaderelection.LeaderElectionConfig)2 LeaderElector (io.kubernetes.client.extended.leaderelection.LeaderElector)2