Skip to content

Commit

Permalink
Merge pull request #253 from sap-contributions/fix-direct-process
Browse files Browse the repository at this point in the history
Allow arguments when using BP_DIRECT_PROCESS
  • Loading branch information
dmikusa authored Nov 8, 2024
2 parents 7056154 + 0ab6417 commit c9bb5d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions procfile/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (b Build) Build(context libcnb.BuildContext) (libcnb.BuildResult, error) {
for k, v := range e.Metadata {
process := libcnb.Process{Type: k}

if (context.StackID == libpak.BionicTinyStackID) || (context.StackID == libpak.JammyTinyStackID) {
if (context.StackID == libpak.BionicTinyStackID) || (context.StackID == libpak.JammyTinyStackID) || sherpa.ResolveBool("BP_DIRECT_PROCESS") {
s, err := shellwords.Parse(v.(string))
if err != nil {
return libcnb.BuildResult{}, fmt.Errorf("unable to parse %s\n%w", s, err)
Expand All @@ -58,7 +58,7 @@ func (b Build) Build(context libcnb.BuildContext) (libcnb.BuildResult, error) {
process.Direct = true
} else {
process.Command = v.(string)
process.Direct = sherpa.ResolveBool("BP_DIRECT_PROCESS")
process.Direct = false
}

result.Processes = append(result.Processes, process)
Expand Down
9 changes: 5 additions & 4 deletions procfile/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
{
Name: "procfile",
Metadata: map[string]interface{}{
"test-type": "test-command",
"test-type": "test-command arg",
},
},
},
Expand All @@ -87,9 +87,10 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
result := libcnb.NewBuildResult()
result.Processes = append(result.Processes,
libcnb.Process{
Type: "test-type",
Command: "test-command",
Direct: true,
Type: "test-type",
Command: "test-command",
Arguments: []string{"arg"},
Direct: true,
},
)

Expand Down

0 comments on commit c9bb5d3

Please sign in to comment.