Merge pull request #1235 from rhatdan/hooks
Report an warning when no stages are defined for a hook
This commit is contained in:
commit
b8d2482b26
1 changed files with 7 additions and 3 deletions
10
lib/hooks.go
10
lib/hooks.go
|
@ -54,9 +54,13 @@ func readHook(hookPath string) (HookParams, error) {
|
||||||
return hook, errors.Wrapf(err, "invalid cmd regular expression %q defined in hook config %q", cmd, hookPath)
|
return hook, errors.Wrapf(err, "invalid cmd regular expression %q defined in hook config %q", cmd, hookPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, stage := range hook.Stage {
|
if len(hook.Stage) == 0 {
|
||||||
if !validStage[stage] {
|
logrus.Warnf("No stage defined in hook config %q, hook will never run", hookPath)
|
||||||
return hook, errors.Wrapf(err, "unknown stage %q defined in hook config %q", stage, 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
|
return hook, nil
|
||||||
|
|
Loading…
Reference in a new issue