Skip to content

Commit

Permalink
Add process specific working directories
Browse files Browse the repository at this point in the history
- Show process' working directory from the `WorkingDirectory`
  param in metadata label
- If working directory from label is empty then use Image's
  inspect to figure out the working directory (stored as WorkingDir)

Signed-off-by: Nitish Gupta <imnitish.ng@gmail.com>
  • Loading branch information
imnitishng committed Apr 29, 2022
1 parent 47a05e6 commit f6825aa
Show file tree
Hide file tree
Showing 23 changed files with 299 additions and 115 deletions.
8 changes: 8 additions & 0 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -955,18 +955,21 @@ func testAcceptance(
helloCommand string
helloArgs []string
helloArgsPrefix string
helloWorkdir string
)
if imageManager.HostOS() == "windows" {
webCommand = ".\\run"
helloCommand = "cmd"
helloArgs = []string{"/c", "echo hello world"}
helloArgsPrefix = " "
helloWorkdir = "/hello_workdir"

} else {
webCommand = "./run"
helloCommand = "echo"
helloArgs = []string{"hello", "world"}
helloArgsPrefix = ""
helloWorkdir = "/hello_workdir"
}

formats := []compareFormat{
Expand Down Expand Up @@ -1008,6 +1011,7 @@ func testAcceptance(
"hello_command": helloCommand,
"hello_args": helloArgs,
"hello_args_prefix": helloArgsPrefix,
"hello_workdir": helloWorkdir,
},
)

Expand Down Expand Up @@ -1604,17 +1608,20 @@ func testAcceptance(
helloCommand string
helloArgs []string
helloArgsPrefix string
helloWorkdir string
)
if imageManager.HostOS() == "windows" {
webCommand = ".\\run"
helloCommand = "cmd"
helloArgs = []string{"/c", "echo hello world"}
helloArgsPrefix = " "
helloWorkdir = "/hello_workdir"
} else {
webCommand = "./run"
helloCommand = "echo"
helloArgs = []string{"hello", "world"}
helloArgsPrefix = ""
helloWorkdir = "/hello_workdir"
}
formats := []compareFormat{
{
Expand Down Expand Up @@ -1655,6 +1662,7 @@ func testAcceptance(
"hello_command": helloCommand,
"hello_args": helloArgs,
"hello_args_prefix": helloArgsPrefix,
"hello_workdir": helloWorkdir,
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ cat <<EOF > "$launch_dir/launch.toml"
command = "echo"
args = ["hello", "world"]
direct = true
working-dir = "/hello_workdir"
EOF

echo "---> Done"
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ echo type = "hello"
echo command = "cmd"
echo args = ["/c", "echo hello world"]
echo direct = true
echo working-dir = "/hello_workdir"
) > %launch_dir%\launch.toml

echo --- Done
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ cat <<EOF > "$launch_dir/launch.toml"
command = "echo"
args = ["hello", "world"]
direct = true
working-dir = "/hello_workdir"
EOF

echo "---> Done"
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ echo type = "hello"
echo command = "cmd"
echo args = ["/c", "echo hello world"]
echo direct = true
echo working-dir = "/hello_workdir"
) > %launch_dir%\launch.toml

echo --- Done
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"default": true,
"args": [
"8080"
]
],
"working-dir": "/workspace"
},
{
"type": "hello",
Expand All @@ -42,7 +43,8 @@
"default": false,
"args": [
{{ ( StringsJoin (StringsDoubleQuote .hello_args) "," ) }}
]
],
"working-dir": "{{.hello_workdir}}"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ stack = "pack.test.stack"
command = "{{ ( StringsEscapeBackslash .web_command ) }}"
default = true
args = [ "8080" ]
working-dir = "/workspace"

[[local_info.processes]]
type = "hello"
shell = ""
command = "{{.hello_command}}"
default = false
args = [ {{ ( StringsJoin (StringsDoubleQuote .hello_args) ",") }} ]
working-dir = "{{.hello_workdir}}"
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Buildpacks:
simple/layers simple-layers-version -

