@@ -4,16 +4,16 @@ import (
44 "context"
55 "strconv"
66
7- "github.com/docker/cli/cli/command"
87 "github.com/docker/docker/api/types"
98 "github.com/docker/docker/api/types/container"
109 "github.com/docker/docker/api/types/events"
1110 "github.com/docker/docker/api/types/filters"
1211 "github.com/docker/docker/api/types/versions"
12+ "github.com/docker/docker/client"
1313 "github.com/sirupsen/logrus"
1414)
1515
16- func waitExitOrRemoved (ctx context.Context , dockerCli command. Cli , containerID string , waitRemove bool ) <- chan int {
16+ func waitExitOrRemoved (ctx context.Context , apiClient client. APIClient , containerID string , waitRemove bool ) <- chan int {
1717 if len (containerID ) == 0 {
1818 // containerID can never be empty
1919 panic ("Internal Error: waitExitOrRemoved needs a containerID as parameter" )
@@ -22,16 +22,16 @@ func waitExitOrRemoved(ctx context.Context, dockerCli command.Cli, containerID s
2222 // Older versions used the Events API, and even older versions did not
2323 // support server-side removal. This legacyWaitExitOrRemoved method
2424 // preserves that old behavior and any issues it may have.
25- if versions .LessThan (dockerCli . Client () .ClientVersion (), "1.30" ) {
26- return legacyWaitExitOrRemoved (ctx , dockerCli , containerID , waitRemove )
25+ if versions .LessThan (apiClient .ClientVersion (), "1.30" ) {
26+ return legacyWaitExitOrRemoved (ctx , apiClient , containerID , waitRemove )
2727 }
2828
2929 condition := container .WaitConditionNextExit
3030 if waitRemove {
3131 condition = container .WaitConditionRemoved
3232 }
3333
34- resultC , errC := dockerCli . Client () .ContainerWait (ctx , containerID , condition )
34+ resultC , errC := apiClient .ContainerWait (ctx , containerID , condition )
3535
3636 statusC := make (chan int )
3737 go func () {
@@ -52,7 +52,7 @@ func waitExitOrRemoved(ctx context.Context, dockerCli command.Cli, containerID s
5252 return statusC
5353}
5454
55- func legacyWaitExitOrRemoved (ctx context.Context , dockerCli command. Cli , containerID string , waitRemove bool ) <- chan int {
55+ func legacyWaitExitOrRemoved (ctx context.Context , apiClient client. APIClient , containerID string , waitRemove bool ) <- chan int {
5656 var removeErr error
5757 statusChan := make (chan int )
5858 exitCode := 125
@@ -65,7 +65,7 @@ func legacyWaitExitOrRemoved(ctx context.Context, dockerCli command.Cli, contain
6565 Filters : f ,
6666 }
6767 eventCtx , cancel := context .WithCancel (ctx )
68- eventq , errq := dockerCli . Client () .Events (eventCtx , options )
68+ eventq , errq := apiClient .Events (eventCtx , options )
6969
7070 eventProcessor := func (e events.Message ) bool {
7171 stopProcessing := false
@@ -84,9 +84,9 @@ func legacyWaitExitOrRemoved(ctx context.Context, dockerCli command.Cli, contain
8484 } else {
8585 // If we are talking to an older daemon, `AutoRemove` is not supported.
8686 // We need to fall back to the old behavior, which is client-side removal
87- if versions .LessThan (dockerCli . Client () .ClientVersion (), "1.25" ) {
87+ if versions .LessThan (apiClient .ClientVersion (), "1.25" ) {
8888 go func () {
89- removeErr = dockerCli . Client () .ContainerRemove (ctx , containerID , types.ContainerRemoveOptions {RemoveVolumes : true })
89+ removeErr = apiClient .ContainerRemove (ctx , containerID , types.ContainerRemoveOptions {RemoveVolumes : true })
9090 if removeErr != nil {
9191 logrus .Errorf ("error removing container: %v" , removeErr )
9292 cancel () // cancel the event Q
0 commit comments