Skip to content

Commit

Permalink
adding extesion fallback flag in jam pack
Browse files Browse the repository at this point in the history
  • Loading branch information
pacostas authored and ForestEckhardt committed Jun 7, 2023
1 parent d58b9bf commit 2a7d0ca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type PackBuild struct {
noColor bool

buildpacks []string
extensions []string
network string
builder string
clearCache bool
Expand All @@ -88,6 +89,11 @@ func (pb PackBuild) WithBuildpacks(buildpacks ...string) PackBuild {
return pb
}

func (pb PackBuild) WithExtensions(extensions ...string) PackBuild {
pb.extensions = append(pb.extensions, extensions...)
return pb
}

func (pb PackBuild) WithNetwork(name string) PackBuild {
pb.network = name
return pb
Expand Down Expand Up @@ -156,6 +162,10 @@ func (pb PackBuild) Execute(name, path string) (Image, fmt.Stringer, error) {
args = append(args, "--buildpack", buildpack)
}

for _, extension := range pb.extensions {
args = append(args, "--extension", extension)
}

if pb.network != "" {
args = append(args, "--network", pb.network)
}
Expand Down
15 changes: 14 additions & 1 deletion packagers/jam.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package packagers

import (
"fmt"
"os"
"path/filepath"

Expand Down Expand Up @@ -32,9 +33,21 @@ func (j Jam) WithExecutable(executable Executable) Jam {
}

func (j Jam) Execute(buildpackDir, output, version string, offline bool) error {

extensionTomlPath := filepath.Join(buildpackDir, "extension.toml")

buildpackOrExtensionToml := "buildpack.toml"
command := "--buildpack"
if _, err := os.Stat(extensionTomlPath); err == nil {
buildpackOrExtensionToml = "extension.toml"
command = "--extension"
}

fmt.Println("jam", command, filepath.Join(buildpackDir, buildpackOrExtensionToml), "--output", output, "--version", version, "--offline", offline)

args := []string{
"pack",
"--buildpack", filepath.Join(buildpackDir, "buildpack.toml"),
command, filepath.Join(buildpackDir, buildpackOrExtensionToml),
"--output", output,
"--version", version,
}
Expand Down

0 comments on commit 2a7d0ca

Please sign in to comment.