use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class JarFilesTest method testToJibContainer_defaultBaseImage.
@Test
@Parameters(value = { "8, eclipse-temurin:8-jre", "9, eclipse-temurin:11-jre", "11, eclipse-temurin:11-jre", "13, eclipse-temurin:17-jre", "17, eclipse-temurin:17-jre" })
public void testToJibContainer_defaultBaseImage(int javaVersion, String expectedBaseImage) throws IOException, InvalidImageReferenceException {
when(mockStandardExplodedProcessor.getJavaVersion()).thenReturn(javaVersion);
JibContainerBuilder containerBuilder = JarFiles.toJibContainerBuilder(mockStandardExplodedProcessor, mockJarCommand, mockCommonCliOptions, mockCommonContainerConfigCliOptions, mockLogger);
ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan();
assertThat(buildPlan.getBaseImage()).isEqualTo(expectedBaseImage);
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class JarFilesTest method testToJibContainerBuilder_packagedSpringBoot_basicInfo.
@Test
public void testToJibContainerBuilder_packagedSpringBoot_basicInfo() throws IOException, InvalidImageReferenceException {
when(mockSpringBootPackagedProcessor.getJavaVersion()).thenReturn(8);
FileEntriesLayer layer = FileEntriesLayer.builder().setName("jar").addEntry(Paths.get("path/to/spring-boot.jar"), AbsoluteUnixPath.get("/app/spring-boot.jar")).build();
when(mockSpringBootPackagedProcessor.createLayers()).thenReturn(Arrays.asList(layer));
when(mockSpringBootPackagedProcessor.computeEntrypoint(anyList())).thenReturn(ImmutableList.of("java", "-jar", "/app/spring-boot.jar"));
when(mockCommonContainerConfigCliOptions.getFrom()).thenReturn(Optional.empty());
JibContainerBuilder containerBuilder = JarFiles.toJibContainerBuilder(mockSpringBootPackagedProcessor, mockJarCommand, mockCommonCliOptions, mockCommonContainerConfigCliOptions, mockLogger);
ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan();
assertThat(buildPlan.getBaseImage()).isEqualTo("eclipse-temurin:8-jre");
assertThat(buildPlan.getPlatforms()).isEqualTo(ImmutableSet.of(new Platform("amd64", "linux")));
assertThat(buildPlan.getCreationTime()).isEqualTo(Instant.EPOCH);
assertThat(buildPlan.getFormat()).isEqualTo(ImageFormat.Docker);
assertThat(buildPlan.getEnvironment()).isEmpty();
assertThat(buildPlan.getLabels()).isEmpty();
assertThat(buildPlan.getVolumes()).isEmpty();
assertThat(buildPlan.getExposedPorts()).isEmpty();
assertThat(buildPlan.getUser()).isNull();
assertThat(buildPlan.getWorkingDirectory()).isNull();
assertThat(buildPlan.getEntrypoint()).containsExactly("java", "-jar", "/app/spring-boot.jar").inOrder();
assertThat(buildPlan.getLayers()).hasSize(1);
assertThat(buildPlan.getLayers().get(0).getName()).isEqualTo("jar");
assertThat(((FileEntriesLayer) buildPlan.getLayers().get(0)).getEntries()).isEqualTo(FileEntriesLayer.builder().addEntry(Paths.get("path/to/spring-boot.jar"), AbsoluteUnixPath.get("/app/spring-boot.jar")).build().getEntries());
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class WarFilesTest method testToJibContainerBuilder_nonJettyBaseImageSpecifiedAndNoEntrypoint.
@Test
public void testToJibContainerBuilder_nonJettyBaseImageSpecifiedAndNoEntrypoint() throws IOException, InvalidImageReferenceException {
JibContainerBuilder containerBuilder = WarFiles.toJibContainerBuilder(mockStandardWarExplodedProcessor, mockCommonCliOptions, mockCommonContainerConfigCliOptions, mockLogger);
ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan();
assertThat(mockCommonContainerConfigCliOptions.isJettyBaseimage()).isFalse();
assertThat(buildPlan.getEntrypoint()).isNull();
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class WarFilesTest method testToJibContainerBuilder_noProgramArgumentsSpecified.
@Test
public void testToJibContainerBuilder_noProgramArgumentsSpecified() throws IOException, InvalidImageReferenceException {
JibContainerBuilder containerBuilder = WarFiles.toJibContainerBuilder(mockStandardWarExplodedProcessor, mockCommonCliOptions, mockCommonContainerConfigCliOptions, mockLogger);
ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan();
assertThat(buildPlan.getCmd()).isNull();
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class WarFilesTest method testToJibContainerBuilder_explodedStandard_basicInfo.
@Test
public void testToJibContainerBuilder_explodedStandard_basicInfo() throws IOException, InvalidImageReferenceException {
FileEntriesLayer layer = FileEntriesLayer.builder().setName("classes").addEntry(Paths.get("path/to/tempDirectory/WEB-INF/classes/class1.class"), AbsoluteUnixPath.get("/my/app/WEB-INF/classes/class1.class")).build();
when(mockStandardWarExplodedProcessor.createLayers()).thenReturn(Arrays.asList(layer));
when(mockCommonContainerConfigCliOptions.isJettyBaseimage()).thenReturn(true);
JibContainerBuilder containerBuilder = WarFiles.toJibContainerBuilder(mockStandardWarExplodedProcessor, mockCommonCliOptions, mockCommonContainerConfigCliOptions, mockLogger);
ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan();
assertThat(buildPlan.getBaseImage()).isEqualTo("jetty");
assertThat(buildPlan.getEntrypoint()).containsExactly("java", "-jar", "/usr/local/jetty/start.jar").inOrder();
assertThat(buildPlan.getLayers()).hasSize(1);
assertThat(buildPlan.getLayers().get(0).getName()).isEqualTo("classes");
assertThat(((FileEntriesLayer) buildPlan.getLayers().get(0)).getEntries()).containsExactlyElementsIn(FileEntriesLayer.builder().addEntry(Paths.get("path/to/tempDirectory/WEB-INF/classes/class1.class"), AbsoluteUnixPath.get("/my/app/WEB-INF/classes/class1.class")).build().getEntries());
}
Aggregations