Skip to content

Commit

Permalink
Merge pull request #1788 from buildpacks/fix/stack-toml-from-run-table
Browse files Browse the repository at this point in the history
Fix: deriving stack.toml from the new run image information
  • Loading branch information
jkutner authored Jun 20, 2023
2 parents 5a61950 + 692e2f1 commit 1f35e85
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ func (b *Builder) stackLayer(dest string) (string, error) {
if b.metadata.Stack.RunImage.Image != "" {
err = toml.NewEncoder(buf).Encode(b.metadata.Stack)
} else if len(b.metadata.RunImages) > 0 {
err = toml.NewEncoder(buf).Encode(b.metadata.RunImages[0])
err = toml.NewEncoder(buf).Encode(StackMetadata{RunImage: b.metadata.RunImages[0]})
}
if err != nil {
return "", errors.Wrapf(err, "failed to marshal stack.toml")
Expand Down
12 changes: 12 additions & 0 deletions internal/builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,18 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
)
})

it("adds the stack.toml to the image", func() {
layerTar, err := baseImage.FindLayerWithPath("/cnb/stack.toml")
h.AssertNil(t, err)
h.AssertOnTarEntry(t, layerTar, "/cnb/stack.toml",
h.ContentEquals(`[run-image]
image = "some/run"
mirrors = ["some/mirror", "other/mirror"]
`),
h.HasModTime(archive.NormalizedDateTime),
)
})

it("adds the run image to the metadata", func() {
label, err := baseImage.Label("io.buildpacks.builder.metadata")
h.AssertNil(t, err)
Expand Down

0 comments on commit 1f35e85

Please sign in to comment.