use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class ContainerHandlerTest method imagePullPolicyWithoutPolicySetTest.
@Test
public void imagePullPolicyWithoutPolicySetTest() {
// project with version and ending in SNAPSHOT
project1.setVersion("3.5-SNAPSHOT");
// project with version but not ending in SNAPSHOT
project2.setVersion("3.5-NEW");
// creating container Handler for two
ContainerHandler handler1 = new ContainerHandler(project1.getProperties(), new GroupArtifactVersion("g", "a", "3.5-SNAPSHOT"), probeHandler);
ContainerHandler handler2 = new ContainerHandler(project2.getProperties(), new GroupArtifactVersion("g", "a", "3.5-NEW"), probeHandler);
// project without version
ContainerHandler handler3 = createContainerHandler(project);
images.clear();
images.add(imageConfiguration1);
// check if policy is not set then both in case of version is set or not
ResourceConfig config2 = ResourceConfig.builder().imagePullPolicy("").build();
containers = handler1.getContainers(config2, images);
assertEquals("PullAlways", containers.get(0).getImagePullPolicy());
containers = handler2.getContainers(config2, images);
assertEquals("", containers.get(0).getImagePullPolicy());
containers = handler3.getContainers(config2, images);
assertEquals("", containers.get(0).getImagePullPolicy());
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class ContainerHandlerTest method getVolumeMountWithMultipleMountTest.
@Test
public void getVolumeMountWithMultipleMountTest() {
ContainerHandler handler = createContainerHandler(project);
images.clear();
images.add(imageConfiguration1);
List<String> mounts = new ArrayList<>();
mounts.add("/path/etc");
// volume config with name and multiple mount
mounts.add("/path/system");
mounts.add("/path/sys");
VolumeConfig volumeConfig4 = VolumeConfig.builder().name("test").mounts(mounts).build();
volumes1.clear();
volumes1.add(volumeConfig4);
ResourceConfig config4 = ResourceConfig.builder().volumes(volumes1).build();
containers = handler.getContainers(config4, images);
assertEquals(3, containers.get(0).getVolumeMounts().size());
for (int i = 0; i <= 2; i++) assertEquals("test", containers.get(0).getVolumeMounts().get(i).getName());
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class DaemonSetHandlerTest method daemonTemplateHandlerTest.
@Test
public void daemonTemplateHandlerTest() {
ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("testing").serviceAccount("test-account").volumes(volumes1).build();
DaemonSet daemonSet = daemonSetHandler.get(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());
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class DaemonSetHandlerTest method daemonTemplateHandlerWithInvalidNameTest.
@Test(expected = IllegalArgumentException.class)
public void daemonTemplateHandlerWithInvalidNameTest() {
// with invalid controller name
ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("TesTing").serviceAccount("test-account").volumes(volumes1).build();
daemonSetHandler.get(config, images);
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class DeploymentConfigHandlerTest method getPodTemplateSpec_withNoImages_shouldReturnPodTemplateSpecWithNoContainers.
@Test
public void getPodTemplateSpec_withNoImages_shouldReturnPodTemplateSpecWithNoContainers() {
// Given
final ResourceConfig resourceConfig = resourceConfigBuilder.controllerName("controller").build();
final List<ImageConfiguration> images = Collections.emptyList();
// When
final PodTemplateSpec result = deploymentConfigHandler.getPodTemplateSpec(resourceConfig, images);
// Then
assertThat(result).extracting("spec.containers").asList().isEmpty();
}
Aggregations