Skip to content

Commit bde2f13

Browse files
committed
refactor some shit
1 parent e7f70bf commit bde2f13

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

cli/docker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ func runDockerCVM(ctx context.Context, log slog.Logger, client dockerutil.Docker
648648
bootDir := filepath.Join(imgMeta.HomeDir, ".coder")
649649

650650
blog.Infof("Creating %q directory to host Coder assets...", bootDir)
651-
_, _, err = dockerutil.ExecContainer(ctx, client, dockerutil.ExecConfig{
651+
_, err = dockerutil.ExecContainer(ctx, client, dockerutil.ExecConfig{
652652
ContainerID: containerID,
653653
User: imgMeta.UID,
654654
Cmd: "mkdir",

dockerutil/container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func BootstrapContainer(ctx context.Context, client DockerClient, conf Bootstrap
114114
var err error
115115
for r, n := retry.New(time.Second, time.Second*2), 0; r.Wait(ctx) && n < 10; n++ {
116116
var out io.Reader
117-
out, _, err = ExecContainer(ctx, client, ExecConfig{
117+
out, err = ExecContainer(ctx, client, ExecConfig{
118118
ContainerID: conf.ContainerID,
119119
User: conf.User,
120120
Cmd: "/bin/sh",

dockerutil/exec.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type ExecConfig struct {
2626

2727
// ExecContainer runs a command in a container. It returns the output and any error.
2828
// If an error occurs during the execution of the command, the output is appended to the error.
29-
func ExecContainer(ctx context.Context, client DockerClient, config ExecConfig) (io.Reader, int, error) {
29+
func ExecContainer(ctx context.Context, client DockerClient, config ExecConfig) (io.Reader, error) {
3030
exec, err := client.ContainerExecCreate(ctx, config.ContainerID, dockertypes.ExecConfig{
3131
Detach: config.Detach,
3232
Cmd: append([]string{config.Cmd}, config.Args...),
@@ -37,23 +37,23 @@ func ExecContainer(ctx context.Context, client DockerClient, config ExecConfig)
3737
Env: config.Env,
3838
})
3939
if err != nil {
40-
return nil, 0, xerrors.Errorf("exec create: %w", err)
40+
return nil, xerrors.Errorf("exec create: %w", err)
4141
}
4242

4343
resp, err := client.ContainerExecAttach(ctx, exec.ID, dockertypes.ExecStartCheck{})
4444
if err != nil {
45-
return nil, 0, xerrors.Errorf("attach to exec: %w", err)
45+
return nil, xerrors.Errorf("attach to exec: %w", err)
4646
}
4747
defer resp.Close()
4848

4949
if config.Stdin != nil {
5050
_, err = io.Copy(resp.Conn, config.Stdin)
5151
if err != nil {
52-
return nil, 0, xerrors.Errorf("copy stdin: %w", err)
52+
return nil, xerrors.Errorf("copy stdin: %w", err)
5353
}
5454
err = resp.CloseWrite()
5555
if err != nil {
56-
return nil, 0, xerrors.Errorf("close write: %w", err)
56+
return nil, xerrors.Errorf("close write: %w", err)
5757
}
5858
}
5959

@@ -75,24 +75,24 @@ func ExecContainer(ctx context.Context, client DockerClient, config ExecConfig)
7575

7676
_, err = io.Copy(wr, resp.Reader)
7777
if err != nil {
78-
return nil, 0, xerrors.Errorf("copy cmd output: %w", err)
78+
return nil, xerrors.Errorf("copy cmd output: %w", err)
7979
}
8080
resp.Close()
8181

8282
inspect, err := client.ContainerExecInspect(ctx, exec.ID)
8383
if err != nil {
84-
return nil, 0, xerrors.Errorf("exec inspect: %w", err)
84+
return nil, xerrors.Errorf("exec inspect: %w", err)
8585
}
8686

8787
if inspect.Running {
88-
return nil, 0, xerrors.Errorf("unexpectedly still running")
88+
return nil, xerrors.Errorf("unexpectedly still running")
8989
}
9090

9191
if inspect.ExitCode > 0 {
92-
return nil, 0, xerrors.Errorf("%s: exit code %d", buf.Bytes(), inspect.ExitCode)
92+
return nil, xerrors.Errorf("%s: exit code %d", buf.Bytes(), inspect.ExitCode)
9393
}
9494

95-
return &buf, inspect.Pid, nil
95+
return &buf, nil
9696
}
9797

9898
func GetExecPID(ctx context.Context, client DockerClient, execID string) (int, error) {

dockerutil/image.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ func GetImageMetadata(ctx context.Context, client DockerClient, image, username
191191
return ImageMetadata{}, xerrors.Errorf("CVMs do not support NFS volumes")
192192
}
193193

194-
_, _, err = ExecContainer(ctx, client, ExecConfig{
194+
_, err = ExecContainer(ctx, client, ExecConfig{
195195
ContainerID: inspect.ID,
196196
Cmd: "stat",
197197
Args: []string{"/sbin/init"},
198198
})
199199
initExists := err == nil
200200

201-
out, _, err := ExecContainer(ctx, client, ExecConfig{
201+
out, err := ExecContainer(ctx, client, ExecConfig{
202202
ContainerID: inspect.ID,
203203
Cmd: "getent",
204204
Args: []string{"passwd", username},

integration/integrationtest/docker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const (
3333
HelloWorldImage = "gcr.io/coder-dev-1/sreya/hello-world"
3434
// UbuntuImage is just vanilla ubuntu (80MB) but the user is set to a non-root
3535
// user .
36-
UbuntuImage = "gcr.io/coder-dev-1/sreya/ubuntu-coder:jon"
36+
UbuntuImage = "gcr.io/coder-dev-1/sreya/ubuntu-coder"
3737
)
3838

3939
// TODO use df to determine if an environment is running in a docker container or not.

0 commit comments

Comments
 (0)