Search in sources :

Example 61 with ResourceConfig

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

the class JobHandlerTest method daemonTemplateHandlerWithInvalidNameTest.

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

Example 62 with ResourceConfig

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

the class PodTemplateHandlerTest method podWithoutEmptyTypeTemplateHandlerTest.

@Test
public void podWithoutEmptyTypeTemplateHandlerTest() {
    // empty type
    VolumeConfig volumeConfig1 = VolumeConfig.builder().name("test").mounts(mounts).build();
    volumes1.clear();
    volumes1.add(volumeConfig1);
    ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("testing").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
    PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, null, images);
    // Assertion
    assertEquals("test-account", podTemplateSpec.getSpec().getServiceAccountName());
    assertTrue(podTemplateSpec.getSpec().getVolumes().isEmpty());
    assertNotNull(podTemplateSpec.getSpec().getContainers());
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) VolumeConfig(org.eclipse.jkube.kit.config.resource.VolumeConfig) Test(org.junit.Test)

Example 63 with ResourceConfig

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

the class PodTemplateHandlerTest method podWithEmotyVolumeTemplateHandlerTest.

@Test
public void podWithEmotyVolumeTemplateHandlerTest() {
    // Pod with empty Volume Config and wihtout ServiceAccount
    ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("testing").replicas(5).volumes(volumes1).build();
    PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, null, images);
    // Assertion
    assertNull(podTemplateSpec.getSpec().getServiceAccountName());
    assertTrue(podTemplateSpec.getSpec().getVolumes().isEmpty());
    assertNotNull(podTemplateSpec.getSpec().getContainers());
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Example 64 with ResourceConfig

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

the class IngressEnricher method create.

@Override
public void create(PlatformMode platformMode, final KubernetesListBuilder listBuilder) {
    ResourceConfig resourceConfig = getConfiguration().getResource();
    Boolean shouldCreateIngress = getValueFromConfig(CREATE_EXTERNAL_URLS, false);
    if (shouldCreateIngress.equals(Boolean.FALSE)) {
        return;
    }
    if (platformMode == PlatformMode.kubernetes) {
        listBuilder.accept(new TypedVisitor<ServiceBuilder>() {

            @Override
            public void visit(ServiceBuilder serviceBuilder) {
                HasMetadata generatedIngress = generateIngressWithConfiguredApiVersion(serviceBuilder, listBuilder, resourceConfig);
                if (generatedIngress != null) {
                    listBuilder.addToItems(generatedIngress);
                }
            }
        });
    }
}
Also used : HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder)

Example 65 with ResourceConfig

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

the class ReplicaSetHandlerTest method replicaSetHandlerWithInvalidNameTest.

@Test(expected = IllegalArgumentException.class)
public void replicaSetHandlerWithInvalidNameTest() {
    // with invalid controller name
    ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("TesTing").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
    replicaSetHandler.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