Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 802bfa0

Browse files
committed
Cleanup tcli
1 parent 2edd14e commit 802bfa0

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-
type runnable interface {
27-
Run(ctx context.Context, command string) *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
type ContainerConfig struct {
3422
Name string
3523
Image string
3624
BindMounts map[string]string
3725
}
3826

39-
func mountArgs(m map[string]string) (args []string) {
27+
func mountArgs(m map[string]string) []string {
28+
args := make([]string, 0, len(m))
4029
for src, dest := range m {
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
type ContainerRunner struct {
5645
name string
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+
defer cancel()
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy