use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class OpenShiftBuildServiceUtilsTest method createBuildArchive_withIOExceptionOnCreateDockerBuildArchive_shouldThrowException.
@Test
public void createBuildArchive_withIOExceptionOnCreateDockerBuildArchive_shouldThrowException() throws Exception {
// Given
when(jKubeServiceHub.getDockerServiceHub().getArchiveService().createDockerBuildArchive(any(ImageConfiguration.class), any(JKubeConfiguration.class), any(ArchiverCustomizer.class))).thenThrow(new IOException("Mocked Exception"));
// When
final JKubeServiceException result = assertThrows(JKubeServiceException.class, () -> createBuildArchive(jKubeServiceHub, imageConfiguration));
// Then
assertThat(result).hasMessage("Unable to create the build archive").getCause().hasMessage("Mocked Exception");
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class OpenshiftBuildServiceIntegrationTest method testDockerBuildFromExt.
@Test
public void testDockerBuildFromExt() throws Exception {
final BuildServiceConfig dockerConfig = withBuildServiceConfig(BuildServiceConfig.builder().buildDirectory(baseDir).buildRecreateMode(BuildRecreateMode.none).s2iBuildNameSuffix("-docker").jKubeBuildStrategy(JKubeBuildStrategy.docker).resourceConfig(mockedResourceConfig).build());
final WebServerEventCollector collector = prepareMockServer(dockerConfig, true, false, false);
OpenshiftBuildService service = new OpenshiftBuildService(jKubeServiceHub);
Map<String, String> fromExt = ImmutableMap.of("name", "app:1.2-1", "kind", "ImageStreamTag", "namespace", "my-project");
ImageConfiguration fromExtImage = ImageConfiguration.builder().name(projectName).build(BuildConfiguration.builder().fromExt(fromExt).nocache(Boolean.TRUE).build()).build();
service.build(fromExtImage);
assertTrue(mockServer.getOpenShiftMockServer().getRequestCount() > 8);
collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
assertEquals("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-docker\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"app:1.2-1\",\"namespace\":\"my-project\"},\"noCache\":true},\"type\":\"Docker\"}}}", collector.getBodies().get(1));
collector.assertEventsNotRecorded("patch-build-config");
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class ContainerHandler method getContainers.
List<Container> getContainers(ResourceConfig config, List<ImageConfiguration> images) {
List<Container> ret = new ArrayList<>();
for (ImageConfiguration imageConfig : images) {
if (imageConfig.getBuildConfiguration() != null) {
Probe livenessProbe = probeHandler.getProbe(config.getLiveness());
Probe readinessProbe = probeHandler.getProbe(config.getReadiness());
Container container = new ContainerBuilder().withName(KubernetesResourceUtil.extractContainerName(this.groupArtifactVersion, imageConfig)).withImage(getImageName(imageConfig)).withImagePullPolicy(getImagePullPolicy(config)).withEnv(getEnvVars(config)).withSecurityContext(createSecurityContext(config)).withPorts(getContainerPorts(imageConfig)).withVolumeMounts(getVolumeMounts(config)).withLivenessProbe(livenessProbe).withReadinessProbe(readinessProbe).build();
ret.add(container);
}
}
return ret;
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class AbstractDockerMojo method buildAndTag.
private void buildAndTag(List<ImageConfiguration> imageConfigs) throws MojoExecutionException {
try {
// TODO need to refactor d-m-p to avoid this call
EnvUtil.storeTimestamp(getBuildTimestampFile(project.getBuild().getDirectory(), DOCKER_BUILD_TIMESTAMP), getBuildTimestamp(getPluginContext(), CONTEXT_KEY_BUILD_TIMESTAMP, project.getBuild().getDirectory(), DOCKER_BUILD_TIMESTAMP));
jkubeServiceHub.getBuildService().build(imageConfigs.toArray(new ImageConfiguration[0]));
} catch (Exception ex) {
throw new MojoExecutionException("Failed to execute the build", ex);
}
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class WatcherManagerTest method watch_withTestWatcher_shouldMutateImages.
@Test
public void watch_withTestWatcher_shouldMutateImages() throws Exception {
// Given
final List<ImageConfiguration> images = Collections.singletonList(new ImageConfiguration());
// When
WatcherManager.watch(images, null, Collections.emptyList(), watcherContext);
// Then
assertThat(images).hasSize(1).extracting(ImageConfiguration::getName).contains("processed-by-test");
// @formatter:off
new Verifications() {
{
logger.info("Running watcher %s", "fake-watcher");
times = 1;
}
};
// @formatter:on
}
Aggregations