Search in sources :

Example 66 with ResourceConfig

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

the class ReplicationControllerHandlerTest method replicationControllerHandlerWithInvalidNameTest.

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

Example 67 with ResourceConfig

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

the class StatefulSetHandlerTest method statefulSetHandlerWithoutControllerTest.

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

Example 68 with ResourceConfig

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

the class StatefulSetHandlerTest method statefulSetHandlerWithInvalidNameTest.

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

Example 69 with ResourceConfig

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

the class DefaultControllerEnricher method create.

@Override
public void create(PlatformMode platformMode, KubernetesListBuilder builder) {
    final String name = getConfig(Config.NAME, JKubeProjectUtil.createDefaultResourceName(getContext().getGav().getSanitizedArtifactId()));
    ResourceConfig providedResourceConfig = Optional.ofNullable(getConfiguration().getResource()).orElse(ResourceConfig.builder().build());
    ResourceConfig config = ResourceConfig.toBuilder(providedResourceConfig).controllerName(getControllerName(providedResourceConfig, name)).imagePullPolicy(getImagePullPolicy(providedResourceConfig, getConfig(Config.PULL_POLICY))).replicas(getReplicaCount(builder, providedResourceConfig, Configs.asInt(getConfig(Config.REPLICA_COUNT)))).restartPolicy(providedResourceConfig.getRestartPolicy()).build();
    final List<ImageConfiguration> images = getImages();
    // At least one image must be present, otherwise the resulting config will be invalid
    if (!KubernetesResourceUtil.checkForKind(builder, POD_CONTROLLER_KINDS) && !images.isEmpty()) {
        final ControllerHandler<? extends HasMetadata> ch = getContext().getHandlerHub().getHandlerFor(fromType(getConfig(Config.TYPE)));
        final HasMetadata resource = ch.get(config, images);
        log.info("Adding a default %s", resource.getKind());
        builder.addToItems(resource);
        setProcessingInstruction(FABRIC8_GENERATED_CONTAINERS, getContainersFromPodSpec(ch.getPodTemplateSpec(config, images)));
    }
}
Also used : HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig)

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