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

Add --run-image for pack build #263

Merged
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
10 changes: 10 additions & 0 deletions pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,17 @@ type PackBuild struct {
sbomOutputDir string
volumes []string
gid string
runImage string

// TODO: remove after deprecation period
noPull bool
}

func (pb PackBuild) WithRunImage(runImage string) PackBuild {
pb.runImage = runImage
return pb
}

func (pb PackBuild) WithBuildpacks(buildpacks ...string) PackBuild {
pb.buildpacks = append(pb.buildpacks, buildpacks...)
return pb
Expand Down Expand Up @@ -215,6 +221,10 @@ func (pb PackBuild) Execute(name, path string) (Image, fmt.Stringer, error) {
args = append(args, "--gid", pb.gid)
}

if pb.runImage != "" {
args = append(args, "--run-image", pb.runImage)
}

buildLogBuffer := bytes.NewBuffer(nil)
err := pb.executable.Execute(pexec.Execution{
Args: args,
Expand Down
21 changes: 21 additions & 0 deletions pack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,27 @@ func testPack(t *testing.T, context spec.G, it spec.S) {
})
})

context("when given optional run image", func() {
it("includes the --run-image option", func() {
image, logs, err := pack.Build.
WithRunImage("custom").
Execute("myapp", "/some/app/path")

Expect(err).NotTo(HaveOccurred())
Expect(image).To(Equal(occam.Image{
ID: "some-image-id",
}))
Expect(logs.String()).To(Equal("some stdout output\nsome stderr output\n"))

Expect(executable.ExecuteCall.Receives.Execution.Args).To(Equal([]string{
"build", "myapp",
"--path", "/some/app/path",
"--run-image", "custom",
}))
Expect(dockerImageInspectClient.ExecuteCall.Receives.Ref).To(Equal("myapp"))
})
})

context("when given optional gid", func() {
it("includes the --gid option and given argument on all commands", func() {
image, logs, err := pack.Build.
Expand Down
Loading