use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class ConfigHelperTest method initImageConfiguration_withSimpleImageConfiguration_shouldReturnImageConfiguration.
@Test
public void initImageConfiguration_withSimpleImageConfiguration_shouldReturnImageConfiguration() {
// Given
ImageConfiguration dummyImageConfiguration = ImageConfiguration.builder().name("foo/bar:latest").build(BuildConfiguration.builder().from("foobase:latest").build()).build();
List<ImageConfiguration> images = new ArrayList<>();
images.add(dummyImageConfiguration);
when(jKubeConfiguration.getBasedir()).thenReturn(new File("dummydir"));
when(imageConfigResolver.resolve(dummyImageConfiguration, javaProject)).thenReturn(images);
// When
List<ImageConfiguration> resolvedImages = ConfigHelper.initImageConfiguration("1.12", new Date(), images, imageConfigResolver, logger, null, configs -> configs, jKubeConfiguration);
// Then
assertThat(resolvedImages).isNotNull().hasSize(1).element(0).isEqualTo(dummyImageConfiguration);
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class GeneratorManagerTest method generate_withTestGenerator_shouldProcessImages.
@Test
public void generate_withTestGenerator_shouldProcessImages() {
// Given
final List<ImageConfiguration> images = Collections.singletonList(new ImageConfiguration());
// When
final List<ImageConfiguration> result = GeneratorManager.generate(images, generatorContext, false);
// Then
assertThat(result).isNotSameAs(images).hasSize(1).extracting(ImageConfiguration::getName).contains("processed-by-test");
// @formatter:off
new Verifications() {
{
logger.info("Running generator %s", "fake-generator");
times = 1;
}
};
// @formatter:on
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class DockerHealthCheckEnricherTest method testEnrichFromSingleImage.
@Test
public void testEnrichFromSingleImage() throws Exception {
// Setup mock behaviour
new Expectations() {
{
List<ImageConfiguration> images = Arrays.asList(ImageConfiguration.builder().alias("myImage").build(BuildConfiguration.builder().healthCheck(HealthCheckConfiguration.builder().mode(HealthCheckMode.cmd).cmd(Arguments.builder().shell("/bin/check").build()).timeout("1s").interval("1h1s").retries(3).build()).build()).build(), ImageConfiguration.builder().alias("myImage2").build(BuildConfiguration.builder().healthCheck(HealthCheckConfiguration.builder().mode(HealthCheckMode.cmd).cmd(Arguments.builder().shell("/xxx/check").build()).timeout("3s").interval("3h1s").retries(9).build()).build()).build());
context.getConfiguration();
result = Configuration.builder().images(images).build();
}
};
KubernetesListBuilder builder = createDeployment("myImage");
DockerHealthCheckEnricher enricher = new DockerHealthCheckEnricher(context);
enricher.create(PlatformMode.kubernetes, builder);
KubernetesList list = builder.build();
assertEquals(1, list.getItems().size());
assertHealthCheckMatching(builder.build().getItems().get(0), "livenessProbe", "/bin/check", 1, 3601, 3);
assertHealthCheckMatching(builder.build().getItems().get(0), "readinessProbe", "/bin/check", 1, 3601, 3);
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class DockerHealthCheckEnricherTest method testInvalidHealthCheck.
@Test
public void testInvalidHealthCheck() throws Exception {
// Setup mock behaviour
new Expectations() {
{
final ImageConfiguration image = ImageConfiguration.builder().alias("myImage").build(BuildConfiguration.builder().healthCheck(HealthCheckConfiguration.builder().mode(HealthCheckMode.none).build()).build()).build();
context.getConfiguration();
result = Configuration.builder().image(image).build();
}
};
KubernetesListBuilder builder = createDeployment("myImage");
DockerHealthCheckEnricher enricher = new DockerHealthCheckEnricher(context);
enricher.create(PlatformMode.kubernetes, builder);
KubernetesList list = builder.build();
assertEquals(1, list.getItems().size());
assertNoProbes(list.getItems().get(0));
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class DockerHealthCheckEnricherTest method testEnrichFromDoubleImage.
@Test
public void testEnrichFromDoubleImage() throws Exception {
// Setup mock behaviour
new Expectations() {
{
List<ImageConfiguration> images = Arrays.asList(ImageConfiguration.builder().alias("myImage").build(BuildConfiguration.builder().healthCheck(HealthCheckConfiguration.builder().mode(HealthCheckMode.cmd).cmd(Arguments.builder().shell("/bin/check").build()).timeout("1s").interval("1h1s").retries(3).build()).build()).build(), ImageConfiguration.builder().alias("myImage2").build(BuildConfiguration.builder().healthCheck(HealthCheckConfiguration.builder().mode(HealthCheckMode.cmd).cmd(Arguments.builder().shell("/xxx/check").build()).timeout("3s").interval("3h1s").retries(9).build()).build()).build());
context.getConfiguration();
result = Configuration.builder().images(images).build();
context.getProcessingInstructions();
result = Collections.singletonMap("FABRIC8_GENERATED_CONTAINERS", "myImage,myImage2");
}
};
KubernetesListBuilder builder = addDeployment(createDeployment("myImage"), "myImage2");
DockerHealthCheckEnricher enricher = new DockerHealthCheckEnricher(context);
enricher.create(PlatformMode.kubernetes, builder);
KubernetesList list = builder.build();
assertEquals(2, list.getItems().size());
assertHealthCheckMatching(builder.build().getItems().get(0), "livenessProbe", "/bin/check", 1, 3601, 3);
assertHealthCheckMatching(builder.build().getItems().get(0), "readinessProbe", "/bin/check", 1, 3601, 3);
assertHealthCheckMatching(builder.build().getItems().get(1), "livenessProbe", "/xxx/check", 3, 10801, 9);
assertHealthCheckMatching(builder.build().getItems().get(1), "readinessProbe", "/xxx/check", 3, 10801, 9);
}
Aggregations