Search in sources :

Example 1 with VolumeConfig

use of io.fabric8.maven.core.config.VolumeConfig in project fabric8-maven-plugin by fabric8io.

the class ContainerHandlerTest method getVolumeMountWithoutMountTest.

@Test
public void getVolumeMountWithoutMountTest() {
    ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
    images.clear();
    images.add(imageConfiguration1);
    // volume config without mount
    VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("first").build();
    volumes1.add(volumeConfig1);
    ResourceConfig config1 = new ResourceConfig.Builder().volumes(volumes1).build();
    containers = handler.getContainers(config1, images);
    assertTrue(containers.get(0).getVolumeMounts().isEmpty());
}
Also used : ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) VolumeConfig(io.fabric8.maven.core.config.VolumeConfig) Test(org.junit.Test)

Example 2 with VolumeConfig

use of io.fabric8.maven.core.config.VolumeConfig in project fabric8-maven-plugin by fabric8io.

the class ContainerHandlerTest method getVolumeMountWithMultipleMountTest.

@Test
public void getVolumeMountWithMultipleMountTest() {
    ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
    images.clear();
    images.add(imageConfiguration1);
    List<String> mounts = new ArrayList<>();
    mounts.add("/path/etc");
    // volume config with name and multiple mount
    mounts.add("/path/system");
    mounts.add("/path/sys");
    VolumeConfig volumeConfig4 = new VolumeConfig.Builder().name("test").mounts(mounts).build();
    volumes1.clear();
    volumes1.add(volumeConfig4);
    ResourceConfig config4 = new ResourceConfig.Builder().volumes(volumes1).build();
    containers = handler.getContainers(config4, images);
    assertEquals(3, containers.get(0).getVolumeMounts().size());
    for (int i = 0; i <= 2; i++) assertEquals("test", containers.get(0).getVolumeMounts().get(i).getName());
}
Also used : ArrayList(java.util.ArrayList) ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) VolumeConfig(io.fabric8.maven.core.config.VolumeConfig) Test(org.junit.Test)

Example 3 with VolumeConfig

use of io.fabric8.maven.core.config.VolumeConfig in project fabric8-maven-plugin by fabric8io.

the class DaemonSetHandlerTest method before.

@Before
public void before() {
    // volume config with name and multiple mount
    mounts.add("/path/system");
    mounts.add("/path/sys");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
    volumes1.add(volumeConfig1);
    // container name with alias
    BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compression("gzip").build();
    ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration).registry("docker.io").build();
    images.add(imageConfiguration);
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) VolumeConfig(io.fabric8.maven.core.config.VolumeConfig) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Before(org.junit.Before)

Example 4 with VolumeConfig

use of io.fabric8.maven.core.config.VolumeConfig in project fabric8-maven-plugin by fabric8io.

the class JobHandlerTest method before.

@Before
public void before() {
    // volume config with name and multiple mount
    mounts.add("/path/system");
    mounts.add("/path/sys");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
    volumes1.add(volumeConfig1);
    // container name with alias
    BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compression("gzip").build();
    ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration).registry("docker.io").build();
    images.add(imageConfiguration);
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) VolumeConfig(io.fabric8.maven.core.config.VolumeConfig) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Before(org.junit.Before)

Example 5 with VolumeConfig

use of io.fabric8.maven.core.config.VolumeConfig in project fabric8-maven-plugin by fabric8io.

the class PodTemplateHandlerTest method podWithVolumeTemplateHandlerTest.

@Test
public void podWithVolumeTemplateHandlerTest() {
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    // Config with Volume Config and ServiceAccount
    // valid type
    VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
    volumes1.clear();
    volumes1.add(volumeConfig1);
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
    PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, images);
    // Assertion
    assertEquals("test-account", podTemplateSpec.getSpec().getServiceAccountName());
    assertFalse(podTemplateSpec.getSpec().getVolumes().isEmpty());
    assertEquals("test", podTemplateSpec.getSpec().getVolumes().get(0).getName());
    assertEquals("/test/path", podTemplateSpec.getSpec().getVolumes().get(0).getHostPath().getPath());
    assertNotNull(podTemplateSpec.getSpec().getContainers());
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) VolumeConfig(io.fabric8.maven.core.config.VolumeConfig) Test(org.junit.Test)

Aggregations

VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)15 ResourceConfig (io.fabric8.maven.core.config.ResourceConfig)7 Test (org.junit.Test)7 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)6 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)6 ArrayList (java.util.ArrayList)6 Before (org.junit.Before)6 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)3 RunVolumeConfiguration (io.fabric8.maven.docker.config.RunVolumeConfiguration)2 VolumeMount (io.fabric8.kubernetes.api.model.VolumeMount)1 VolumeMountBuilder (io.fabric8.kubernetes.api.model.VolumeMountBuilder)1 VolumeType (io.fabric8.maven.core.config.VolumeType)1 ContainerCreateConfig (io.fabric8.maven.docker.access.ContainerCreateConfig)1 ContainerNetworkingConfig (io.fabric8.maven.docker.access.ContainerNetworkingConfig)1 NetworkConfig (io.fabric8.maven.docker.config.NetworkConfig)1 VolumeConfiguration (io.fabric8.maven.docker.config.VolumeConfiguration)1 HashMap (java.util.HashMap)1