Search in sources :

Example 1 with VolumeConfig

use of org.eclipse.jkube.kit.config.resource.VolumeConfig in project jkube by eclipse.

the class ContainerHandlerTest method getVolumeMountWithNameAndMountTest.

@Test
public void getVolumeMountWithNameAndMountTest() {
    ContainerHandler handler = createContainerHandler(project);
    List<String> mounts = new ArrayList<>();
    mounts.add("/path/etc");
    images.clear();
    images.add(imageConfiguration1);
    // volume config with name and single mount
    VolumeConfig volumeConfig3 = VolumeConfig.builder().name("third").mounts(mounts).build();
    volumes1.clear();
    volumes1.add(volumeConfig3);
    ResourceConfig config3 = ResourceConfig.builder().volumes(volumes1).build();
    containers = handler.getContainers(config3, images);
    assertEquals(1, containers.get(0).getVolumeMounts().size());
    assertEquals("third", containers.get(0).getVolumeMounts().get(0).getName());
    assertEquals("/path/etc", containers.get(0).getVolumeMounts().get(0).getMountPath());
}
Also used : ArrayList(java.util.ArrayList) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) VolumeConfig(org.eclipse.jkube.kit.config.resource.VolumeConfig) Test(org.junit.Test)

Example 2 with VolumeConfig

use of org.eclipse.jkube.kit.config.resource.VolumeConfig in project jkube by eclipse.

the class ContainerHandlerTest method getVolumeMountWithoutMountTest.

@Test
public void getVolumeMountWithoutMountTest() {
    ContainerHandler handler = createContainerHandler(project);
    images.clear();
    images.add(imageConfiguration1);
    // volume config without mount
    VolumeConfig volumeConfig1 = VolumeConfig.builder().name("first").build();
    volumes1.add(volumeConfig1);
    ResourceConfig config1 = ResourceConfig.builder().volumes(volumes1).build();
    containers = handler.getContainers(config1, images);
    assertTrue(containers.get(0).getVolumeMounts().isEmpty());
}
Also used : ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) VolumeConfig(org.eclipse.jkube.kit.config.resource.VolumeConfig) Test(org.junit.Test)

Example 3 with VolumeConfig

use of org.eclipse.jkube.kit.config.resource.VolumeConfig in project jkube by eclipse.

the class DeploymentHandlerTest 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 = VolumeConfig.builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
    volumes1.add(volumeConfig1);
    // container name with alias
    final BuildConfiguration buildImageConfiguration = BuildConfiguration.builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compressionString("gzip").build();
    ImageConfiguration imageConfiguration = ImageConfiguration.builder().name("test").alias("test-app").build(buildImageConfiguration).registry("docker.io").build();
    images.add(imageConfiguration);
    deploymentHandler = new DeploymentHandler(new PodTemplateHandler(new ContainerHandler(project.getProperties(), new GroupArtifactVersion("g", "a", "v"), probeHandler)));
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) GroupArtifactVersion(org.eclipse.jkube.kit.config.resource.GroupArtifactVersion) VolumeConfig(org.eclipse.jkube.kit.config.resource.VolumeConfig) Before(org.junit.Before)

Example 4 with VolumeConfig

use of org.eclipse.jkube.kit.config.resource.VolumeConfig in project jkube by eclipse.

the class PodTemplateHandlerTest method podWithVolumeTemplateHandlerTest.

@Test
public void podWithVolumeTemplateHandlerTest() {
    // Config with Volume Config and ServiceAccount
    // valid type
    VolumeConfig volumeConfig1 = VolumeConfig.builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
    volumes1.clear();
    volumes1.add(volumeConfig1);
    ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("testing").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
    PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, null, 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(org.eclipse.jkube.kit.config.resource.ResourceConfig) VolumeConfig(org.eclipse.jkube.kit.config.resource.VolumeConfig) Test(org.junit.Test)

Example 5 with VolumeConfig

use of org.eclipse.jkube.kit.config.resource.VolumeConfig in project jkube by eclipse.

the class PodTemplateHandlerTest method podWithInvalidVolumeTypeTemplateHandlerTest.

@Test
public void podWithInvalidVolumeTypeTemplateHandlerTest() {
    // invalid type
    VolumeConfig volumeConfig1 = VolumeConfig.builder().name("test").mounts(mounts).type("hoStPath").path("/test/path").build();
    volumes1.clear();
    volumes1.add(volumeConfig1);
    ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("testing").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
    PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, null, images);
    // Assertion
    assertEquals("test-account", podTemplateSpec.getSpec().getServiceAccountName());
    assertTrue(podTemplateSpec.getSpec().getVolumes().isEmpty());
    assertNotNull(podTemplateSpec.getSpec().getContainers());
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) VolumeConfig(org.eclipse.jkube.kit.config.resource.VolumeConfig) Test(org.junit.Test)

Aggregations

VolumeConfig (org.eclipse.jkube.kit.config.resource.VolumeConfig)15 ResourceConfig (org.eclipse.jkube.kit.config.resource.ResourceConfig)7 Test (org.junit.Test)7 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)6 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)6 GroupArtifactVersion (org.eclipse.jkube.kit.config.resource.GroupArtifactVersion)6 Before (org.junit.Before)6 ArrayList (java.util.ArrayList)5 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)3 Volume (io.fabric8.kubernetes.api.model.Volume)1 VolumeMount (io.fabric8.kubernetes.api.model.VolumeMount)1 VolumeMountBuilder (io.fabric8.kubernetes.api.model.VolumeMountBuilder)1 VolumeType (org.eclipse.jkube.kit.config.resource.VolumeType)1