MCPcopy
hub / github.com/basecamp/once / tryHookScript

Method tryHookScript

internal/docker/application_backup.go:309–328  ·  view source on GitHub ↗
(ctx context.Context, containerName, name string)

Source from the content-addressed store, hash-verified

307}
308
309func (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

Callers 2

backupToWriterMethod · 0.95
runHookScriptMethod · 0.95

Calls 1

execInContainerFunction · 0.70

Tested by

no test coverage detected