diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/EphemeralBuilder.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/EphemeralBuilder.java index 23479e4d2b..0546c018e5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/EphemeralBuilder.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/EphemeralBuilder.java @@ -21,19 +21,18 @@ import java.time.Clock; import java.time.Instant; import java.util.Map; -import org.springframework.boot.buildpack.platform.build.BuilderMetadata.Stack.RunImage; import org.springframework.boot.buildpack.platform.docker.type.Image; import org.springframework.boot.buildpack.platform.docker.type.ImageArchive; import org.springframework.boot.buildpack.platform.docker.type.ImageReference; import org.springframework.boot.buildpack.platform.docker.type.Layer; import org.springframework.boot.buildpack.platform.io.Content; import org.springframework.boot.buildpack.platform.io.Owner; -import org.springframework.boot.buildpack.platform.toml.Toml; /** * An short lived builder that is created for each {@link Lifecycle} run. * * @author Phillip Webb + * @author Scott Frederick */ class EphemeralBuilder { @@ -74,8 +73,6 @@ class EphemeralBuilder { update.withUpdatedConfig(this.builderMetadata::attachTo); update.withTag(name); update.withCreateDate(Instant.now(clock)); - update.withNewLayer(getDefaultDirsLayer(buildOwner)); - update.withNewLayer(getStackLayer(builderMetadata)); if (env != null && !env.isEmpty()) { update.withNewLayer(getEnvLayer(env)); } @@ -86,30 +83,6 @@ class EphemeralBuilder { update.withCreatedBy("Spring Boot", "dev"); } - private Layer getDefaultDirsLayer(Owner buildOwner) throws IOException { - return Layer.of((layout) -> { - layout.folder("/workspace", buildOwner); - layout.folder("/layers", buildOwner); - layout.folder("/cnb", Owner.ROOT); - layout.folder("/cnb/buildpacks", Owner.ROOT); - layout.folder("/platform", Owner.ROOT); - layout.folder("/platform/env", Owner.ROOT); - }); - } - - private Layer getStackLayer(BuilderMetadata builderMetadata) throws IOException { - Toml toml = getRunImageToml(builderMetadata.getStack().getRunImage()); - return Layer.of((layout) -> layout.file("/cnb/stack.toml", Owner.ROOT, Content.of(toml.toString()))); - } - - private Toml getRunImageToml(RunImage runImage) { - Toml toml = new Toml(); - toml.table("run-image"); - toml.string("image", runImage.getImage()); - toml.array("mirrors", runImage.getMirrors()); - return toml; - } - private Layer getEnvLayer(Map env) throws IOException { return Layer.of((layout) -> { for (Map.Entry entry : env.entrySet()) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/EphemeralBuilderTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/EphemeralBuilderTests.java index 5335253d8c..60b682b843 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/EphemeralBuilderTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/EphemeralBuilderTests.java @@ -19,9 +19,7 @@ package org.springframework.boot.buildpack.platform.build; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.InputStreamReader; import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.time.Clock; @@ -42,7 +40,6 @@ import org.springframework.boot.buildpack.platform.docker.type.ImageArchive; import org.springframework.boot.buildpack.platform.docker.type.ImageConfig; import org.springframework.boot.buildpack.platform.docker.type.ImageReference; import org.springframework.boot.buildpack.platform.json.AbstractJsonTests; -import org.springframework.util.FileCopyUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -50,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat; * Tests for {@link EphemeralBuilder}. * * @author Phillip Webb + * @author Scott Frederick */ class EphemeralBuilderTests extends AbstractJsonTests { @@ -101,33 +99,10 @@ class EphemeralBuilderTests extends AbstractJsonTests { assertThat(builder.getArchive().getCreateDate()).isEqualTo(Instant.now(clock)); } - @Test - void getArchiveContainsDefaultDirsLayer() throws Exception { - EphemeralBuilder builder = new EphemeralBuilder(this.owner, this.image, this.metadata, this.env); - File folder = unpack(getLayer(builder.getArchive(), 0), "dirs"); - assertThat(new File(folder, "workspace")).isDirectory(); - assertThat(new File(folder, "layers")).isDirectory(); - assertThat(new File(folder, "cnb")).isDirectory(); - assertThat(new File(folder, "cnb/buildpacks")).isDirectory(); - assertThat(new File(folder, "platform")).isDirectory(); - assertThat(new File(folder, "platform/env")).isDirectory(); - } - - @Test - void getArchiveContainsStackLayer() throws Exception { - EphemeralBuilder builder = new EphemeralBuilder(this.owner, this.image, this.metadata, this.env); - File folder = unpack(getLayer(builder.getArchive(), 1), "stack"); - File tomlFile = new File(folder, "cnb/stack.toml"); - assertThat(tomlFile).exists(); - String toml = FileCopyUtils - .copyToString(new InputStreamReader(new FileInputStream(tomlFile), StandardCharsets.UTF_8)); - assertThat(toml).contains("[run-image]").contains("image = "); - } - @Test void getArchiveContainsEnvLayer() throws Exception { EphemeralBuilder builder = new EphemeralBuilder(this.owner, this.image, this.metadata, this.env); - File folder = unpack(getLayer(builder.getArchive(), 2), "env"); + File folder = unpack(getLayer(builder.getArchive(), 0), "env"); assertThat(new File(folder, "platform/env/spring")).usingCharset(StandardCharsets.UTF_8).hasContent("boot"); }