RunHookWithTimeout executes a hook with a hard timeout. On timeout, returns HookTimeoutError and callers should fail open.
(hookName, root string, timeout time.Duration)
| 146 | // RunHookWithTimeout executes a hook with a hard timeout. |
| 147 | // On timeout, returns HookTimeoutError and callers should fail open. |
| 148 | func RunHookWithTimeout(hookName, root string, timeout time.Duration) error { |
| 149 | if timeout <= 0 { |
| 150 | return RunHook(hookName, root) |
| 151 | } |
| 152 | |
| 153 | return runWithTimeout(hookName, timeout, func() error { |
| 154 | return RunHook(hookName, root) |
| 155 | }) |
| 156 | } |
| 157 | |
| 158 | func runWithTimeout(hookName string, timeout time.Duration, fn func() error) error { |
| 159 | if timeout <= 0 { |