Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: deriving stack.toml from the new run image information #1788

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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