Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ func checkPlatform(platform rspec.Platform) {
}

func checkHooks(hooks rspec.Hooks, hooksCheck bool) {
checkEventHookPaths("pre-start", hooks.Prestart, hooksCheck)
checkEventHookPaths("post-start", hooks.Poststart, hooksCheck)
checkEventHookPaths("post-stop", hooks.Poststop, hooksCheck)
checkEventHooks("pre-start", hooks.Prestart, hooksCheck)
checkEventHooks("post-start", hooks.Poststart, hooksCheck)
checkEventHooks("post-stop", hooks.Poststop, hooksCheck)
}

func checkEventHookPaths(hookType string, hooks []rspec.Hook, hooksCheck bool) {
func checkEventHooks(hookType string, hooks []rspec.Hook, hooksCheck bool) {
for _, hook := range hooks {
if !filepath.IsAbs(hook.Path) {
logrus.Fatalf("The %s hook %v: is not absolute path", hookType, hook.Path)
Expand All @@ -145,6 +145,12 @@ func checkEventHookPaths(hookType string, hooks []rspec.Hook, hooksCheck bool) {
logrus.Fatalf("The %s hook %v: is not executable", hookType, hook.Path)
}
}

for _, env := range hook.Env {
if !envValid(env) {
logrus.Fatalf("Env %q for hook %v is in the invalid form.", env, hook.Path)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is host-independent, so it should happen regardless of whether --hooks is set (and that portability was the main reason for the flag in #49. For example, see here).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thanks.

}
}
}

Expand Down