Skip to content

Commit 8510055

Browse files
committed
config: Require strictly-positive timeout values
If the timeout value was zero, the hook would always error, and there doesn't seem to be much point to that. And I'm not sure what negative timeouts would mean. By adding this restriction, we do not limit useful hook entries, and we give the validation code grounds to warn users attempting to validate configs which are poorly defined or have useless hook entries. Removing the pointer is not strictly required, but keeps up with our anti-pointer zero-value style (style.md) now that Go's zero-value is clearly invalid. Signed-off-by: W. Trevor King <[email protected]>
1 parent 0946333 commit 8510055

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ Hooks allow for the configuration of custom actions related to the [lifecycle](r
357357
* **`args`** (array of strings, OPTIONAL) with the same semantics as [IEEE Std 1003.1-2001 `execv`'s *argv*][ieee-1003.1-2001-xsh-exec].
358358
* **`env`** (array of strings, OPTIONAL) with the same semantics as [IEEE Std 1003.1-2001's `environ`][ieee-1003.1-2001-xbd-c8.1].
359359
* **`timeout`** (int, OPTIONAL) is the number of seconds before aborting the hook.
360+
If set, `timeout` MUST be greater than zero.
360361
* **`poststart`** (array of objects, OPTIONAL) is an array of [post-start hooks](#poststart).
361362
Entries in the array have the same schema as pre-start entries.
362363
* **`poststop`** (array of objects, OPTIONAL) is an array of [post-stop hooks](#poststop).

schema/defs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@
9191
"$ref": "#/definitions/Env"
9292
},
9393
"timeout": {
94-
"type": "integer"
94+
"type": "integer",
95+
"minimum": 1
9596
}
9697
},
9798
"required": [

specs-go/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ type Hook struct {
126126
Path string `json:"path"`
127127
Args []string `json:"args,omitempty"`
128128
Env []string `json:"env,omitempty"`
129-
Timeout *int `json:"timeout,omitempty"`
129+
Timeout int `json:"timeout,omitempty"`
130130
}
131131

132132
// Hooks for container setup and teardown

0 commit comments

Comments
 (0)