diff --git a/cmd/dockerfuse/client/client_test.go b/cmd/dockerfuse/client/client_test.go index 0943cd7..5ec2490 100644 --- a/cmd/dockerfuse/client/client_test.go +++ b/cmd/dockerfuse/client/client_test.go @@ -11,7 +11,9 @@ import ( "github.com/dguerri/dockerfuse/pkg/rpccommon" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/common" "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" fusefs "github.com/hanwen/go-fuse/v2/fs" "github.com/hanwen/go-fuse/v2/fuse" @@ -63,21 +65,21 @@ func (dc *mockDockerClient) ContainerExecAttach(ctx context.Context, execID stri args := dc.Called(ctx, execID, config) return args.Get(0).(types.HijackedResponse), args.Error(1) } -func (dc *mockDockerClient) ContainerExecCreate(ctx context.Context, container string, config container.ExecOptions) (types.IDResponse, error) { +func (dc *mockDockerClient) ContainerExecCreate(ctx context.Context, container string, config container.ExecOptions) (common.IDResponse, error) { args := dc.Called(ctx, container, config) - return args.Get(0).(types.IDResponse), args.Error(1) + return args.Get(0).(common.IDResponse), args.Error(1) } -func (dc *mockDockerClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) { +func (dc *mockDockerClient) ContainerInspect(ctx context.Context, containerID string) (container.InspectResponse, error) { args := dc.Called(ctx, containerID) - return args.Get(0).(types.ContainerJSON), args.Error(1) + return args.Get(0).(container.InspectResponse), args.Error(1) } func (dc *mockDockerClient) CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader, options container.CopyToContainerOptions) error { args := dc.Called(ctx, containerID, dstPath, content, options) return args.Error(0) } -func (dc *mockDockerClient) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) { +func (dc *mockDockerClient) ImageInspectWithRaw(ctx context.Context, imageID string) (image.InspectResponse, []byte, error) { args := dc.Called(ctx, imageID) - return args.Get(0).(types.ImageInspect), args.Get(1).([]byte), args.Error(2) + return args.Get(0).(image.InspectResponse), args.Get(1).([]byte), args.Error(2) } func TestNewFuseDockerClient(t *testing.T) { @@ -119,15 +121,15 @@ func TestNewFuseDockerClient(t *testing.T) { Cmd: []string{satelliteFullRemotePath}, } mDC.On("ContainerExecCreate", context.Background(), "test_container", config).Return( - types.IDResponse{ID: "test_execid"}, nil) + common.IDResponse{ID: "test_execid"}, nil) mDC.On("ContainerExecAttach", context.Background(), "test_execid", container.ExecStartOptions{Tty: true}).Return( types.HijackedResponse{Conn: nil}, nil) mDC.On("CopyToContainer", context.Background(), "test_container", satelliteExecPath, mock.AnythingOfType("*bufio.Reader"), container.CopyToContainerOptions{}).Return(nil) mDC.On("ImageInspectWithRaw", context.Background(), "test_container_image").Return( - types.ImageInspect{Architecture: "arm64"}, []byte{}, nil) - mDC.On("ContainerInspect", context.Background(), "test_container").Return(types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{Image: "test_container_image"}, + image.InspectResponse{Architecture: "arm64"}, []byte{}, nil) + mDC.On("ContainerInspect", context.Background(), "test_container").Return(container.InspectResponse{ + ContainerJSONBase: &container.ContainerJSONBase{Image: "test_container_image"}, }, nil) mDCF.On("NewClientWithOpts", mock.Anything).Return(&mDC, nil) @@ -171,7 +173,7 @@ func TestNewFuseDockerClient(t *testing.T) { mDCF = mockDockerClientFactory{} containerInspectError := fmt.Errorf("error on ContainerInspect") - mDC.On("ContainerInspect", context.Background(), "test_container").Return(types.ContainerJSON{}, containerInspectError) + mDC.On("ContainerInspect", context.Background(), "test_container").Return(container.InspectResponse{}, containerInspectError) mDCF.On("NewClientWithOpts", mock.Anything).Return(&mDC, nil) _, err = NewDockerFuseClient("test_container") @@ -193,9 +195,9 @@ func TestNewFuseDockerClient(t *testing.T) { imageInspectWithRawError := fmt.Errorf("error on ImageInspectWithRaw") mDC.On("ImageInspectWithRaw", context.Background(), "test_container_image").Return( - types.ImageInspect{}, []byte{}, imageInspectWithRawError) - mDC.On("ContainerInspect", context.Background(), "test_container").Return(types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{Image: "test_container_image"}, + image.InspectResponse{}, []byte{}, imageInspectWithRawError) + mDC.On("ContainerInspect", context.Background(), "test_container").Return(container.InspectResponse{ + ContainerJSONBase: &container.ContainerJSONBase{Image: "test_container_image"}, }, nil) mDCF.On("NewClientWithOpts", mock.Anything).Return(&mDC, nil) @@ -217,9 +219,9 @@ func TestNewFuseDockerClient(t *testing.T) { mDCF = mockDockerClientFactory{} mDC.On("ImageInspectWithRaw", context.Background(), "test_container_image").Return( - types.ImageInspect{Architecture: "invalidarc64"}, []byte{}, nil) - mDC.On("ContainerInspect", context.Background(), "test_container").Return(types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{Image: "test_container_image"}, + image.InspectResponse{Architecture: "invalidarc64"}, []byte{}, nil) + mDC.On("ContainerInspect", context.Background(), "test_container").Return(container.InspectResponse{ + ContainerJSONBase: &container.ContainerJSONBase{Image: "test_container_image"}, }, nil) mDCF.On("NewClientWithOpts", mock.Anything).Return(&mDC, nil) @@ -243,9 +245,9 @@ func TestNewFuseDockerClient(t *testing.T) { osExecutableError := fmt.Errorf("error on os.Executable()") mFS.On("Executable").Return("/test/pos/executable", osExecutableError) mDC.On("ImageInspectWithRaw", context.Background(), "test_container_image").Return( - types.ImageInspect{Architecture: "arm64"}, []byte{}, nil) - mDC.On("ContainerInspect", context.Background(), "test_container").Return(types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{Image: "test_container_image"}, + image.InspectResponse{Architecture: "arm64"}, []byte{}, nil) + mDC.On("ContainerInspect", context.Background(), "test_container").Return(container.InspectResponse{ + ContainerJSONBase: &container.ContainerJSONBase{Image: "test_container_image"}, }, nil) mDCF.On("NewClientWithOpts", mock.Anything).Return(&mDC, nil) @@ -270,9 +272,9 @@ func TestNewFuseDockerClient(t *testing.T) { mFS.On("ReadFile", satelliteFullLocalPath).Return([]byte{}, osReadFileError) mFS.On("Executable").Return("/test/pos/executable", nil) mDC.On("ImageInspectWithRaw", context.Background(), "test_container_image").Return( - types.ImageInspect{Architecture: "arm64"}, []byte{}, nil) - mDC.On("ContainerInspect", context.Background(), "test_container").Return(types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{Image: "test_container_image"}, + image.InspectResponse{Architecture: "arm64"}, []byte{}, nil) + mDC.On("ContainerInspect", context.Background(), "test_container").Return(container.InspectResponse{ + ContainerJSONBase: &container.ContainerJSONBase{Image: "test_container_image"}, }, nil) mDCF.On("NewClientWithOpts", mock.Anything).Return(&mDC, nil) @@ -299,9 +301,9 @@ func TestNewFuseDockerClient(t *testing.T) { mFS.On("ReadFile", satelliteFullLocalPath).Return([]byte("test executable content"), nil) mFS.On("Executable").Return("/test/pos/executable", nil) mDC.On("ImageInspectWithRaw", context.Background(), "test_container_image").Return( - types.ImageInspect{Architecture: "arm64"}, []byte{}, nil) - mDC.On("ContainerInspect", context.Background(), "test_container").Return(types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{Image: "test_container_image"}, + image.InspectResponse{Architecture: "arm64"}, []byte{}, nil) + mDC.On("ContainerInspect", context.Background(), "test_container").Return(container.InspectResponse{ + ContainerJSONBase: &container.ContainerJSONBase{Image: "test_container_image"}, }, nil) mDCF.On("NewClientWithOpts", mock.Anything).Return(&mDC, nil) @@ -324,15 +326,15 @@ func TestNewFuseDockerClient(t *testing.T) { containerExecCreateError := fmt.Errorf("error on ContainerExecCreate") mDC.On("ContainerExecCreate", context.Background(), "test_container", config).Return( - types.IDResponse{}, containerExecCreateError) + common.IDResponse{}, containerExecCreateError) mDC.On("CopyToContainer", context.Background(), "test_container", satelliteExecPath, mock.AnythingOfType("*bufio.Reader"), container.CopyToContainerOptions{}).Return(nil) mFS.On("ReadFile", satelliteFullLocalPath).Return([]byte("test executable content"), nil) mFS.On("Executable").Return("/test/pos/executable", nil) mDC.On("ImageInspectWithRaw", context.Background(), "test_container_image").Return( - types.ImageInspect{Architecture: "arm64"}, []byte{}, nil) - mDC.On("ContainerInspect", context.Background(), "test_container").Return(types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{Image: "test_container_image"}, + image.InspectResponse{Architecture: "arm64"}, []byte{}, nil) + mDC.On("ContainerInspect", context.Background(), "test_container").Return(container.InspectResponse{ + ContainerJSONBase: &container.ContainerJSONBase{Image: "test_container_image"}, }, nil) mDCF.On("NewClientWithOpts", mock.Anything).Return(&mDC, nil) @@ -357,15 +359,15 @@ func TestNewFuseDockerClient(t *testing.T) { mDC.On("ContainerExecAttach", context.Background(), "test_execid", container.ExecStartOptions{Tty: true}).Return( types.HijackedResponse{}, containerExecAttachError) mDC.On("ContainerExecCreate", context.Background(), "test_container", config).Return( - types.IDResponse{ID: "test_execid"}, nil) + common.IDResponse{ID: "test_execid"}, nil) mDC.On("CopyToContainer", context.Background(), "test_container", satelliteExecPath, mock.AnythingOfType("*bufio.Reader"), container.CopyToContainerOptions{}).Return(nil) mFS.On("ReadFile", satelliteFullLocalPath).Return([]byte("test executable content"), nil) mFS.On("Executable").Return("/test/pos/executable", nil) mDC.On("ImageInspectWithRaw", context.Background(), "test_container_image").Return( - types.ImageInspect{Architecture: "arm64"}, []byte{}, nil) - mDC.On("ContainerInspect", context.Background(), "test_container").Return(types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{Image: "test_container_image"}, + image.InspectResponse{Architecture: "arm64"}, []byte{}, nil) + mDC.On("ContainerInspect", context.Background(), "test_container").Return(container.InspectResponse{ + ContainerJSONBase: &container.ContainerJSONBase{Image: "test_container_image"}, }, nil) mDCF.On("NewClientWithOpts", mock.Anything).Return(&mDC, nil) diff --git a/cmd/dockerfuse/client/docker_client.go b/cmd/dockerfuse/client/docker_client.go index 663f5bd..75f5261 100644 --- a/cmd/dockerfuse/client/docker_client.go +++ b/cmd/dockerfuse/client/docker_client.go @@ -5,7 +5,9 @@ import ( "io" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/common" "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" ) @@ -17,10 +19,10 @@ type dockerClientFactoryInterface interface { type dockerClient interface { ContainerExecAttach(ctx context.Context, execID string, config container.ExecStartOptions) (types.HijackedResponse, error) - ContainerExecCreate(ctx context.Context, container string, config container.ExecOptions) (types.IDResponse, error) - ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) + ContainerExecCreate(ctx context.Context, container string, config container.ExecOptions) (common.IDResponse, error) + ContainerInspect(ctx context.Context, containerID string) (container.InspectResponse, error) CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader, options container.CopyToContainerOptions) error - ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) + ImageInspectWithRaw(ctx context.Context, imageID string) (image.InspectResponse, []byte, error) } // dockerClientFactory implements dockerClientFactoryInterface providing real client for Docker API diff --git a/go.mod b/go.mod index 07759b5..98b73cd 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.23.0 toolchain go1.23.7 require ( - github.com/docker/docker v27.4.1+incompatible + github.com/docker/docker v28.0.0+incompatible github.com/hanwen/go-fuse/v2 v2.7.2 github.com/lalkh/containerd v1.4.3 github.com/stretchr/testify v1.10.0 diff --git a/go.sum b/go.sum index f68cc72..fd9c713 100644 --- a/go.sum +++ b/go.sum @@ -248,8 +248,8 @@ github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TT github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/docker v27.4.1+incompatible h1:ZJvcY7gfwHn1JF48PfbyXg7Jyt9ZCWDW+GGXOIxEwp4= -github.com/docker/docker v27.4.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v28.0.0+incompatible h1:Olh0KS820sJ7nPsBKChVhk5pzqcwDR15fumfAd/p9hM= +github.com/docker/docker v28.0.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.6.3/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=