Search in sources :

Example 11 with ClusterAccess

use of io.fabric8.maven.core.access.ClusterAccess in project fabric8-maven-plugin by fabric8io.

the class ClusterAccessTest method kubernetesPlatformModeTest.

@Test
public void kubernetesPlatformModeTest() throws Exception {
    RootPaths rootpaths = new RootPaths();
    rootpaths.setPaths(paths);
    mockServer.expect().get().withPath("/").andReturn(200, rootpaths).always();
    ClusterAccess clusterAccess = new ClusterAccess(null, client);
    mode = clusterAccess.resolvePlatformMode(PlatformMode.kubernetes, logger);
    assertEquals(PlatformMode.kubernetes, mode);
    mode = clusterAccess.resolvePlatformMode(PlatformMode.DEFAULT, logger);
    assertEquals(PlatformMode.kubernetes, mode);
    mode = clusterAccess.resolvePlatformMode(null, logger);
    assertEquals(PlatformMode.kubernetes, mode);
}
Also used : RootPaths(io.fabric8.kubernetes.api.model.RootPaths) Test(org.junit.Test)

Example 12 with ClusterAccess

use of io.fabric8.maven.core.access.ClusterAccess in project fabric8-maven-plugin by fabric8io.

the class ClusterAccessTest method createClientTestOpenshift.

@Test
public void createClientTestOpenshift() throws Exception {
    paths.add("/oapi");
    paths.add("/oapi/v1");
    RootPaths rootpaths = new RootPaths();
    rootpaths.setPaths(paths);
    mockServer.expect().get().withPath("/").andReturn(200, rootpaths).always();
    ClusterAccess clusterAccess = new ClusterAccess(null, client);
    Client outputClient = clusterAccess.createDefaultClient(logger);
    assertTrue(outputClient instanceof OpenShiftClient);
}
Also used : RootPaths(io.fabric8.kubernetes.api.model.RootPaths) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Client(io.fabric8.kubernetes.client.Client) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) Test(org.junit.Test)

Example 13 with ClusterAccess

use of io.fabric8.maven.core.access.ClusterAccess in project fabric8-maven-plugin by fabric8io.

the class DockerImageWatcher method restartContainer.

protected void restartContainer(WatchService.ImageWatcher watcher, Set<HasMetadata> resources) throws MojoExecutionException {
    ImageConfiguration imageConfig = watcher.getImageConfiguration();
    String imageName = imageConfig.getName();
    try {
        ClusterAccess clusterAccess = new ClusterAccess(getContext().getNamespace());
        KubernetesClient client = clusterAccess.createDefaultClient(log);
        String namespace = clusterAccess.getNamespace();
        String imagePrefix = getImagePrefix(imageName);
        for (HasMetadata entity : resources) {
            updateImageName(client, namespace, entity, imagePrefix, imageName);
        }
    } catch (KubernetesClientException e) {
        KubernetesResourceUtil.handleKubernetesClientException(e, this.log);
    } catch (MojoExecutionException e) {
        throw e;
    } catch (Exception e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ClusterAccess(io.fabric8.maven.core.access.ClusterAccess) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) DockerAccessException(io.fabric8.maven.docker.access.DockerAccessException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Aggregations

ClusterAccess (io.fabric8.maven.core.access.ClusterAccess)6 Test (org.junit.Test)6 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)5 RootPaths (io.fabric8.kubernetes.api.model.RootPaths)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)3 DockerBuildService (io.fabric8.maven.core.service.kubernetes.DockerBuildService)3 OpenshiftBuildService (io.fabric8.maven.core.service.openshift.OpenshiftBuildService)3 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)3 Controller (io.fabric8.kubernetes.api.Controller)2 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)2 Client (io.fabric8.kubernetes.client.Client)2 File (java.io.File)2 IOException (java.io.IOException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 KubernetesHelper.createIntOrString (io.fabric8.kubernetes.api.KubernetesHelper.createIntOrString)1 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)1 DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)1 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)1