Skip to content

Commit 05f994c

Browse files
committed
Address review comments
Signed-off-by: Mrunal Patel <[email protected]>
1 parent a5f88db commit 05f994c

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

runtime.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ This event needs to be captured by oc to run onstop event handlers.
2020
Hooks allow one to run code before/after various lifecycle events of the container.
2121
The state of the container is passed to the hooks over stdin, so the hooks could get the information they need to do their work.
2222

23-
Hook paths are absolute are executed from the host's filesystem.
24-
The working directory for the hooks is set to the container's root filesystem unless overriden in the configuration.
23+
Hook paths are absolute and are executed from the host's filesystem.
2524

2625
### Pre-start
2726
The pre-start hooks are called after the container process is started but before the user supplied command is executed.
@@ -37,26 +36,18 @@ If a hook returns a non-zero exit code, then an error is logged and the remainin
3736

3837
```json
3938
"hooks" : {
40-
"pre-start": [
39+
"prestart": [
4140
{
42-
"path": "/usr/bin/fix-mounts",
43-
"args": ["arg1", "arg2"],
44-
"env": {
45-
"key1": "value1"
46-
},
47-
"dir": ""
48-
},
49-
{
50-
"path": "/usr/libexec/acme/bin/setup-network"
41+
"args": ["/usr/bin/fix-mounts", "arg1", "arg2"],
42+
"env": [ "key1=value1"],
5143
}
5244
],
53-
"post-stop": [
45+
"poststop": [
5446
{
55-
"path": "/usr/sbin/cleanup.sh",
56-
"args": ["-f"]
47+
"args": ["/usr/sbin/cleanup.sh", "-f"]
5748
}
5849
]
5950
}
6051
```
6152

62-
`path` is required for a hook. `args`, `env` and `dir` are optional.
53+
`args` are required for a hook. `env` is optional.

spec.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ type Spec struct {
1515
Hostname string `json:"hostname"`
1616
// Mounts profile configuration for adding mounts to the container's filesystem.
1717
Mounts []Mount `json:"mounts"`
18-
// Prestart is a list of commands to be run before the container process is executed.
19-
Prestart []Command `json:"prestart"`
20-
// Poststop is a list of commands to be run after the container process exits.
21-
Poststop []Command `json:"poststop"`
18+
// Hooks are the commands run at various lifecycle events of the container.
19+
Hooks Hooks `json:"hooks"`
20+
}
21+
22+
type Hooks struct {
23+
// Prestart is a list of hooks to be run before the container process is executed.
24+
Prestart []Hook `json:"prestart"`
25+
// Poststop is a list of hooks to be run after the container process exits.
26+
Poststop []Hook `json:"poststop"`
2227
}
2328

2429
// Mount specifies a mount for a container.
@@ -66,9 +71,8 @@ type Platform struct {
6671
Arch string `json:"arch"`
6772
}
6873

69-
type Command struct {
70-
Path string `json:"path"`
74+
// Hook specifies a command that is run at a particular event in the lifecycle of a container.
75+
type Hook struct {
7176
Args []string `json:"args"`
7277
Env []string `json:"env"`
73-
Dir string `json:"dir"`
7478
}

0 commit comments

Comments
 (0)