Skip to content

Commit 88c05a1

Browse files
committed
Merge branch 'main' into COP-1752-dx-tracker
2 parents b81e7d3 + 30be423 commit 88c05a1

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

framework/.changeset/v0.10.36.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
- Add DX tracking package
1+
2+
- Allow to execute arbitrary `ExecConfig` in Docker using our client

framework/.changeset/v0.11.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add DX tracking package

framework/docker.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,18 @@ func NewDockerClient() (*DockerClient, error) {
114114

115115
// ExecContainer executes a command inside a running container by name and returns the combined stdout/stderr.
116116
func (dc *DockerClient) ExecContainer(containerName string, command []string) (string, error) {
117-
L.Info().Strs("Command", command).Str("ContainerName", containerName).Msg("Executing command")
117+
execConfig := container.ExecOptions{
118+
Cmd: command,
119+
AttachStdout: true,
120+
AttachStderr: true,
121+
}
122+
123+
return dc.ExecContainerOptions(containerName, execConfig)
124+
}
125+
126+
// ExecContainer executes a command inside a running container by name and returns the combined stdout/stderr.
127+
func (dc *DockerClient) ExecContainerOptions(containerName string, execConfig container.ExecOptions) (string, error) {
128+
L.Info().Strs("Command", execConfig.Cmd).Str("ContainerName", containerName).Msg("Executing command")
118129
ctx := context.Background()
119130
containers, err := dc.cli.ContainerList(ctx, container.ListOptions{
120131
All: true,
@@ -135,11 +146,6 @@ func (dc *DockerClient) ExecContainer(containerName string, command []string) (s
135146
return "", fmt.Errorf("container with name '%s' not found", containerName)
136147
}
137148

138-
execConfig := container.ExecOptions{
139-
Cmd: command,
140-
AttachStdout: true,
141-
AttachStderr: true,
142-
}
143149
execID, err := dc.cli.ContainerExecCreate(ctx, containerID, execConfig)
144150
if err != nil {
145151
return "", fmt.Errorf("failed to create exec instance: %w", err)

0 commit comments

Comments
 (0)