@@ -11,18 +11,18 @@ import (
11
11
"github.com/docker/docker/api/types"
12
12
"github.com/docker/docker/api/types/container"
13
13
"github.com/docker/docker/api/types/filters"
14
- docker "github.com/docker/docker/client"
14
+ "github.com/docker/docker/client"
15
15
16
16
"github.com/percona/percona-backup-mongodb/pbm/errors"
17
17
)
18
18
19
19
type Docker struct {
20
- cn * docker .Client
20
+ cn * client .Client
21
21
ctx context.Context
22
22
}
23
23
24
24
func NewDocker (ctx context.Context , host string ) (* Docker , error ) {
25
- cn , err := docker .NewClientWithOpts (docker .WithHost (host ))
25
+ cn , err := client .NewClientWithOpts (client .WithHost (host ))
26
26
if err != nil {
27
27
return nil , errors .Wrap (err , "docker client" )
28
28
}
@@ -39,7 +39,7 @@ func (d *Docker) StopContainers(labels []string) error {
39
39
for _ , v := range labels {
40
40
fltr .Add ("label" , v )
41
41
}
42
- containers , err := d .cn .ContainerList (d .ctx , types. ContainerListOptions {
42
+ containers , err := d .cn .ContainerList (d .ctx , container. ListOptions {
43
43
Filters : fltr ,
44
44
})
45
45
if err != nil {
@@ -66,7 +66,7 @@ func (d *Docker) StopAgents(rsName string) error {
66
66
func (d * Docker ) PauseAgents (rsName string ) error {
67
67
fltr := filters .NewArgs ()
68
68
fltr .Add ("label" , "com.percona.pbm.agent.rs=" + rsName )
69
- containers , err := d .cn .ContainerList (d .ctx , types. ContainerListOptions {
69
+ containers , err := d .cn .ContainerList (d .ctx , container. ListOptions {
70
70
Filters : fltr ,
71
71
})
72
72
if err != nil {
@@ -91,7 +91,7 @@ func (d *Docker) PauseAgents(rsName string) error {
91
91
func (d * Docker ) UnpauseAgents (rsName string ) error {
92
92
fltr := filters .NewArgs ()
93
93
fltr .Add ("label" , "com.percona.pbm.agent.rs=" + rsName )
94
- containers , err := d .cn .ContainerList (d .ctx , types. ContainerListOptions {
94
+ containers , err := d .cn .ContainerList (d .ctx , container. ListOptions {
95
95
Filters : fltr ,
96
96
})
97
97
if err != nil {
@@ -123,7 +123,7 @@ func (d *Docker) StartContainers(labels []string) error {
123
123
for _ , v := range labels {
124
124
fltr .Add ("label" , v )
125
125
}
126
- containers , err := d .cn .ContainerList (d .ctx , types. ContainerListOptions {
126
+ containers , err := d .cn .ContainerList (d .ctx , container. ListOptions {
127
127
All : true ,
128
128
Filters : fltr ,
129
129
})
@@ -136,7 +136,7 @@ func (d *Docker) StartContainers(labels []string) error {
136
136
137
137
for _ , c := range containers {
138
138
log .Println ("Straing container" , c .ID )
139
- err = d .cn .ContainerStart (d .ctx , c .ID , types. ContainerStartOptions {})
139
+ err = d .cn .ContainerStart (d .ctx , c .ID , container. StartOptions {})
140
140
if err != nil {
141
141
return errors .Wrapf (err , "start container %s" , c .ID )
142
142
}
@@ -156,7 +156,7 @@ func (d *Docker) RestartContainers(labels []string) error {
156
156
for _ , v := range labels {
157
157
fltr .Add ("label" , v )
158
158
}
159
- containers , err := d .cn .ContainerList (d .ctx , types. ContainerListOptions {
159
+ containers , err := d .cn .ContainerList (d .ctx , container. ListOptions {
160
160
Filters : fltr ,
161
161
})
162
162
if err != nil {
@@ -177,7 +177,7 @@ func (d *Docker) RestartContainers(labels []string) error {
177
177
func (d * Docker ) RunOnReplSet (rsName string , wait time.Duration , cmd ... string ) error {
178
178
fltr := filters .NewArgs ()
179
179
fltr .Add ("label" , "com.percona.pbm.agent.rs=" + rsName )
180
- containers , err := d .cn .ContainerList (d .ctx , types. ContainerListOptions {
180
+ containers , err := d .cn .ContainerList (d .ctx , container. ListOptions {
181
181
Filters : fltr ,
182
182
})
183
183
if err != nil {
@@ -260,7 +260,7 @@ func (d *Docker) StartAgentContainers(labels []string) error {
260
260
fltr .Add ("label" , v )
261
261
}
262
262
263
- containers , err := d .cn .ContainerList (d .ctx , types. ContainerListOptions {
263
+ containers , err := d .cn .ContainerList (d .ctx , container. ListOptions {
264
264
All : true ,
265
265
Filters : fltr ,
266
266
})
@@ -282,15 +282,15 @@ func (d *Docker) StartAgentContainers(labels []string) error {
282
282
var buf strings.Builder
283
283
var started bool
284
284
for i := 1 ; i <= 5 ; i ++ {
285
- err := d .cn .ContainerStart (d .ctx , cont .ID , types. ContainerStartOptions {})
285
+ err := d .cn .ContainerStart (d .ctx , cont .ID , container. StartOptions {})
286
286
if err != nil {
287
287
errCh <- errors .Wrapf (err , "start container %s" , cont .ID )
288
288
return
289
289
}
290
290
291
291
since := time .Now ().Format (time .RFC3339Nano )
292
292
time .Sleep (5 * time .Second )
293
- out , err := d .cn .ContainerLogs (d .ctx , cont .ID , types. ContainerLogsOptions {
293
+ out , err := d .cn .ContainerLogs (d .ctx , cont .ID , container. LogsOptions {
294
294
ShowStdout : true ,
295
295
ShowStderr : true ,
296
296
Follow : false ,
0 commit comments