use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class ContainerHandlerTest method registryHandling.
@Test
public void registryHandling() {
// container name with alias
final BuildConfiguration buildImageConfiguration = BuildConfiguration.builder().build();
String[] testData = { "docker.io/test/test-app:1.2", "docker-alternate.io", null, null, "docker.io/test/test-app:1.2", "test/test-app:1.2", "docker-image-config.io", "docker-pull.io", "docker-default.io", "docker-image-config.io/test/test-app:1.2", "test/test-app", null, "docker-pull.io", "docker-default.io", "docker-pull.io/test/test-app:latest", "test/test-app", null, null, "docker-default.io", "docker-default.io/test/test-app:latest" };
for (int i = 0; i < testData.length; i += 5) {
JavaProject testProject = JavaProject.builder().properties(new Properties()).build();
Properties testProps = new Properties();
if (testData[i + 2] != null) {
testProps.put("jkube.docker.pull.registry", testData[i + 2]);
}
if (testData[i + 3] != null) {
testProps.put("jkube.docker.registry", testData[i + 3]);
}
Properties properties = testProject.getProperties();
properties.putAll(testProps);
testProject.setProperties(properties);
ContainerHandler handler = createContainerHandler(testProject);
// container name with alias
ImageConfiguration imageConfiguration = ImageConfiguration.builder().build(buildImageConfiguration).name(testData[i]).registry(testData[i + 1]).build();
images.clear();
images.add(imageConfiguration);
containers = handler.getContainers(config, images);
assertNotNull(containers);
assertEquals(testData[i + 4], containers.get(0).getImage());
}
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class ContainerHandlerTest method getContainerTestWithUser.
@Test
public void getContainerTestWithUser() {
project.setArtifactId("test-artifact");
project.setGroupId("test-group");
ports.add("8080");
ports.add("9090");
tags.add("latest");
tags.add("test");
// container name with user and image with tag
ContainerHandler handler = new ContainerHandler(project.getProperties(), new GroupArtifactVersion("test-group", "test-artifact", "0"), probeHandler);
final BuildConfiguration buildImageConfiguration = BuildConfiguration.builder().ports(ports).from("fabric8/").cleanup("try").tags(tags).compressionString("gzip").dockerFile("testFile").build();
ImageConfiguration imageConfiguration = ImageConfiguration.builder().name("user/test:latest").build(buildImageConfiguration).registry("docker.io").build();
images.clear();
images.add(imageConfiguration);
containers = handler.getContainers(config, images);
assertNotNull(containers);
assertEquals("user-test-artifact", containers.get(0).getName());
assertEquals("docker.io/user/test:latest", containers.get(0).getImage());
assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class DaemonSetHandlerTest method before.
@Before
public void before() {
// volume config with name and multiple mount
mounts.add("/path/system");
mounts.add("/path/sys");
ports.add("8080");
ports.add("9090");
tags.add("latest");
tags.add("test");
VolumeConfig volumeConfig1 = VolumeConfig.builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
volumes1.add(volumeConfig1);
// container name with alias
final BuildConfiguration buildImageConfiguration = BuildConfiguration.builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compressionString("gzip").build();
ImageConfiguration imageConfiguration = ImageConfiguration.builder().name("test").alias("test-app").build(buildImageConfiguration).registry("docker.io").build();
images.add(imageConfiguration);
daemonSetHandler = new DaemonSetHandler(new PodTemplateHandler(new ContainerHandler(project.getProperties(), new GroupArtifactVersion("g", "a", "v"), probeHandler)));
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration 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();
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class DeploymentConfigHandlerTest method get_withNoImagesAndNoControllerName_shouldThrowException.
@Test
public void get_withNoImagesAndNoControllerName_shouldThrowException() {
// Given
final ResourceConfig resourceConfig = resourceConfigBuilder.build();
final List<ImageConfiguration> images = Collections.emptyList();
// When
final IllegalArgumentException result = assertThrows(IllegalArgumentException.class, () -> deploymentConfigHandler.get(resourceConfig, images));
// Then
assertThat(result).hasMessage("No controller name is specified!");
}
Aggregations