Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commit802bfa0

Browse files
committed
Cleanup tcli
1 parent2edd14e commit802bfa0

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

‎ci/tcli/tcli.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"context"
66
"encoding/json"
77
"fmt"
8-
"io"
98
"os/exec"
109
"regexp"
1110
"strings"
@@ -18,25 +17,15 @@ import (
1817
"golang.org/x/xerrors"
1918
)
2019

21-
var (
22-
_runnable=&ContainerRunner{}
23-
_runnable=&HostRunner{}
24-
)
25-
26-
typerunnableinterface {
27-
Run(ctx context.Context,commandstring)*Assertable
28-
RunCmd(cmd*exec.Cmd)*Assertable
29-
io.Closer
30-
}
31-
3220
// ContainerConfig describes the ContainerRunner configuration schema for initializing a testing environment
3321
typeContainerConfigstruct {
3422
Namestring
3523
Imagestring
3624
BindMountsmap[string]string
3725
}
3826

39-
funcmountArgs(mmap[string]string) (args []string) {
27+
funcmountArgs(mmap[string]string) []string {
28+
args:=make([]string,0,len(m))
4029
forsrc,dest:=rangem {
4130
args=append(args,"--mount",fmt.Sprintf("type=bind,source=%s,target=%s",src,dest))
4231
}
@@ -54,7 +43,6 @@ func preflightChecks() error {
5443
// ContainerRunner specifies a runtime container for performing command tests
5544
typeContainerRunnerstruct {
5645
namestring
57-
ctx context.Context
5846
}
5947

6048
// NewContainerRunner starts a new docker container for executing command tests
@@ -83,13 +71,15 @@ func NewContainerRunner(ctx context.Context, config *ContainerConfig) (*Containe
8371

8472
return&ContainerRunner{
8573
name:config.Name,
86-
ctx:ctx,
8774
},nil
8875
}
8976

9077
// Close kills and removes the command execution testing container
9178
func (r*ContainerRunner)Close()error {
92-
cmd:=exec.CommandContext(r.ctx,
79+
ctx,cancel:=context.WithTimeout(context.Background(),2*time.Second)
80+
defercancel()
81+
82+
cmd:=exec.CommandContext(ctx,
9383
"sh","-c",strings.Join([]string{
9484
"docker","kill",r.name,"&&",
9585
"docker","rm",r.name,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp