use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class MicronautGeneratorTest method customize_webPortIsFirst.
@Test
public void customize_webPortIsFirst() {
// Given
when(ctx.getProject().getCompileClassPathElements()).thenReturn(Collections.emptyList());
when(ctx.getProject().getOutputDirectory()).thenReturn(new File("MOCK"));
// When
final List<ImageConfiguration> result = micronautGenerator.customize(new ArrayList<>(), false);
// Then
assertThat(result).singleElement().extracting(ImageConfiguration::getBuildConfiguration).extracting(BuildConfiguration::getPorts).asList().containsExactly("8080", "8778", "9779");
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class KubernetesExtensionTest method images_withMapListClosure_shouldSetImagesUsingConfigObjectParsing.
@Test
public void images_withMapListClosure_shouldSetImagesUsingConfigObjectParsing() {
// Given
final KubernetesExtension extension = new TestKubernetesExtension();
// When
extension.images(new Closure<Void>(extension) {
public Void doCall(Object... args) {
setProperty("image1", new Closure<Void>(new ImageConfiguration()) {
public Void doCall(Object... args) {
setProperty("name", "closure/image1:name");
return null;
}
});
setProperty("image2", new Closure<Void>(new ImageConfiguration()) {
public Void doCall(Object... args) {
setProperty("name", "closure/image2:name");
return null;
}
});
return null;
}
});
// Then
assertThat(extension.images).hasSize(2).extracting(ImageConfiguration::getName).containsExactly("closure/image1:name", "closure/image2:name");
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class DefaultServiceEnricherTest method serviceImageLabelEnrichment.
@Test
public void serviceImageLabelEnrichment() throws Exception {
ImageConfiguration imageConfigurationWithLabels = ImageConfiguration.builder().name("test-label").alias("test").build();
final TreeMap<String, Object> config = new TreeMap<>();
config.put("type", "LoadBalancer");
new Expectations() {
{
Configuration configuration = Configuration.builder().image(imageConfigurationWithLabels).processorConfig(new ProcessorConfig(null, null, Collections.singletonMap("jkube-service", config))).build();
groupArtifactVersion.getSanitizedArtifactId();
result = "jkube-service";
context.getConfiguration();
result = configuration;
imageConfigurationWithLabels.getBuildConfiguration();
result = BuildConfiguration.builder().labels(Collections.singletonMap("jkube.generator.service.ports", "9090")).ports(Arrays.asList("80", "53/UDP")).build();
}
};
String json = enrich();
assertPort(json, 0, 9090, 9090, "http", "TCP");
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class ContainerHandlerTest method containerPortsWithoutPortTest.
@Test
public void containerPortsWithoutPortTest() {
ContainerHandler handler = createContainerHandler(project);
// without Ports
final BuildConfiguration buildImageConfiguration2 = BuildConfiguration.builder().from("fabric8/maven:latest").cleanup("try").compressionString("gzip").build();
ImageConfiguration imageConfiguration2 = ImageConfiguration.builder().name("test").alias("test-app").build(buildImageConfiguration2).registry("docker.io").build();
images.clear();
images.add(imageConfiguration2);
containers = handler.getContainers(config, images);
assertNull(containers.get(0).getPorts());
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class ContainerHandlerTest method getContainersWithAliasTest.
@Test
public void getContainersWithAliasTest() {
project.setArtifactId("test-artifact");
project.setGroupId("test-group");
ports.add("8080");
ports.add("9090");
tags.add("latest");
tags.add("test");
ContainerHandler handler = new ContainerHandler(project.getProperties(), new GroupArtifactVersion("test-group", "test-artifact", "0"), probeHandler);
// 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("docker.io/test/test-app:1.2").alias("test-app").build(buildImageConfiguration).registry("docker-alternate.io").build();
images.clear();
images.add(imageConfiguration);
containers = handler.getContainers(config, images);
assertNotNull(containers);
assertEquals("test-app", containers.get(0).getName());
assertEquals("docker.io/test/test-app:1.2", containers.get(0).getImage());
assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
Aggregations