@@ -8,11 +8,10 @@ import (
88 "strings"
99 "time"
1010
11- "github.com/docker/docker/api/types"
12- "github.com/docker/docker/api/types/container"
13- "github.com/docker/docker/api/types/events"
14- engineapi "github.com/docker/docker/client"
1511 gogotypes "github.com/gogo/protobuf/types"
12+ "github.com/moby/moby/api/types/container"
13+ "github.com/moby/moby/api/types/events"
14+ engineapi "github.com/moby/moby/client"
1615 "github.com/moby/swarmkit/v2/agent/exec"
1716 "github.com/moby/swarmkit/v2/api"
1817 "github.com/moby/swarmkit/v2/log"
@@ -42,16 +41,16 @@ func newContainerAdapter(client engineapi.APIClient, nodeDescription *api.NodeDe
4241 }, nil
4342}
4443
45- func noopPrivilegeFn () (string , error ) { return "" , nil }
44+ func noopPrivilegeFn (context. Context ) (string , error ) { return "" , nil }
4645
47- func (c * containerConfig ) imagePullOptions () types .ImagePullOptions {
46+ func (c * containerConfig ) imagePullOptions () engineapi .ImagePullOptions {
4847 var registryAuth string
4948
5049 if c .spec ().PullOptions != nil {
5150 registryAuth = c .spec ().PullOptions .RegistryAuth
5251 }
5352
54- return types .ImagePullOptions {
53+ return engineapi .ImagePullOptions {
5554 // if the image needs to be pulled, the auth config will be retrieved and updated
5655 RegistryAuth : registryAuth ,
5756 PrivilegeFunc : noopPrivilegeFn ,
@@ -130,7 +129,7 @@ func (c *containerAdapter) createNetworks(ctx context.Context) error {
130129
131130func (c * containerAdapter ) removeNetworks (ctx context.Context ) error {
132131 for _ , nid := range c .container .networks () {
133- if err := c .client .NetworkRemove (ctx , nid ); err != nil {
132+ if _ , err := c .client .NetworkRemove (ctx , nid , engineapi. NetworkRemoveOptions {} ); err != nil {
134133 if isActiveEndpointError (err ) {
135134 continue
136135 }
@@ -144,32 +143,36 @@ func (c *containerAdapter) removeNetworks(ctx context.Context) error {
144143}
145144
146145func (c * containerAdapter ) create (ctx context.Context ) error {
147- _ , err := c .client .ContainerCreate (ctx ,
148- c .container .config (),
149- c .container .hostConfig (),
150- c .container .networkingConfig (),
151- nil ,
152- c .container .name (),
153- )
146+ _ , err := c .client .ContainerCreate (ctx , engineapi.ContainerCreateOptions {
147+ Config : c .container .config (),
148+ HostConfig : c .container .hostConfig (),
149+ NetworkingConfig : c .container .networkingConfig (),
150+ Name : c .container .name (),
151+ })
154152
155153 return err
156154}
157155
158156func (c * containerAdapter ) start (ctx context.Context ) error {
159157 // TODO(nishanttotla): Consider adding checkpoint handling later
160- return c .client .ContainerStart (ctx , c .container .name (), types.ContainerStartOptions {})
158+ _ , err := c .client .ContainerStart (ctx , c .container .name (), engineapi.ContainerStartOptions {})
159+ return err
161160}
162161
163- func (c * containerAdapter ) inspect (ctx context.Context ) (types.ContainerJSON , error ) {
164- return c .client .ContainerInspect (ctx , c .container .name ())
162+ func (c * containerAdapter ) inspect (ctx context.Context ) (container.InspectResponse , error ) {
163+ res , err := c .client .ContainerInspect (ctx , c .container .name (), engineapi.ContainerInspectOptions {})
164+ if err != nil {
165+ return container.InspectResponse {}, err
166+ }
167+ return res .Container , nil
165168}
166169
167170// events issues a call to the events API and returns a channel with all
168171// events. The stream of events can be shutdown by cancelling the context.
169172//
170173// A chan struct{} is returned that will be closed if the event processing
171174// fails and needs to be restarted.
172- func (c * containerAdapter ) events (ctx context.Context ) ( <- chan events. Message , <- chan struct {}, error ) {
175+ func (c * containerAdapter ) events (ctx context.Context ) engineapi. EventsResult {
173176 // TODO(stevvooe): Move this to a single, global event dispatch. For
174177 // now, we create a connection per container.
175178 var (
@@ -180,7 +183,7 @@ func (c *containerAdapter) events(ctx context.Context) (<-chan events.Message, <
180183 log .G (ctx ).Debugf ("waiting on events" )
181184 // TODO(stevvooe): For long running tasks, it is likely that we will have
182185 // to restart this under failure.
183- eventCh , errCh := c .client .Events (ctx , types. EventsOptions {
186+ res := c .client .Events (ctx , engineapi. EventsListOptions {
184187 Since : "0" ,
185188 Filters : c .container .eventFilter (),
186189 })
@@ -190,13 +193,13 @@ func (c *containerAdapter) events(ctx context.Context) (<-chan events.Message, <
190193
191194 for {
192195 select {
193- case msg := <- eventCh :
196+ case msg := <- res . Messages :
194197 select {
195198 case eventsq <- msg :
196199 case <- ctx .Done ():
197200 return
198201 }
199- case err := <- errCh :
202+ case err := <- res . Err :
200203 log .G (ctx ).WithError (err ).Error ("error from events stream" )
201204 return
202205 case <- ctx .Done ():
@@ -206,7 +209,10 @@ func (c *containerAdapter) events(ctx context.Context) (<-chan events.Message, <
206209 }
207210 }()
208211
209- return eventsq , closed , nil
212+ return engineapi.EventsResult {
213+ Messages : eventsq ,
214+ Err : nil ,
215+ }
210216}
211217
212218func (c * containerAdapter ) shutdown (ctx context.Context ) error {
@@ -220,18 +226,21 @@ func (c *containerAdapter) shutdown(ctx context.Context) error {
220226 stopgraceFromProto , _ := gogotypes .DurationFromProto (spec .StopGracePeriod )
221227 stopgraceSeconds = int (stopgraceFromProto .Seconds ())
222228 }
223- return c .client .ContainerStop (ctx , c .container .name (), container.StopOptions {Timeout : & stopgraceSeconds })
229+ _ , err := c .client .ContainerStop (ctx , c .container .name (), engineapi.ContainerStopOptions {Timeout : & stopgraceSeconds })
230+ return err
224231}
225232
226233func (c * containerAdapter ) terminate (ctx context.Context ) error {
227- return c .client .ContainerKill (ctx , c .container .name (), "" )
234+ _ , err := c .client .ContainerKill (ctx , c .container .name (), engineapi.ContainerKillOptions {})
235+ return err
228236}
229237
230238func (c * containerAdapter ) remove (ctx context.Context ) error {
231- return c .client .ContainerRemove (ctx , c .container .name (), types .ContainerRemoveOptions {
239+ _ , err := c .client .ContainerRemove (ctx , c .container .name (), engineapi .ContainerRemoveOptions {
232240 RemoveVolumes : true ,
233241 Force : true ,
234242 })
243+ return err
235244}
236245
237246func (c * containerAdapter ) createVolumes (ctx context.Context ) error {
@@ -268,7 +277,7 @@ func (c *containerAdapter) logs(ctx context.Context, options api.LogSubscription
268277 return nil , errors .New ("logs not supported on services with TTY" )
269278 }
270279
271- apiOptions := types .ContainerLogsOptions {
280+ apiOptions := engineapi .ContainerLogsOptions {
272281 Follow : options .Follow ,
273282 Timestamps : true ,
274283 Details : false ,
0 commit comments