Search in sources :

Example 11 with ResourceConfig

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

the class BaseEnricherGetReplicaCountTest method withNoListBuilderAndConfiguredResourceConfigShouldReturnResourceConfig.

@Test
public void withNoListBuilderAndConfiguredResourceConfigShouldReturnResourceConfig() {
    // Given
    final ResourceConfig resourceConfig = ResourceConfig.builder().replicas(313373).build();
    // When
    final int result = getReplicaCount(null, resourceConfig, 1337);
    // Then
    assertThat(result).isEqualTo(313373);
}
Also used : ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Example 12 with ResourceConfig

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

the class BaseEnricherGetReplicaCountTest method withNoListBuilderAndEmptyResourceConfigShouldReturnDefault.

@Test
public void withNoListBuilderAndEmptyResourceConfigShouldReturnDefault() {
    // When
    final int result = getReplicaCount(null, new ResourceConfig(), 1337);
    // Then
    assertThat(result).isEqualTo(1337);
}
Also used : ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Example 13 with ResourceConfig

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

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

the class DefaultNamespaceEnricherTest method createWithPropertiesAndUnknownTypeInKubernetesShouldAddNothing.

@Test
public void createWithPropertiesAndUnknownTypeInKubernetesShouldAddNothing() {
    // Given
    Properties properties = new Properties();
    properties.put("jkube.enricher.jkube-namespace.type", "unknown");
    properties.put("jkube.enricher.jkube-namespace.namespace", "example");
    setExpectations(properties, new ResourceConfig());
    final KubernetesListBuilder klb = new KubernetesListBuilder();
    // When
    new DefaultNamespaceEnricher(context).create(PlatformMode.kubernetes, klb);
    // Then
    assertThat(klb.build().getItems()).isEmpty();
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Properties(java.util.Properties) Test(org.junit.Test)

Example 15 with ResourceConfig

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

the class DefaultNamespaceEnricherTest method createWithPropertiesInOpenShiftShouldAddProject.

@Test
public void createWithPropertiesInOpenShiftShouldAddProject() {
    // Given
    Properties properties = new Properties();
    properties.put("jkube.enricher.jkube-namespace.namespace", "example");
    setExpectations(properties, new ResourceConfig());
    final KubernetesListBuilder klb = new KubernetesListBuilder();
    // When
    new DefaultNamespaceEnricher(context).create(PlatformMode.openshift, klb);
    // Then
    assertThat(klb.build().getItems()).hasSize(1);
    assertThat(klb.build().getItems().iterator().next()).isInstanceOf(Project.class).hasFieldOrPropertyWithValue("metadata.name", "example").hasFieldOrPropertyWithValue("status.phase", "Active");
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Properties(java.util.Properties) 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