Search in sources :

Example 31 with ResourceConfig

use of io.fabric8.maven.core.config.ResourceConfig in project fabric8-maven-plugin by fabric8io.

the class DaemonSetHandlerTest method daemonTemplateHandlerTest.

@Test
public void daemonTemplateHandlerTest() {
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    DaemonSetHandler daemonSetHandler = new DaemonSetHandler(podTemplateHandler);
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withServiceAccount("test-account").volumes(volumes1).build();
    DaemonSet daemonSet = daemonSetHandler.getDaemonSet(config, images);
    // Assertion
    assertNotNull(daemonSet.getSpec());
    assertNotNull(daemonSet.getMetadata());
    assertNotNull(daemonSet.getSpec().getTemplate());
    assertEquals("testing", daemonSet.getMetadata().getName());
    assertEquals("test-account", daemonSet.getSpec().getTemplate().getSpec().getServiceAccountName());
    assertFalse(daemonSet.getSpec().getTemplate().getSpec().getVolumes().isEmpty());
    assertEquals("test", daemonSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getName());
    assertEquals("/test/path", daemonSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getHostPath().getPath());
    assertNotNull(daemonSet.getSpec().getTemplate().getSpec().getContainers());
}
Also used : DaemonSet(io.fabric8.kubernetes.api.model.extensions.DaemonSet) ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) Test(org.junit.Test)

Example 32 with ResourceConfig

use of io.fabric8.maven.core.config.ResourceConfig in project fabric8-maven-plugin by fabric8io.

the class DaemonSetHandlerTest method daemonTemplateHandlerWithInvalidNameTest.

@Test(expected = IllegalArgumentException.class)
public void daemonTemplateHandlerWithInvalidNameTest() {
    // invalid controller name
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    DaemonSetHandler daemonSetHandler = new DaemonSetHandler(podTemplateHandler);
    // with invalid controller name
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("TesTing").withServiceAccount("test-account").volumes(volumes1).build();
    daemonSetHandler.getDaemonSet(config, images);
}
Also used : ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) Test(org.junit.Test)

Example 33 with ResourceConfig

use of io.fabric8.maven.core.config.ResourceConfig in project fabric8-maven-plugin by fabric8io.

the class DeploymentHandlerTest method deploymentTemplateHandlerWithInvalidNameTest.

@Test(expected = IllegalArgumentException.class)
public void deploymentTemplateHandlerWithInvalidNameTest() {
    // invalid controller name
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    DeploymentHandler deploymentHandler = new DeploymentHandler(podTemplateHandler);
    // with invalid controller name
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("TesTing").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
    deploymentHandler.getDeployment(config, images);
}
Also used : ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) Test(org.junit.Test)

Example 34 with ResourceConfig

use of io.fabric8.maven.core.config.ResourceConfig in project fabric8-maven-plugin by fabric8io.

the class PodTemplateHandler method getVolumes.

private List<Volume> getVolumes(ResourceConfig config) {
    List<VolumeConfig> volumeConfigs = config.getVolumes();
    List<Volume> ret = new ArrayList<>();
    if (volumeConfigs != null) {
        for (VolumeConfig volumeConfig : volumeConfigs) {
            VolumeType type = VolumeType.typeFor(volumeConfig.getType());
            if (type != null) {
                ret.add(type.fromConfig(volumeConfig));
            }
        }
    }
    return ret;
}
Also used : VolumeType(io.fabric8.maven.core.config.VolumeType) ArrayList(java.util.ArrayList) VolumeConfig(io.fabric8.maven.core.config.VolumeConfig)

Aggregations

ResourceConfig (io.fabric8.maven.core.config.ResourceConfig)31 Test (org.junit.Test)29 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)9 ArrayList (java.util.ArrayList)6 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)5 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)2 TypedVisitor (io.fabric8.kubernetes.api.builder.TypedVisitor)1 Container (io.fabric8.kubernetes.api.model.Container)1 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)1 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)1 Job (io.fabric8.kubernetes.api.model.Job)1 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)1 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)1 PodSpecBuilder (io.fabric8.kubernetes.api.model.PodSpecBuilder)1 Probe (io.fabric8.kubernetes.api.model.Probe)1 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)1 VolumeMount (io.fabric8.kubernetes.api.model.VolumeMount)1 VolumeMountBuilder (io.fabric8.kubernetes.api.model.VolumeMountBuilder)1 DaemonSet (io.fabric8.kubernetes.api.model.extensions.DaemonSet)1 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)1