-
Notifications
You must be signed in to change notification settings - Fork 10
/
container.go
66 lines (51 loc) · 1.02 KB
/
container.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package conex
import (
"context"
"fmt"
"testing"
"time"
docker "github.com/fsouza/go-dockerclient"
)
func init() {
var _ Container = (*container)(nil)
}
type container struct {
j *docker.Container
c *docker.Client
t testing.TB
}
func (c *container) ID() string {
return c.j.ID
}
func (c *container) Image() string {
return c.j.Image
}
func (c *container) Name() string {
return c.j.Name
}
func (c *container) Address() string {
return c.j.NetworkSettings.IPAddress
}
func (c *container) Ports() []string {
// return c.j.NetworkSettings.Ports
return nil
}
func (c *container) Drop() {
err := c.c.StopContainer(c.j.ID, 10)
if err != nil {
fmt.Println("failed ", c.j.ID)
c.t.Fatal(err)
}
err = c.c.RemoveContainer(docker.RemoveContainerOptions{
ID: c.j.ID,
RemoveVolumes: true,
Force: true,
Context: context.Background(),
})
if err != nil {
c.t.Fatal(err)
}
}
func (c *container) Wait(port string, timeout time.Duration) error {
return wait(c.Address(), port, timeout)
}