()
| 83 | } |
| 84 | |
| 85 | func (a *App) SetupDocker() error { |
| 86 | |
| 87 | if a.kind == utils.DockerStart { |
| 88 | running, err := a.docker.IsContainerRunning(a.container) |
| 89 | if err != nil { |
| 90 | return err |
| 91 | } |
| 92 | if running { |
| 93 | return fmt.Errorf("docker container is already in running state") |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | a.logger.Debug("inside setup docker", zap.String("cmd", a.cmd)) |
| 98 | |
| 99 | if HookImpl != nil { |
| 100 | newCmd, err := HookImpl.BeforeDockerSetup(context.Background(), a.cmd) |
| 101 | if err != nil { |
| 102 | utils.LogError(a.logger, err, "hook failed during docker setup") |
| 103 | return err |
| 104 | } |
| 105 | a.cmd = newCmd |
| 106 | } |
| 107 | |
| 108 | a.logger.Debug("after before docker setup hook", zap.String("cmd", a.cmd)) |
| 109 | |
| 110 | // attaching the init container's PID namespace to the app container |
| 111 | err := a.modifyDockerRun(context.Background()) |
| 112 | if err != nil { |
| 113 | utils.LogError(a.logger, err, "failed to attach init pid") |
| 114 | return err |
| 115 | } |
| 116 | return nil |
| 117 | } |
| 118 | |
| 119 | // ModifyDockerRun modifies the existing Docker command to attach the init container's PID namespace |
| 120 | func (a *App) modifyDockerRun(_ context.Context) error { |
no test coverage detected