executeHook runs a single hook and returns the result.
(ctx context.Context, hook HookConfig, event HookEvent)
| 163 | |
| 164 | // executeHook runs a single hook and returns the result. |
| 165 | func (m *Manager) executeHook(ctx context.Context, hook HookConfig, event HookEvent) *HookResult { |
| 166 | timeout := time.Duration(hook.GetTimeout()) * time.Millisecond |
| 167 | |
| 168 | switch hook.Type { |
| 169 | case HookTypeCommand: |
| 170 | return m.executeCommandHook(ctx, hook, event, timeout) |
| 171 | case HookTypeHTTP: |
| 172 | return m.executeHTTPHook(ctx, hook, event, timeout) |
| 173 | default: |
| 174 | m.logger.Warn("Unknown hook type", zap.String("type", string(hook.Type)), zap.String("name", hook.Name)) |
| 175 | return &HookResult{ExitCode: -1, Error: "unknown hook type"} |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | // executeCommandHook runs a shell command hook. |
| 180 | // The event JSON is passed via stdin. Exit code 0 = allow, 2 = block. |
no test coverage detected