Search in sources :

Example 56 with ResourceConfig

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

the class DeploymentConfigHandlerTest method get_withNoImagesAndNoControllerName_shouldThrowException.

@Test
public void get_withNoImagesAndNoControllerName_shouldThrowException() {
    // Given
    final ResourceConfig resourceConfig = resourceConfigBuilder.build();
    final List<ImageConfiguration> images = Collections.emptyList();
    // When
    final IllegalArgumentException result = assertThrows(IllegalArgumentException.class, () -> deploymentConfigHandler.get(resourceConfig, images));
    // Then
    assertThat(result).hasMessage("No controller name is specified!");
}
Also used : ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Example 57 with ResourceConfig

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

the class DeploymentConfigHandlerTest method get_withImages_shouldReturnConfigWithContainers.

@Test
public void get_withImages_shouldReturnConfigWithContainers() {
    // Given
    final ResourceConfig resourceConfig = resourceConfigBuilder.controllerName("controller").build();
    final List<ImageConfiguration> images = Arrays.asList(ImageConfiguration.builder().name("busybox").build(BuildConfiguration.builder().build()).build(), ImageConfiguration.builder().name("jkubeio/java:latest").build(BuildConfiguration.builder().build()).build());
    // When
    final DeploymentConfig result = deploymentConfigHandler.get(resourceConfig, images);
    // Then
    assertThat(result).hasFieldOrPropertyWithValue("metadata.name", "controller").extracting("spec.template.spec.containers").asList().hasSize(2).extracting("image", "name").containsExactly(new Tuple("busybox:latest", "g-a"), new Tuple("jkubeio/java:latest", "jkubeio-a"));
}
Also used : ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Tuple(org.assertj.core.groups.Tuple) Test(org.junit.Test)

Example 58 with ResourceConfig

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

the class DeploymentHandlerTest method deploymentTemplateHandlerTest.

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

Example 59 with ResourceConfig

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

the class DeploymentHandlerTest method deploymentTemplateHandlerWithInvalidNameTest.

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

Example 60 with ResourceConfig

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

the class DeploymentHandlerTest method deploymentTemplateHandlerWithoutControllerTest.

@Test(expected = IllegalArgumentException.class)
public void deploymentTemplateHandlerWithoutControllerTest() {
    // without controller name
    ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
    deploymentHandler.get(config, images);
}
Also used : 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