From 4c5d16a5eb5407670856c67ff8bd096ae22a3c88 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 19 Dec 2017 13:39:32 +0000 Subject: [PATCH] Report an warning when no stages are defined for a hook We accidently defined hooks using stages rather then stage, which causes all of the hooks not to work, but we saw no complaints in the log files about this. Signed-off-by: Daniel J Walsh --- lib/hooks.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/hooks.go b/lib/hooks.go index 074ce7cc..42ff335a 100644 --- a/lib/hooks.go +++ b/lib/hooks.go @@ -53,9 +53,13 @@ func readHook(hookPath string) (HookParams, error) { return hook, errors.Wrapf(err, "invalid cmd regular expression %q defined in hook config %q", cmd, hookPath) } } - for _, stage := range hook.Stage { - if !validStage[stage] { - return hook, errors.Wrapf(err, "unknown stage %q defined in hook config %q", stage, hookPath) + if len(hook.Stage) == 0 { + logrus.Warnf("No stage defined in hook config %q, hook will never run", hookPath) + } else { + for _, stage := range hook.Stage { + if !validStage[stage] { + return hook, errors.Wrapf(err, "unknown stage %q defined in hook config %q", stage, hookPath) + } } } return hook, nil