Search in sources :

Example 46 with ResourceConfig

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

the class DefaultNamespaceEnricherTest method testNoNamespaceConfiguredInMetadataIfNoPropertyProvided.

@Test
public void testNoNamespaceConfiguredInMetadataIfNoPropertyProvided() {
    // Given
    setExpectations(new Properties(), new ResourceConfig());
    final KubernetesListBuilder kubernetesListBuilder = getKubernetesListBuilder();
    // When
    new DefaultNamespaceEnricher(context).enrich(PlatformMode.kubernetes, kubernetesListBuilder);
    // Then
    assertThat(kubernetesListBuilder.build().getItems()).hasSize(2);
    assertThat(kubernetesListBuilder.build().getItems().get(0).getMetadata().getNamespace()).isNull();
    assertThat(kubernetesListBuilder.build().getItems().get(1).getMetadata().getNamespace()).isNull();
}
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 47 with ResourceConfig

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

the class DefaultNamespaceEnricherTest method enrichWithOpenShiftProjectFragmentWithNoStatus.

@Test
public void enrichWithOpenShiftProjectFragmentWithNoStatus() {
    // Given
    setExpectations(new Properties(), new ResourceConfig());
    final KubernetesListBuilder kubernetesListBuilder = new KubernetesListBuilder();
    kubernetesListBuilder.addToItems(new ProjectBuilder().withNewMetadata().withName("test-jkube").endMetadata().build());
    // When
    new DefaultNamespaceEnricher(context).enrich(PlatformMode.openshift, kubernetesListBuilder);
    // Then
    assertThat(kubernetesListBuilder.build().getItems()).hasSize(1);
    assertThat(kubernetesListBuilder.build().getItems().iterator().next()).hasFieldOrPropertyWithValue("metadata.name", "test-jkube");
    assertNull(kubernetesListBuilder.build().getItems().get(0).getMetadata().getNamespace());
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ProjectBuilder(io.fabric8.openshift.api.model.ProjectBuilder) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Properties(java.util.Properties) Test(org.junit.Test)

Example 48 with ResourceConfig

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

the class DefaultNamespaceEnricherTest method setNamespaceInResourceConfig.

private void setNamespaceInResourceConfig(String namespace) {
    ResourceConfig resourceConfig = ResourceConfig.builder().namespace(namespace).build();
    setExpectations(new Properties(), resourceConfig);
}
Also used : ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Properties(java.util.Properties)

Example 49 with ResourceConfig

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

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

the class ContainerHandlerTest method getVolumeMountWithEmptyVolumeTest.

@Test
public void getVolumeMountWithEmptyVolumeTest() {
    ContainerHandler handler = createContainerHandler(project);
    images.clear();
    images.add(imageConfiguration1);
    // empty volume
    ResourceConfig config5 = ResourceConfig.builder().volumes(volumes2).build();
    containers = handler.getContainers(config5, images);
    assertTrue(containers.get(0).getVolumeMounts().isEmpty());
}
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