@@ -15,6 +15,7 @@ import (
15
15
"github.com/docker/docker/api/types"
16
16
"github.com/docker/docker/api/types/container"
17
17
"github.com/docker/docker/api/types/filters"
18
+ "github.com/docker/docker/api/types/image"
18
19
"github.com/docker/docker/client"
19
20
"github.com/docker/docker/pkg/stdcopy"
20
21
"github.com/docker/go-connections/nat"
@@ -33,7 +34,10 @@ type Controller struct {
33
34
func NewController () (c * Controller ) {
34
35
var err error
35
36
c = new (Controller )
36
- c .cli , err = client .NewClientWithOpts (client .FromEnv )
37
+ c .cli , err = client .NewClientWithOpts (
38
+ client .FromEnv ,
39
+ client .WithVersion ("1.45" ),
40
+ )
37
41
checkErr (err )
38
42
39
43
return
@@ -45,11 +49,11 @@ func NewController() (c *Controller) {
45
49
// if one occurred while creating the client. The Controller struct has a
46
50
// method EnsureImage() which pulls an image with the given name from
47
51
// a registry and logs the output to the console.
48
- func (c Controller ) EnsureImage (image string ) (err error ) {
52
+ func (c Controller ) EnsureImage (imageName string ) (err error ) {
49
53
var reader io.ReadCloser
50
54
51
- trace ("Running ImagePull for image %s" , image )
52
- reader , err = c .cli .ImagePull (context .Background (), image , types. ImagePullOptions {})
55
+ trace ("Running ImagePull for image %s" , imageName )
56
+ reader , err = c .cli .ImagePull (context .Background (), imageName , image. PullOptions {})
53
57
if reader != nil {
54
58
defer func () {
55
59
checkErr (reader .Close ())
@@ -106,7 +110,7 @@ func (c Controller) ContainerRun(
106
110
err = c .cli .ContainerStart (
107
111
context .Background (),
108
112
resp .ID ,
109
- types. ContainerStartOptions {},
113
+ container. StartOptions {},
110
114
)
111
115
if err != nil || unitTestFailure {
112
116
// Remove the container, because we haven't persisted to config yet, so
@@ -131,7 +135,7 @@ func (c Controller) ContainerRun(
131
135
// This function is useful for waiting until a specific event has occurred in the
132
136
// container (e.g. a server has started up) before continuing with other operations.
133
137
func (c Controller ) ContainerWaitForLogEntry (id string , text string ) {
134
- options := types. ContainerLogsOptions {
138
+ options := container. LogsOptions {
135
139
ShowStdout : true ,
136
140
ShowStderr : false ,
137
141
Since : "" ,
@@ -177,7 +181,7 @@ func (c Controller) ContainerStart(id string) (err error) {
177
181
panic ("Must pass in non-empty id" )
178
182
}
179
183
180
- err = c .cli .ContainerStart (context .Background (), id , types. ContainerStartOptions {})
184
+ err = c .cli .ContainerStart (context .Background (), id , container. StartOptions {})
181
185
return
182
186
}
183
187
@@ -329,7 +333,7 @@ func (c Controller) ContainerExists(id string) (exists bool) {
329
333
)
330
334
resp , err := c .cli .ContainerList (
331
335
context .Background (),
332
- types. ContainerListOptions {Filters : f },
336
+ container. ListOptions {Filters : f },
333
337
)
334
338
checkErr (err )
335
339
if len (resp ) > 0 {
@@ -352,7 +356,7 @@ func (c Controller) ContainerRemove(id string) (err error) {
352
356
panic ("Must pass in non-empty id" )
353
357
}
354
358
355
- options := types. ContainerRemoveOptions {
359
+ options := container. RemoveOptions {
356
360
RemoveVolumes : false ,
357
361
RemoveLinks : false ,
358
362
Force : false ,
0 commit comments