-
Notifications
You must be signed in to change notification settings - Fork 10
/
conex.go
51 lines (43 loc) · 1.55 KB
/
conex.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
// Package conex provides easy to use Docker Integration with Testing.
package conex
import (
"testing"
"time"
)
// We keep logger here because the filename is shown along with the logs,
// this means that conex.go is put right before each log in tests which
// makes the source of the log more clear to the user.
func logf(t testing.TB, f string, args ...interface{}) {
t.Logf(f, args...)
}
//Same story as above.
func fatalf(t testing.TB, f string, args ...interface{}) {
t.Fatalf(f, args...)
}
// Manager is the conex container manager.
type Manager interface {
Run(m *testing.M, images ...string) int
Box(t testing.TB, config *Config) Container
}
// Container is a simple interface to a docker
// container.
type Container interface {
ID() string
Name() string
Image() string
Address() string
Drop()
Wait(port string, timeout time.Duration) error // Wait for the port to respond to tcp/udp.
//TODO: Yo.
// Ports() []string
}
// Config contains the configuration data about a container.
type Config struct {
Image string // Name of the image as it was passed by the operator (e.g. could be symbolic)
Env []string // List of environment variable to set in the container
Cmd []string // Command to run when starting the container
Hostname string // Hostname
Domainname string // Domainname
User string // User that will run the command(s) inside the container, also support user:group
Expose []string // Ports to expose, supports the docker command line style syntax proto/port or just port which defaults to tcp
}