(ctx context.Context, container string, chdir string, cmd []string, env []string)
| 186 | } |
| 187 | |
| 188 | func (d Docker) Exec(ctx context.Context, container string, chdir string, cmd []string, env []string) (string, error) { |
| 189 | id, err := d.client.ContainerExecCreate(ctx, container, types.ExecConfig{Tty: true, WorkingDir: chdir, Cmd: cmd, Env: env, AttachStderr: true, AttachStdout: true}) |
| 190 | if err != nil { |
| 191 | return "", err |
| 192 | } |
| 193 | resp, err := d.client.ContainerExecAttach(ctx, id.ID, types.ExecStartCheck{}) |
| 194 | if err != nil { |
| 195 | return "", err |
| 196 | } |
| 197 | buf := new(bytes.Buffer) |
| 198 | buf.ReadFrom(resp.Reader) |
| 199 | return buf.String(), err |
| 200 | } |
| 201 | |
| 202 | func (d Docker) Restart(ctx context.Context, container string) error { |
| 203 | _ = d.Stop(ctx, container) |
no test coverage detected