Search in sources :

Example 51 with ResourceConfig

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

the class ContainerHandlerTest method imagePullPolicyWithoutPolicySetTest.

@Test
public void imagePullPolicyWithoutPolicySetTest() {
    // project with version and ending in SNAPSHOT
    project1.setVersion("3.5-SNAPSHOT");
    // project with version but not ending in SNAPSHOT
    project2.setVersion("3.5-NEW");
    // creating container Handler for two
    ContainerHandler handler1 = new ContainerHandler(project1.getProperties(), new GroupArtifactVersion("g", "a", "3.5-SNAPSHOT"), probeHandler);
    ContainerHandler handler2 = new ContainerHandler(project2.getProperties(), new GroupArtifactVersion("g", "a", "3.5-NEW"), probeHandler);
    // project without version
    ContainerHandler handler3 = createContainerHandler(project);
    images.clear();
    images.add(imageConfiguration1);
    // check if policy is not set then both in case of version is set or not
    ResourceConfig config2 = ResourceConfig.builder().imagePullPolicy("").build();
    containers = handler1.getContainers(config2, images);
    assertEquals("PullAlways", containers.get(0).getImagePullPolicy());
    containers = handler2.getContainers(config2, images);
    assertEquals("", containers.get(0).getImagePullPolicy());
    containers = handler3.getContainers(config2, images);
    assertEquals("", containers.get(0).getImagePullPolicy());
}
Also used : GroupArtifactVersion(org.eclipse.jkube.kit.config.resource.GroupArtifactVersion) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Example 52 with ResourceConfig

use of org.eclipse.jkube.kit.config.resource.ResourceConfig 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 53 with ResourceConfig

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

the class DaemonSetHandlerTest method daemonTemplateHandlerTest.

@Test
public void daemonTemplateHandlerTest() {
    ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("testing").serviceAccount("test-account").volumes(volumes1).build();
    DaemonSet daemonSet = daemonSetHandler.get(config, images);
    // Assertion
    assertNotNull(daemonSet.getSpec());
    assertNotNull(daemonSet.getMetadata());
    assertNotNull(daemonSet.getSpec().getTemplate());
    assertEquals("testing", daemonSet.getMetadata().getName());
    assertEquals("test-account", daemonSet.getSpec().getTemplate().getSpec().getServiceAccountName());
    assertFalse(daemonSet.getSpec().getTemplate().getSpec().getVolumes().isEmpty());
    assertEquals("test", daemonSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getName());
    assertEquals("/test/path", daemonSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getHostPath().getPath());
    assertNotNull(daemonSet.getSpec().getTemplate().getSpec().getContainers());
}
Also used : DaemonSet(io.fabric8.kubernetes.api.model.apps.DaemonSet) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Example 54 with ResourceConfig

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

the class DaemonSetHandlerTest method daemonTemplateHandlerWithInvalidNameTest.

@Test(expected = IllegalArgumentException.class)
public void daemonTemplateHandlerWithInvalidNameTest() {
    // with invalid controller name
    ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("TesTing").serviceAccount("test-account").volumes(volumes1).build();
    daemonSetHandler.get(config, images);
}
Also used : ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Example 55 with ResourceConfig

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

the class DeploymentConfigHandlerTest method getPodTemplateSpec_withNoImages_shouldReturnPodTemplateSpecWithNoContainers.

@Test
public void getPodTemplateSpec_withNoImages_shouldReturnPodTemplateSpecWithNoContainers() {
    // Given
    final ResourceConfig resourceConfig = resourceConfigBuilder.controllerName("controller").build();
    final List<ImageConfiguration> images = Collections.emptyList();
    // When
    final PodTemplateSpec result = deploymentConfigHandler.getPodTemplateSpec(resourceConfig, images);
    // Then
    assertThat(result).extracting("spec.containers").asList().isEmpty();
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Aggregations

ResourceConfig (org.eclipse.jkube.kit.config.resource.ResourceConfig)69 Test (org.junit.Test)60 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)17 Properties (java.util.Properties)10 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)9 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)7 VolumeConfig (org.eclipse.jkube.kit.config.resource.VolumeConfig)7 ArrayList (java.util.ArrayList)5 Expectations (mockit.Expectations)5 File (java.io.File)4 IngressRulePathResourceConfig (org.eclipse.jkube.kit.config.resource.IngressRulePathResourceConfig)4 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)3 Service (io.fabric8.kubernetes.api.model.Service)3 IOException (java.io.IOException)3 List (java.util.List)3 Optional (java.util.Optional)3 KitLogger (org.eclipse.jkube.kit.common.KitLogger)3 JKubeServiceHub (org.eclipse.jkube.kit.config.service.JKubeServiceHub)3 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)2 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)2