Search in sources :

Example 6 with VolumeConfig

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

the class PodTemplateHandler method getVolumes.

private List<Volume> getVolumes(ResourceConfig config) {
    List<VolumeConfig> volumeConfigs = config.getVolumes();
    List<Volume> ret = new ArrayList<>();
    if (volumeConfigs != null) {
        for (VolumeConfig volumeConfig : volumeConfigs) {
            VolumeType type = VolumeType.typeFor(volumeConfig.getType());
            if (type != null) {
                ret.add(type.fromConfig(volumeConfig));
            }
        }
    }
    return ret;
}
Also used : VolumeType(org.eclipse.jkube.kit.config.resource.VolumeType) Volume(io.fabric8.kubernetes.api.model.Volume) ArrayList(java.util.ArrayList) VolumeConfig(org.eclipse.jkube.kit.config.resource.VolumeConfig)

Example 7 with VolumeConfig

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

the class ContainerHandler method getVolumeMounts.

private List<VolumeMount> getVolumeMounts(ResourceConfig config) {
    List<VolumeConfig> volumeConfigs = config.getVolumes();
    List<VolumeMount> ret = new ArrayList<>();
    if (volumeConfigs != null) {
        for (VolumeConfig volumeConfig : volumeConfigs) {
            List<String> mounts = volumeConfig.getMounts();
            if (mounts != null) {
                for (String mount : mounts) {
                    ret.add(new VolumeMountBuilder().withName(volumeConfig.getName()).withMountPath(mount).withReadOnly(false).build());
                }
            }
        }
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) VolumeMount(io.fabric8.kubernetes.api.model.VolumeMount) VolumeMountBuilder(io.fabric8.kubernetes.api.model.VolumeMountBuilder) VolumeConfig(org.eclipse.jkube.kit.config.resource.VolumeConfig)

Example 8 with VolumeConfig

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

the class ContainerHandlerTest method getVolumeMountWithoutNameTest.

@Test
public void getVolumeMountWithoutNameTest() {
    ContainerHandler handler = createContainerHandler(project);
    images.clear();
    images.add(imageConfiguration1);
    List<String> mounts = new ArrayList<>();
    mounts.add("/path/etc");
    // volume config without name but with mount
    VolumeConfig volumeConfig2 = VolumeConfig.builder().mounts(mounts).build();
    volumes1.clear();
    volumes1.add(volumeConfig2);
    ResourceConfig config2 = ResourceConfig.builder().volumes(volumes1).build();
    containers = handler.getContainers(config2, images);
    assertEquals(1, containers.get(0).getVolumeMounts().size());
    assertNull(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 9 with VolumeConfig

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

the class ContainerHandlerTest method getVolumeMountWithMultipleMountTest.

@Test
public void getVolumeMountWithMultipleMountTest() {
    ContainerHandler handler = createContainerHandler(project);
    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 = VolumeConfig.builder().name("test").mounts(mounts).build();
    volumes1.clear();
    volumes1.add(volumeConfig4);
    ResourceConfig config4 = 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(org.eclipse.jkube.kit.config.resource.ResourceConfig) VolumeConfig(org.eclipse.jkube.kit.config.resource.VolumeConfig) Test(org.junit.Test)

Example 10 with VolumeConfig

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

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 = 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);
    daemonSetHandler = new DaemonSetHandler(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)

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