(ctx context.Context, containerName, name string)
| 307 | } |
| 308 | |
| 309 | func (a *Application) tryHookScript(ctx context.Context, containerName, name string) (bool, error) { |
| 310 | path := "/hooks/" + name |
| 311 | |
| 312 | _, err := a.namespace.client.ContainerStatPath(ctx, containerName, path) |
| 313 | if err != nil { |
| 314 | if errdefs.IsNotFound(err) { |
| 315 | return false, nil |
| 316 | } |
| 317 | return false, fmt.Errorf("checking for hook script %q: %w", name, err) |
| 318 | } |
| 319 | |
| 320 | result, err := execInContainer(ctx, a.namespace.client, containerName, []string{path}) |
| 321 | if err != nil { |
| 322 | return true, err |
| 323 | } |
| 324 | if result.ExitCode != 0 { |
| 325 | return true, fmt.Errorf("hook script %q failed with exit code %d: %s", name, result.ExitCode, result.Stderr) |
| 326 | } |
| 327 | return true, nil |
| 328 | } |
| 329 | |
| 330 | // Helpers |
| 331 |
no test coverage detected