This repository was archived by the owner on Dec 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontainers.go
More file actions
107 lines (93 loc) 路 4.08 KB
/
Copy pathcontainers.go
File metadata and controls
107 lines (93 loc) 路 4.08 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package docker
import (
"github.com/docker/docker/api/types"
"github.com/go-check/check"
"github.com/libkermit/docker"
)
// Create lets you create a container with the specified image, and default
// configuration.
func (p *Project) Create(c *check.C, image string) types.ContainerJSON {
container, err := p.project.Create(image)
c.Assert(err, check.IsNil,
check.Commentf("error while creating the container with image %s", image))
return container
}
// CreateWithConfig lets you create a container with the specified image, and
// some custom simple configuration.
func (p *Project) CreateWithConfig(c *check.C, image string, containerConfig docker.ContainerConfig) types.ContainerJSON {
container, err := p.project.CreateWithConfig(image, containerConfig)
c.Assert(err, check.IsNil,
check.Commentf("error while creating the container with image %s and config %v", image, containerConfig))
return container
}
// Start lets you create and start a container with the specified image, and
// default configuration.
func (p *Project) Start(c *check.C, image string) types.ContainerJSON {
container, err := p.project.Start(image)
c.Assert(err, check.IsNil,
check.Commentf("error while starting the container with image %s", image))
return container
}
// StartWithConfig lets you create and start a container with the specified
// image, and some custom simple configuration.
func (p *Project) StartWithConfig(c *check.C, image string, containerConfig docker.ContainerConfig) types.ContainerJSON {
container, err := p.project.StartWithConfig(image, containerConfig)
c.Assert(err, check.IsNil,
check.Commentf("error while creating the starting with image %s", image))
return container
}
// Stop stops the container with a default timeout.
func (p *Project) Stop(c *check.C, containerID string) {
c.Assert(p.project.Stop(containerID), check.IsNil,
check.Commentf("error while stopping container %s", containerID))
}
// StopWithTimeout stops the container with the specified timeout.
func (p *Project) StopWithTimeout(c *check.C, containerID string, timeout int) {
c.Assert(p.project.StopWithTimeout(containerID, timeout), check.IsNil,
check.Commentf("error while stopping container %s with timeout %d", containerID, timeout))
}
// Inspect returns the container informations
func (p *Project) Inspect(c *check.C, containerID string) types.ContainerJSON {
container, err := p.project.Inspect(containerID)
c.Assert(err, check.IsNil,
check.Commentf("error while inspecting with container %s", containerID))
return container
}
// List lists the containers managed by kermit
func (p *Project) List(c *check.C) []types.Container {
containers, err := p.project.List()
c.Assert(err, check.IsNil,
check.Commentf("error while listing containers"))
return containers
}
// IsRunning checks if the container is running or not
func (p *Project) IsRunning(c *check.C, containerID string) bool {
isRunning, err := p.project.IsRunning(containerID)
c.Assert(err, check.IsNil,
check.Commentf("error while inspecting for running with container %s", containerID))
return isRunning
}
// IsStopped checks if the container is running or not
func (p *Project) IsStopped(c *check.C, containerID string) bool {
isStopped, err := p.project.IsPaused(containerID)
c.Assert(err, check.IsNil,
check.Commentf("error while inspecting for stopped with container %s", containerID))
return isStopped
}
// IsPaused checks if the container is running or not
func (p *Project) IsPaused(c *check.C, containerID string) bool {
isPaused, err := p.project.IsPaused(containerID)
c.Assert(err, check.IsNil,
check.Commentf("error while inspecting for paused with container %s", containerID))
return isPaused
}
// Remove removes the container
func (p *Project) Remove(c *check.C, containerID string) {
c.Assert(p.project.Remove(containerID), check.IsNil,
check.Commentf("error while removing the container %s", containerID))
}
// Clean stops and removes (by default, controllable with the keep) kermit containers
func (p *Project) Clean(c *check.C, keep bool) {
c.Assert(p.project.Clean(keep), check.IsNil,
check.Commentf("error while cleaning the containers"))
}