diff --git a/pack.go b/pack.go index 46c9424..cc42072 100644 --- a/pack.go +++ b/pack.go @@ -68,23 +68,29 @@ type PackBuild struct { verbose bool noColor bool - buildpacks []string - extensions []string - network string - builder string - clearCache bool - env map[string]string - trustBuilder bool - pullPolicy string - sbomOutputDir string - volumes []string - gid string - runImage string + buildpacks []string + extensions []string + network string + builder string + clearCache bool + env map[string]string + trustBuilder bool + pullPolicy string + sbomOutputDir string + volumes []string + gid string + runImage string + additionalBuildArgs []string // TODO: remove after deprecation period noPull bool } +func (pb PackBuild) WithAdditionalBuildArgs(args ...string) PackBuild { + pb.additionalBuildArgs = append(pb.additionalBuildArgs, args...) + return pb +} + func (pb PackBuild) WithRunImage(runImage string) PackBuild { pb.runImage = runImage return pb @@ -225,6 +231,8 @@ func (pb PackBuild) Execute(name, path string) (Image, fmt.Stringer, error) { args = append(args, "--run-image", pb.runImage) } + args = append(args, pb.additionalBuildArgs...) + buildLogBuffer := bytes.NewBuffer(nil) err := pb.executable.Execute(pexec.Execution{ Args: args, diff --git a/pack_test.go b/pack_test.go index ad39428..1d0f96e 100644 --- a/pack_test.go +++ b/pack_test.go @@ -346,6 +346,27 @@ func testPack(t *testing.T, context spec.G, it spec.S) { }) }) + context("when given additional build args", func() { + it("includes the additional args", func() { + image, logs, err := pack.Build. + WithAdditionalBuildArgs("--not-supported-yet", "true"). + 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", + "--not-supported-yet", "true", + })) + Expect(dockerImageInspectClient.ExecuteCall.Receives.Ref).To(Equal("myapp")) + }) + }) + context("failure cases", func() { context("when the executable fails", func() { it.Before(func() {