diff --git a/acceptance/launcher_test.go b/acceptance/launcher_test.go index 7d3334e53..e6e77a6a5 100644 --- a/acceptance/launcher_test.go +++ b/acceptance/launcher_test.go @@ -76,6 +76,16 @@ func testLauncher(t *testing.T, when spec.G, it spec.S) { assertOutput(t, cmd, "Executing web process-type") }) + when("process contains a period", func() { + it("launches that process", func() { + cmd := exec.Command("docker", "run", "--rm", + "--entrypoint=process.with.period"+exe, + "--env=CNB_PLATFORM_API="+latestPlatformAPI, + launchImage) + assertOutput(t, cmd, "Executing process.with.period process-type") + }) + }) + it("appends any args to the process args", func() { cmd := exec.Command("docker", "run", "--rm", "--entrypoint=web", diff --git a/acceptance/testdata/launcher/linux/container/cnb/process/process.with.period b/acceptance/testdata/launcher/linux/container/cnb/process/process.with.period new file mode 120000 index 000000000..b8a08bcd5 --- /dev/null +++ b/acceptance/testdata/launcher/linux/container/cnb/process/process.with.period @@ -0,0 +1 @@ +../lifecycle/launcher \ No newline at end of file diff --git a/acceptance/testdata/launcher/linux/container/layers/config/metadata.toml b/acceptance/testdata/launcher/linux/container/layers/config/metadata.toml index f1045316b..11ecc14cc 100644 --- a/acceptance/testdata/launcher/linux/container/layers/config/metadata.toml +++ b/acceptance/testdata/launcher/linux/container/layers/config/metadata.toml @@ -74,3 +74,10 @@ args = ["$WORKER_VAR"] direct = false buildpack-id = "0.4/buildpack" + +[[processes]] + type = "process.with.period" + command = "echo" + args = ["Executing process.with.period process-type"] + direct = false + buildpack-id = "0.4/buildpack" diff --git a/acceptance/testdata/launcher/windows/container/cnb/process/process.with.period.exe b/acceptance/testdata/launcher/windows/container/cnb/process/process.with.period.exe new file mode 120000 index 000000000..6b24b27f5 --- /dev/null +++ b/acceptance/testdata/launcher/windows/container/cnb/process/process.with.period.exe @@ -0,0 +1 @@ +../lifecycle/launcher.exe \ No newline at end of file diff --git a/acceptance/testdata/launcher/windows/container/layers/config/metadata.toml b/acceptance/testdata/launcher/windows/container/layers/config/metadata.toml index df926f0b9..55f52580a 100644 --- a/acceptance/testdata/launcher/windows/container/layers/config/metadata.toml +++ b/acceptance/testdata/launcher/windows/container/layers/config/metadata.toml @@ -49,3 +49,10 @@ args = ["/c", "echo VAR_FROM_EXEC_D: %VAR_FROM_EXEC_D%"] direct = false buildpack-id = "0.5/buildpack" + +[[processes]] + type = "process.with.period" + command = "echo" + direct = false + args = ["Executing", "process.with.period", "process-type"] + buildpack-id = "some/buildpack" diff --git a/cmd/launcher/cli/launcher.go b/cmd/launcher/cli/launcher.go index 2dddf03fb..7ee481b42 100644 --- a/cmd/launcher/cli/launcher.go +++ b/cmd/launcher/cli/launcher.go @@ -62,9 +62,11 @@ func defaultProcessType(platformAPI *api.Version, launchMD launch.Metadata) stri cmd.DefaultLogger.Warnf("CNB_PROCESS_TYPE is not supported in Platform API %s", platformAPI) cmd.DefaultLogger.Warnf("Run with ENTRYPOINT '%s' to invoke the '%s' process type", pType, pType) } - process := strings.TrimSuffix(filepath.Base(os.Args[0]), filepath.Ext(os.Args[0])) - if _, ok := launchMD.FindProcessType(process); ok { - return process + + _, process := filepath.Split(os.Args[0]) + processType := strings.TrimSuffix(process, platform.DefaultExecExt) + if _, ok := launchMD.FindProcessType(processType); ok { + return processType } return "" } diff --git a/go.mod b/go.mod index b3b99b1b6..3045cae41 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ require ( github.com/BurntSushi/toml v1.1.0 github.com/apex/log v1.9.0 github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20220906183739-a13b39e9d86d - github.com/buildpacks/imgutil v0.0.0-20220805205524-56137f75e24d + github.com/buildpacks/imgutil v0.0.0-20220913203928-6accc39f0cf9 github.com/chrismellard/docker-credential-acr-env v0.0.0-20220327082430-c57b701bfc08 github.com/docker/docker v20.10.18+incompatible github.com/golang/mock v1.6.0 diff --git a/go.sum b/go.sum index d30ac4574..4b6aadfcc 100644 --- a/go.sum +++ b/go.sum @@ -164,8 +164,8 @@ github.com/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbz github.com/blizzy78/varnamelen v0.3.0/go.mod h1:hbwRdBvoBqxk34XyQ6HA0UH3G0/1TKuv5AC4eaBT0Ec= github.com/bombsimon/wsl/v3 v3.3.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc= github.com/breml/bidichk v0.1.1/go.mod h1:zbfeitpevDUGI7V91Uzzuwrn4Vls8MoBMrwtt78jmso= -github.com/buildpacks/imgutil v0.0.0-20220805205524-56137f75e24d h1:06r2+NQ34WRTcqshXDvaQqOSeFDa8QPlxmClEYPdYCY= -github.com/buildpacks/imgutil v0.0.0-20220805205524-56137f75e24d/go.mod h1:S2RQzj190M80SV4VbpoCxeyoVYKjRN8qcIPLXEWNuF0= +github.com/buildpacks/imgutil v0.0.0-20220913203928-6accc39f0cf9 h1:44evShMGyqmWmuy/w6mD2wsuHsIMldOcptV4LjC2MjM= +github.com/buildpacks/imgutil v0.0.0-20220913203928-6accc39f0cf9/go.mod h1:YeEEHF5p5VpTAoVbf8pZ5peFuz50TrElzsNpeNELqgA= github.com/butuzov/ireturn v0.1.1/go.mod h1:Wh6Zl3IMtTpaIKbmwzqi6olnM9ptYQxxVacMsOEFPoc= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= diff --git a/platform/launch/defaults.go b/platform/launch/defaults.go new file mode 100644 index 000000000..1d820ed0f --- /dev/null +++ b/platform/launch/defaults.go @@ -0,0 +1,21 @@ +package launch + +import "path/filepath" + +const ( + EnvAppDir = "CNB_APP_DIR" + EnvLayersDir = "CNB_LAYERS_DIR" + EnvNoColor = "CNB_NO_COLOR" // defaults to false + EnvPlatformAPI = "CNB_PLATFORM_API" + EnvProcessType = "CNB_PROCESS_TYPE" + + DefaultPlatformAPI = "0.3" + DefaultProcessType = "web" + + DefaultExecExt = execExt +) + +var ( + DefaultAppDir = filepath.Join(rootDir, "workspace") + DefaultLayersDir = filepath.Join(rootDir, "layers") +) diff --git a/platform/launch/defaults_unix.go b/platform/launch/defaults_unix.go new file mode 100644 index 000000000..8e6710765 --- /dev/null +++ b/platform/launch/defaults_unix.go @@ -0,0 +1,9 @@ +//go:build linux || darwin +// +build linux darwin + +package launch + +const ( + execExt = "" + rootDir = "/" +) diff --git a/platform/launch/defaults_windows.go b/platform/launch/defaults_windows.go new file mode 100644 index 000000000..a205943a5 --- /dev/null +++ b/platform/launch/defaults_windows.go @@ -0,0 +1,6 @@ +package launch + +const ( + execExt = ".exe" + rootDir = `c:\` +)