Skip to content

Commit

Permalink
Bump github.com/docker/docker to 27.0.2+incompatible (#381)
Browse files Browse the repository at this point in the history
Signed-off-by: cncal <[email protected]>
  • Loading branch information
cncal authored Jul 9, 2024
1 parent 3921bcd commit ebd9de0
Show file tree
Hide file tree
Showing 65 changed files with 1,490 additions and 656 deletions.
9 changes: 5 additions & 4 deletions core/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import (
"io"
"time"

dockertypes "github.com/docker/docker/api/types"
"k8s.io/client-go/tools/remotecommand"

dockertypes "github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"
"github.com/sirupsen/logrus"

"github.com/Mirantis/cri-dockerd/libdocker"
Expand All @@ -33,7 +34,7 @@ import (
)

type dockerExitError struct {
Inspect *dockertypes.ContainerExecInspect
Inspect *dockercontainer.ExecInspect
}

func (d *dockerExitError) String() string {
Expand Down Expand Up @@ -87,7 +88,7 @@ func (*NativeExecHandler) ExecInContainer(
done := make(chan struct{})
defer close(done)

createOpts := dockertypes.ExecConfig{
createOpts := dockercontainer.ExecOptions{
Cmd: cmd,
AttachStdin: stdin != nil,
AttachStdout: stdout != nil,
Expand Down Expand Up @@ -119,7 +120,7 @@ func (*NativeExecHandler) ExecInContainer(
})
}()

startOpts := dockertypes.ExecStartCheck{Detach: false, Tty: tty}
startOpts := dockercontainer.ExecStartOptions{Detach: false, Tty: tty}
streamOpts := libdocker.StreamOptions{
InputStream: stdin,
OutputStream: stdout,
Expand Down
8 changes: 4 additions & 4 deletions core/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

dockertypes "github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"k8s.io/client-go/tools/remotecommand"
Expand All @@ -39,7 +40,7 @@ func TestExecInContainer(t *testing.T) {
returnCreateExec1 *dockertypes.IDResponse
returnCreateExec2 error
returnStartExec error
returnInspectExec1 *dockertypes.ContainerExecInspect
returnInspectExec1 *dockercontainer.ExecInspect
returnInspectExec2 error
expectError error
}{{
Expand All @@ -48,7 +49,7 @@ func TestExecInContainer(t *testing.T) {
returnCreateExec1: &dockertypes.IDResponse{ID: "12345678"},
returnCreateExec2: nil,
returnStartExec: nil,
returnInspectExec1: &dockertypes.ContainerExecInspect{
returnInspectExec1: &dockercontainer.ExecInspect{
ExecID: "200",
ContainerID: "12345678",
Running: false,
Expand Down Expand Up @@ -91,7 +92,7 @@ func TestExecInContainer(t *testing.T) {
returnCreateExec1: &dockertypes.IDResponse{ID: "12345678"},
returnCreateExec2: nil,
returnStartExec: context.DeadlineExceeded,
returnInspectExec1: &dockertypes.ContainerExecInspect{
returnInspectExec1: &dockercontainer.ExecInspect{
ExecID: "200",
ContainerID: "12345678",
Running: true,
Expand Down Expand Up @@ -149,7 +150,6 @@ func TestExecInContainer(t *testing.T) {
}
}


func getFakeContainerJSON() *dockertypes.ContainerJSON {
return &dockertypes.ContainerJSON{
ContainerJSONBase: &dockertypes.ContainerJSONBase{
Expand Down
8 changes: 4 additions & 4 deletions core/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"strconv"
"strings"

dockertypes "github.com/docker/docker/api/types"
dockerfilters "github.com/docker/docker/api/types/filters"
dockerimage "github.com/docker/docker/api/types/image"
dockerregistry "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/pkg/jsonmessage"

Expand Down Expand Up @@ -62,7 +62,7 @@ func (ds *dockerService) ListImages(
r *runtimeapi.ListImagesRequest,
) (*runtimeapi.ListImagesResponse, error) {
filter := r.GetFilter()
opts := dockertypes.ImageListOptions{}
opts := dockerimage.ListOptions{}
if filter != nil {
if filter.GetImage().GetImage() != "" {
opts.Filters = dockerfilters.NewArgs()
Expand Down Expand Up @@ -149,7 +149,7 @@ func (ds *dockerService) PullImage(
}
err := ds.client.PullImage(image.Image,
authConfig,
dockertypes.ImagePullOptions{},
dockerimage.PullOptions{},
)
if err != nil {
return nil, filterHTTPError(err, image.Image)
Expand Down Expand Up @@ -193,7 +193,7 @@ func (ds *dockerService) RemoveImage(
images = append(images, image.Image)

for _, image := range images {
if _, err := ds.client.RemoveImage(image, dockertypes.ImageRemoveOptions{PruneChildren: true}); err != nil &&
if _, err := ds.client.RemoveImage(image, dockerimage.RemoveOptions{PruneChildren: true}); err != nil &&
!libdocker.IsImageNotFoundError(err) {
return nil, err
}
Expand Down
25 changes: 13 additions & 12 deletions core/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"testing"

dockertypes "github.com/docker/docker/api/types"
dockerimage "github.com/docker/docker/api/types/image"
"github.com/docker/docker/pkg/jsonmessage"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -41,11 +42,11 @@ func TestRemoveImage(t *testing.T) {
libdocker.NewCalledDetail("inspect_image", nil),
libdocker.NewCalledDetail(
"remove_image",
[]interface{}{"foo", dockertypes.ImageRemoveOptions{PruneChildren: true}},
[]interface{}{"foo", dockerimage.RemoveOptions{PruneChildren: true}},
),
libdocker.NewCalledDetail(
"remove_image",
[]interface{}{"1111", dockertypes.ImageRemoveOptions{PruneChildren: true}},
[]interface{}{"1111", dockerimage.RemoveOptions{PruneChildren: true}},
),
},
},
Expand All @@ -55,15 +56,15 @@ func TestRemoveImage(t *testing.T) {
libdocker.NewCalledDetail("inspect_image", nil),
libdocker.NewCalledDetail(
"remove_image",
[]interface{}{"foo", dockertypes.ImageRemoveOptions{PruneChildren: true}},
[]interface{}{"foo", dockerimage.RemoveOptions{PruneChildren: true}},
),
libdocker.NewCalledDetail(
"remove_image",
[]interface{}{"bar", dockertypes.ImageRemoveOptions{PruneChildren: true}},
[]interface{}{"bar", dockerimage.RemoveOptions{PruneChildren: true}},
),
libdocker.NewCalledDetail(
"remove_image",
[]interface{}{"2222", dockertypes.ImageRemoveOptions{PruneChildren: true}},
[]interface{}{"2222", dockerimage.RemoveOptions{PruneChildren: true}},
),
},
},
Expand All @@ -77,22 +78,22 @@ func TestRemoveImage(t *testing.T) {
libdocker.NewCalledDetail("inspect_image", nil),
libdocker.NewCalledDetail(
"remove_image",
[]interface{}{"foo", dockertypes.ImageRemoveOptions{PruneChildren: true}},
[]interface{}{"foo", dockerimage.RemoveOptions{PruneChildren: true}},
),
libdocker.NewCalledDetail(
"remove_image",
[]interface{}{"foo@3333", dockertypes.ImageRemoveOptions{PruneChildren: true}},
[]interface{}{"foo@3333", dockerimage.RemoveOptions{PruneChildren: true}},
),
libdocker.NewCalledDetail(
"remove_image",
[]interface{}{
"example.com/foo@3333",
dockertypes.ImageRemoveOptions{PruneChildren: true},
dockerimage.RemoveOptions{PruneChildren: true},
},
),
libdocker.NewCalledDetail(
"remove_image",
[]interface{}{"3333", dockertypes.ImageRemoveOptions{PruneChildren: true}},
[]interface{}{"3333", dockerimage.RemoveOptions{PruneChildren: true}},
),
},
},
Expand All @@ -106,18 +107,18 @@ func TestRemoveImage(t *testing.T) {
libdocker.NewCalledDetail("inspect_image", nil),
libdocker.NewCalledDetail(
"remove_image",
[]interface{}{"foo@4444", dockertypes.ImageRemoveOptions{PruneChildren: true}},
[]interface{}{"foo@4444", dockerimage.RemoveOptions{PruneChildren: true}},
),
libdocker.NewCalledDetail(
"remove_image",
[]interface{}{
"example.com/foo@4444",
dockertypes.ImageRemoveOptions{PruneChildren: true},
dockerimage.RemoveOptions{PruneChildren: true},
},
),
libdocker.NewCalledDetail(
"remove_image",
[]interface{}{"4444", dockertypes.ImageRemoveOptions{PruneChildren: true}},
[]interface{}{"4444", dockerimage.RemoveOptions{PruneChildren: true}},
),
},
},
Expand Down
4 changes: 2 additions & 2 deletions core/imagefs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"syscall"
"time"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/image"
"github.com/sirupsen/logrus"

runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
Expand All @@ -43,7 +43,7 @@ func (ds *dockerService) imageFsInfo() (*runtimeapi.ImageFsInfoResponse, error)
logrus.Debugf("Filesystem usage containing '%s': usedBytes=%v, iNodesUsed=%v", ds.dockerRootDir, usedBytes, iNodesUsed)

// compute total used bytes by docker images
images, err := ds.client.ListImages(types.ImageListOptions{All: true, SharedSize: true})
images, err := ds.client.ListImages(image.ListOptions{All: true, SharedSize: true})
if err != nil {
logrus.Error(err, "Failed to get image list from docker")
return nil, err
Expand Down
5 changes: 3 additions & 2 deletions core/sandbox_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
dockertypes "github.com/docker/docker/api/types"
dockerbackend "github.com/docker/docker/api/types/backend"
dockercontainer "github.com/docker/docker/api/types/container"
dockerimage "github.com/docker/docker/api/types/image"
dockerregistry "github.com/docker/docker/api/types/registry"
"github.com/sirupsen/logrus"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
Expand Down Expand Up @@ -442,7 +443,7 @@ func ensureSandboxImageExists(client libdocker.DockerClientInterface, image stri
if !withCredentials {
logrus.Infof("Pulling the image without credentials. Image: %v", image)

err := client.PullImage(image, dockerregistry.AuthConfig{}, dockertypes.ImagePullOptions{})
err := client.PullImage(image, dockerregistry.AuthConfig{}, dockerimage.PullOptions{})
if err != nil {
return fmt.Errorf("failed pulling image %q: %v", image, err)
}
Expand All @@ -453,7 +454,7 @@ func ensureSandboxImageExists(client libdocker.DockerClientInterface, image stri
var pullErrs []error
for _, currentCreds := range creds {
authConfig := dockerregistry.AuthConfig(currentCreds)
err := client.PullImage(image, authConfig, dockertypes.ImagePullOptions{})
err := client.PullImage(image, authConfig, dockerimage.PullOptions{})
// If there was no error, return success
if err == nil {
return nil
Expand Down
9 changes: 4 additions & 5 deletions core/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package core
import (
"testing"

dockertypes "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/stretchr/testify/assert"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
Expand All @@ -32,7 +31,7 @@ func TestContainerStats(t *testing.T) {
tests := map[string]struct {
containerID string
container *libdocker.FakeContainer
containerStats *dockertypes.StatsJSON
containerStats *container.StatsResponse
calledDetails []libdocker.CalledDetail
}{
"container exists": {
Expand All @@ -44,7 +43,7 @@ func TestContainerStats(t *testing.T) {
Labels: labels,
},
},
&dockertypes.StatsJSON{},
&container.StatsResponse{},
[]libdocker.CalledDetail{
libdocker.NewCalledDetail("list", nil),
libdocker.NewCalledDetail("get_container_stats", nil),
Expand All @@ -59,7 +58,7 @@ func TestContainerStats(t *testing.T) {
Labels: labels,
},
},
&dockertypes.StatsJSON{},
&container.StatsResponse{},
[]libdocker.CalledDetail{
libdocker.NewCalledDetail("list", nil),
},
Expand All @@ -71,7 +70,7 @@ func TestContainerStats(t *testing.T) {
ds, fakeDocker, _ := newTestDockerService()
fakeDocker.SetFakeContainers([]*libdocker.FakeContainer{test.container})
fakeDocker.InjectContainerStats(
map[string]*dockertypes.StatsJSON{test.container.ID: test.containerStats},
map[string]*container.StatsResponse{test.container.ID: test.containerStats},
)
ds.ContainerStats(
getTestCTX(),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/coreos/go-systemd/v22 v22.5.0
github.com/davecgh/go-spew v1.1.1
github.com/docker/distribution v2.8.3+incompatible
github.com/docker/docker v26.1.2+incompatible
github.com/docker/docker v27.0.2+incompatible
github.com/docker/go-connections v0.5.0
github.com/emicklei/go-restful v2.16.0+incompatible
github.com/golang/mock v1.6.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4Kfc
github.com/docker/docker v20.10.21+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v26.1.2+incompatible h1:UVX5ZOrrfTGZZYEP+ZDq3Xn9PdHNXaSYMFPDumMqG2k=
github.com/docker/docker v26.1.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v27.0.2+incompatible h1:mNhCtgXNV1fIRns102grG7rdzIsGGCq1OlOD0KunZos=
github.com/docker/docker v27.0.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
Expand Down
17 changes: 7 additions & 10 deletions libdocker/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,20 @@ type DockerClientInterface interface {
RemoveContainer(id string, opts dockercontainer.RemoveOptions) error
InspectImageByRef(imageRef string) (*dockertypes.ImageInspect, error)
InspectImageByID(imageID string) (*dockertypes.ImageInspect, error)
ListImages(opts dockertypes.ImageListOptions) ([]dockerimagetypes.Summary, error)
PullImage(image string, auth dockerregistry.AuthConfig, opts dockertypes.ImagePullOptions) error
RemoveImage(
image string,
opts dockertypes.ImageRemoveOptions,
) ([]dockerimagetypes.DeleteResponse, error)
ListImages(opts dockerimagetypes.ListOptions) ([]dockerimagetypes.Summary, error)
PullImage(image string, auth dockerregistry.AuthConfig, opts dockerimagetypes.PullOptions) error
RemoveImage(imageStr string, opts dockerimagetypes.RemoveOptions) ([]dockerimagetypes.DeleteResponse, error)
ImageHistory(id string) ([]dockerimagetypes.HistoryResponseItem, error)
Logs(string, dockercontainer.LogsOptions, StreamOptions) error
Version() (*dockertypes.Version, error)
Info() (*dockersystem.Info, error)
CreateExec(string, dockertypes.ExecConfig) (*dockertypes.IDResponse, error)
StartExec(string, dockertypes.ExecStartCheck, StreamOptions) error
InspectExec(id string) (*dockertypes.ContainerExecInspect, error)
CreateExec(string, dockercontainer.ExecOptions) (*dockertypes.IDResponse, error)
StartExec(string, dockercontainer.ExecStartOptions, StreamOptions) error
InspectExec(id string) (*dockercontainer.ExecInspect, error)
AttachToContainer(string, dockercontainer.AttachOptions, StreamOptions) error
ResizeContainerTTY(id string, height, width uint) error
ResizeExecTTY(id string, height, width uint) error
GetContainerStats(id string) (*dockertypes.StatsJSON, error)
GetContainerStats(id string) (*dockercontainer.StatsResponse, error)
}

// Get a *dockerapi.Client, either using the endpoint passed in, or using
Expand Down
Loading

0 comments on commit ebd9de0

Please sign in to comment.