Processes:
TYPE SHELL COMMAND ARGS
web (default) bash {{.web_command}} 8080
hello {{.hello_command}} {{ .hello_args_prefix }}{{ StringsJoin .hello_args " "}}
TYPE SHELL COMMAND ARGS WORK DIR
web (default) bash {{.web_command}} 8080 /workspace
hello {{.hello_command}} {{ .hello_args_prefix }}{{ StringsJoin .hello_args " "}} {{.hello_workdir}}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ local_info:
default: true
args:
- '8080'
working-dir: /workspace
- type: hello
shell: ''
command: "{{.hello_command}}"
default: false
args: [ {{ ( StringsJoin (StringsDoubleQuote .hello_args) ",") }} ]
args: [ {{ ( StringsJoin (StringsDoubleQuote .hello_args) ",") }} ]
working-dir: "{{.hello_workdir}}"
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"default": true,
"args": [
"8080"
]
],
"working-dir": "/workspace"
},
{
"type": "hello",
Expand All @@ -38,7 +39,8 @@
"default": false,
"args": [
{{ ( StringsJoin (StringsDoubleQuote .hello_args) "," ) }}
]
],
"working-dir": "{{.hello_workdir}}"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ stack = "pack.test.stack"
command = "{{( StringsEscapeBackslash .web_command )}}"
default = true
args = [ "8080" ]
working-dir = "/workspace"

[[remote_info.processes]]
type = "hello"
shell = ""
command = "{{.hello_command}}"
default = false
args = [ {{ ( StringsJoin (StringsDoubleQuote .hello_args) "," ) }} ]
working-dir = "{{.hello_workdir}}"

Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Buildpacks:
simple/layers simple-layers-version -

Processes:
TYPE SHELL COMMAND ARGS
web (default) bash {{.web_command}} 8080
hello {{.hello_command}} {{ .hello_args_prefix }}{{ StringsJoin .hello_args " "}}
TYPE SHELL COMMAND ARGS WORK DIR
web (default) bash {{.web_command}} 8080 /workspace
hello {{.hello_command}} {{ .hello_args_prefix }}{{ StringsJoin .hello_args " "}} {{.hello_workdir}}

LOCAL:
(not present)
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ remote_info:
default: true
args:
- '8080'
working-dir: /workspace
- type: hello
shell: ''
command: "{{.hello_command}}"
default: false
args: [ {{ ( StringsJoin (StringsDoubleQuote .hello_args) "," ) }} ]
working-dir: "{{.hello_workdir}}"
52 changes: 26 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require (
github.com/BurntSushi/toml v1.1.0
github.com/Masterminds/semver v1.5.0
github.com/apex/log v1.9.0
github.com/buildpacks/imgutil v0.0.0-20220310160537-4dd8bc60eaff
github.com/buildpacks/imgutil v0.0.0-20220425182719-2edb52457eb0
github.com/buildpacks/lifecycle v0.14.0
github.com/docker/cli v20.10.14+incompatible
github.com/docker/docker v20.10.14+incompatible
Expand All @@ -20,71 +20,71 @@ require (
github.com/heroku/color v0.0.6
github.com/mitchellh/ioprogress v0.0.0-20180201004757-6a23b12fa88e
github.com/onsi/gomega v1.19.0
github.com/opencontainers/image-spec v1.0.2
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
github.com/pelletier/go-toml v1.9.5
github.com/pkg/errors v0.9.1
github.com/rivo/tview v0.0.0-20210624165335-29d673af0ce2
github.com/sabhiram/go-gitignore v0.0.0-20201211074657-223ce5d391b0
github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
github.com/sclevine/spec v1.4.0
github.com/spf13/cobra v1.4.0
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
golang.org/x/mod v0.5.1
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.5.1 // indirect
github.com/Microsoft/hcsshim v0.8.23 // indirect
github.com/bits-and-blooms/bitset v1.2.0 // indirect
github.com/containerd/cgroups v1.0.1 // indirect
github.com/containerd/containerd v1.5.8 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.10.1 // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Microsoft/hcsshim v0.9.2 // indirect
github.com/bits-and-blooms/bitset v1.2.2 // indirect
github.com/containerd/cgroups v1.0.3 // indirect
github.com/containerd/containerd v1.6.3 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.11.4 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker-credential-helpers v0.6.4 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/gdamore/encoding v1.0.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.15.2 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/moby/sys/mount v0.2.0 // indirect
github.com/moby/sys/mountinfo v0.4.1 // indirect
github.com/moby/sys/mount v0.3.2 // indirect
github.com/moby/sys/mountinfo v0.6.1 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/runc v1.0.2 // indirect
github.com/opencontainers/selinux v1.8.2 // indirect
github.com/opencontainers/runc v1.1.1 // indirect
github.com/opencontainers/selinux v1.10.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/src-d/gcfg v1.4.0 // indirect
github.com/vbatts/tar-split v0.11.2 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
github.com/xanzy/ssh-agent v0.3.1 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220318055525-2edf467146b5 // indirect
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.43.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
google.golang.org/genproto v0.0.0-20220422154200-b37d22cd5731 // indirect
google.golang.org/grpc v1.46.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit f6825aa

Please sign in to comment.