Browse code

api/types/image: move image option types to client

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>

Austin Vazquez authored on 2025/08/21 00:28:23
Showing 77 changed files
1 1
deleted file mode 100644
... ...
@@ -1,124 +0,0 @@
1
-package image
2
-
3
-import (
4
-	"context"
5
-	"io"
6
-
7
-	"github.com/moby/moby/api/types/filters"
8
-	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
9
-)
10
-
11
-// ImportSource holds source information for ImageImport
12
-type ImportSource struct {
13
-	Source     io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
14
-	SourceName string    // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
15
-}
16
-
17
-// ImportOptions holds information to import images from the client host.
18
-type ImportOptions struct {
19
-	Tag      string   // Tag is the name to tag this image with. This attribute is deprecated.
20
-	Message  string   // Message is the message to tag the image with
21
-	Changes  []string // Changes are the raw changes to apply to this image
22
-	Platform string   // Platform is the target platform of the image
23
-}
24
-
25
-// CreateOptions holds information to create images.
26
-type CreateOptions struct {
27
-	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry.
28
-	Platform     string // Platform is the target platform of the image if it needs to be pulled from the registry.
29
-}
30
-
31
-// PullOptions holds information to pull images.
32
-type PullOptions struct {
33
-	All          bool
34
-	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
35
-
36
-	// PrivilegeFunc is a function that clients can supply to retry operations
37
-	// after getting an authorization error. This function returns the registry
38
-	// authentication header value in base64 encoded format, or an error if the
39
-	// privilege request fails.
40
-	//
41
-	// For details, refer to [github.com/moby/moby/api/types/registry.RequestAuthConfig].
42
-	PrivilegeFunc func(context.Context) (string, error)
43
-	Platform      string
44
-}
45
-
46
-// PushOptions holds information to push images.
47
-type PushOptions struct {
48
-	All          bool
49
-	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
50
-
51
-	// PrivilegeFunc is a function that clients can supply to retry operations
52
-	// after getting an authorization error. This function returns the registry
53
-	// authentication header value in base64 encoded format, or an error if the
54
-	// privilege request fails.
55
-	//
56
-	// For details, refer to [github.com/moby/moby/api/types/registry.RequestAuthConfig].
57
-	PrivilegeFunc func(context.Context) (string, error)
58
-
59
-	// Platform is an optional field that selects a specific platform to push
60
-	// when the image is a multi-platform image.
61
-	// Using this will only push a single platform-specific manifest.
62
-	Platform *ocispec.Platform `json:",omitempty"`
63
-}
64
-
65
-// ListOptions holds parameters to list images with.
66
-type ListOptions struct {
67
-	// All controls whether all images in the graph are filtered, or just
68
-	// the heads.
69
-	All bool
70
-
71
-	// Filters is a JSON-encoded set of filter arguments.
72
-	Filters filters.Args
73
-
74
-	// SharedSize indicates whether the shared size of images should be computed.
75
-	SharedSize bool
76
-
77
-	// ContainerCount indicates whether container count should be computed.
78
-	//
79
-	// Deprecated: This field has been unused and is no longer required and will be removed in a future version.
80
-	ContainerCount bool
81
-
82
-	// Manifests indicates whether the image manifests should be returned.
83
-	Manifests bool
84
-}
85
-
86
-// RemoveOptions holds parameters to remove images.
87
-type RemoveOptions struct {
88
-	Platforms     []ocispec.Platform
89
-	Force         bool
90
-	PruneChildren bool
91
-}
92
-
93
-// HistoryOptions holds parameters to get image history.
94
-type HistoryOptions struct {
95
-	// Platform from the manifest list to use for history.
96
-	Platform *ocispec.Platform
97
-}
98
-
99
-// LoadOptions holds parameters to load images.
100
-type LoadOptions struct {
101
-	// Quiet suppresses progress output
102
-	Quiet bool
103
-
104
-	// Platforms selects the platforms to load if the image is a
105
-	// multi-platform image and has multiple variants.
106
-	Platforms []ocispec.Platform
107
-}
108
-
109
-type InspectOptions struct {
110
-	// Manifests returns the image manifests.
111
-	Manifests bool
112
-
113
-	// Platform selects the specific platform of a multi-platform image to inspect.
114
-	//
115
-	// This option is only available for API version 1.49 and up.
116
-	Platform *ocispec.Platform
117
-}
118
-
119
-// SaveOptions holds parameters to save images.
120
-type SaveOptions struct {
121
-	// Platforms selects the platforms to save if the image is a
122
-	// multi-platform image and has multiple variants.
123
-	Platforms []ocispec.Platform
124
-}
... ...
@@ -109,13 +109,13 @@ type ImageAPIClient interface {
109 109
 	ImageBuild(ctx context.Context, context io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error)
110 110
 	BuildCachePrune(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error)
111 111
 	BuildCancel(ctx context.Context, id string) error
112
-	ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error)
113
-	ImageImport(ctx context.Context, source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error)
112
+	ImageCreate(ctx context.Context, parentReference string, options ImageCreateOptions) (io.ReadCloser, error)
113
+	ImageImport(ctx context.Context, source ImageImportSource, ref string, options ImageImportOptions) (io.ReadCloser, error)
114 114
 
115
-	ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error)
116
-	ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error)
117
-	ImagePush(ctx context.Context, ref string, options image.PushOptions) (io.ReadCloser, error)
118
-	ImageRemove(ctx context.Context, image string, options image.RemoveOptions) ([]image.DeleteResponse, error)
115
+	ImageList(ctx context.Context, options ImageListOptions) ([]image.Summary, error)
116
+	ImagePull(ctx context.Context, ref string, options ImagePullOptions) (io.ReadCloser, error)
117
+	ImagePush(ctx context.Context, ref string, options ImagePushOptions) (io.ReadCloser, error)
118
+	ImageRemove(ctx context.Context, image string, options ImageRemoveOptions) ([]image.DeleteResponse, error)
119 119
 	ImageSearch(ctx context.Context, term string, options ImageSearchOptions) ([]registry.SearchResult, error)
120 120
 	ImageTag(ctx context.Context, image, ref string) error
121 121
 	ImagesPrune(ctx context.Context, pruneFilter filters.Args) (image.PruneReport, error)
... ...
@@ -8,13 +8,12 @@ import (
8 8
 	"strings"
9 9
 
10 10
 	"github.com/distribution/reference"
11
-	"github.com/moby/moby/api/types/image"
12 11
 	"github.com/moby/moby/api/types/registry"
13 12
 )
14 13
 
15 14
 // ImageCreate creates a new image based on the parent options.
16 15
 // It returns the JSON content in the response body.
17
-func (cli *Client) ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error) {
16
+func (cli *Client) ImageCreate(ctx context.Context, parentReference string, options ImageCreateOptions) (io.ReadCloser, error) {
18 17
 	ref, err := reference.ParseNormalizedNamed(parentReference)
19 18
 	if err != nil {
20 19
 		return nil, err
21 20
new file mode 100644
... ...
@@ -0,0 +1,7 @@
0
+package client
1
+
2
+// ImageCreateOptions holds information to create images.
3
+type ImageCreateOptions struct {
4
+	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry.
5
+	Platform     string // Platform is the target platform of the image if it needs to be pulled from the registry.
6
+}
... ...
@@ -10,7 +10,6 @@ import (
10 10
 	"testing"
11 11
 
12 12
 	cerrdefs "github.com/containerd/errdefs"
13
-	"github.com/moby/moby/api/types/image"
14 13
 	"github.com/moby/moby/api/types/registry"
15 14
 	"gotest.tools/v3/assert"
16 15
 	is "gotest.tools/v3/assert/cmp"
... ...
@@ -20,7 +19,7 @@ func TestImageCreateError(t *testing.T) {
20 20
 	client := &Client{
21 21
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
22 22
 	}
23
-	_, err := client.ImageCreate(context.Background(), "reference", image.CreateOptions{})
23
+	_, err := client.ImageCreate(context.Background(), "reference", ImageCreateOptions{})
24 24
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
25 25
 }
26 26
 
... ...
@@ -61,7 +60,7 @@ func TestImageCreate(t *testing.T) {
61 61
 		}),
62 62
 	}
63 63
 
64
-	createResponse, err := client.ImageCreate(context.Background(), specifiedReference, image.CreateOptions{
64
+	createResponse, err := client.ImageCreate(context.Background(), specifiedReference, ImageCreateOptions{
65 65
 		RegistryAuth: expectedRegistryAuth,
66 66
 	})
67 67
 	assert.NilError(t, err)
... ...
@@ -1,8 +1,6 @@
1 1
 package client
2 2
 
3
-import (
4
-	"github.com/moby/moby/api/types/image"
5
-)
3
+import ocispec "github.com/opencontainers/image-spec/specs-go/v1"
6 4
 
7 5
 // ImageHistoryOption is a type representing functional options for the image history operation.
8 6
 type ImageHistoryOption interface {
... ...
@@ -15,5 +13,10 @@ func (f imageHistoryOptionFunc) Apply(o *imageHistoryOpts) error {
15 15
 }
16 16
 
17 17
 type imageHistoryOpts struct {
18
-	apiOptions image.HistoryOptions
18
+	apiOptions imageHistoryOptions
19
+}
20
+
21
+type imageHistoryOptions struct {
22
+	// Platform from the manifest list to use for history.
23
+	Platform *ocispec.Platform
19 24
 }
... ...
@@ -7,12 +7,11 @@ import (
7 7
 	"strings"
8 8
 
9 9
 	"github.com/distribution/reference"
10
-	"github.com/moby/moby/api/types/image"
11 10
 )
12 11
 
13 12
 // ImageImport creates a new image based on the source options.
14 13
 // It returns the JSON content in the response body.
15
-func (cli *Client) ImageImport(ctx context.Context, source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) {
14
+func (cli *Client) ImageImport(ctx context.Context, source ImageImportSource, ref string, options ImageImportOptions) (io.ReadCloser, error) {
16 15
 	if ref != "" {
17 16
 		// Check if the given image name can be resolved
18 17
 		if _, err := reference.ParseNormalizedNamed(ref); err != nil {
19 18
new file mode 100644
... ...
@@ -0,0 +1,19 @@
0
+package client
1
+
2
+import (
3
+	"io"
4
+)
5
+
6
+// ImageImportSource holds source information for ImageImport
7
+type ImageImportSource struct {
8
+	Source     io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
9
+	SourceName string    // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
10
+}
11
+
12
+// ImageImportOptions holds information to import images from the client host.
13
+type ImageImportOptions struct {
14
+	Tag      string   // Tag is the name to tag this image with. This attribute is deprecated.
15
+	Message  string   // Message is the message to tag the image with
16
+	Changes  []string // Changes are the raw changes to apply to this image
17
+	Platform string   // Platform is the target platform of the image
18
+}
... ...
@@ -10,7 +10,6 @@ import (
10 10
 	"testing"
11 11
 
12 12
 	cerrdefs "github.com/containerd/errdefs"
13
-	"github.com/moby/moby/api/types/image"
14 13
 	"gotest.tools/v3/assert"
15 14
 	is "gotest.tools/v3/assert/cmp"
16 15
 )
... ...
@@ -19,7 +18,7 @@ func TestImageImportError(t *testing.T) {
19 19
 	client := &Client{
20 20
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
21 21
 	}
22
-	_, err := client.ImageImport(context.Background(), image.ImportSource{}, "image:tag", image.ImportOptions{})
22
+	_, err := client.ImageImport(context.Background(), ImageImportSource{}, "image:tag", ImageImportOptions{})
23 23
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
24 24
 }
25 25
 
... ...
@@ -30,7 +29,7 @@ func TestImageImport(t *testing.T) {
30 30
 	)
31 31
 	tests := []struct {
32 32
 		doc                 string
33
-		options             image.ImportOptions
33
+		options             ImageImportOptions
34 34
 		expectedQueryParams url.Values
35 35
 	}{
36 36
 		{
... ...
@@ -42,7 +41,7 @@ func TestImageImport(t *testing.T) {
42 42
 		},
43 43
 		{
44 44
 			doc: "change options",
45
-			options: image.ImportOptions{
45
+			options: ImageImportOptions{
46 46
 				Tag:     "imported",
47 47
 				Message: "A message",
48 48
 				Changes: []string{"change1", "change2"},
... ...
@@ -57,7 +56,7 @@ func TestImageImport(t *testing.T) {
57 57
 		},
58 58
 		{
59 59
 			doc: "with platform",
60
-			options: image.ImportOptions{
60
+			options: ImageImportOptions{
61 61
 				Platform: "linux/amd64",
62 62
 			},
63 63
 			expectedQueryParams: url.Values{
... ...
@@ -80,7 +79,7 @@ func TestImageImport(t *testing.T) {
80 80
 					}, nil
81 81
 				}),
82 82
 			}
83
-			resp, err := client.ImageImport(context.Background(), image.ImportSource{
83
+			resp, err := client.ImageImport(context.Background(), ImageImportSource{
84 84
 				Source:     strings.NewReader("source"),
85 85
 				SourceName: "image_source",
86 86
 			}, "repository_name:imported", tc.options)
... ...
@@ -3,7 +3,6 @@ package client
3 3
 import (
4 4
 	"bytes"
5 5
 
6
-	"github.com/moby/moby/api/types/image"
7 6
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
8 7
 )
9 8
 
... ...
@@ -50,7 +49,7 @@ func ImageInspectWithPlatform(platform *ocispec.Platform) ImageInspectOption {
50 50
 }
51 51
 
52 52
 // ImageInspectWithAPIOpts sets the API options for the image inspect operation.
53
-func ImageInspectWithAPIOpts(opts image.InspectOptions) ImageInspectOption {
53
+func ImageInspectWithAPIOpts(opts ImageInspectOptions) ImageInspectOption {
54 54
 	return imageInspectOptionFunc(func(clientOpts *imageInspectOpts) error {
55 55
 		clientOpts.apiOptions = opts
56 56
 		return nil
... ...
@@ -59,5 +58,15 @@ func ImageInspectWithAPIOpts(opts image.InspectOptions) ImageInspectOption {
59 59
 
60 60
 type imageInspectOpts struct {
61 61
 	raw        *bytes.Buffer
62
-	apiOptions image.InspectOptions
62
+	apiOptions ImageInspectOptions
63
+}
64
+
65
+type ImageInspectOptions struct {
66
+	// Manifests returns the image manifests.
67
+	Manifests bool
68
+
69
+	// Platform selects the specific platform of a multi-platform image to inspect.
70
+	//
71
+	// This option is only available for API version 1.49 and up.
72
+	Platform *ocispec.Platform
63 73
 }
... ...
@@ -16,7 +16,7 @@ import (
16 16
 // to include [image.Summary.Manifests] with information about image manifests.
17 17
 // This is experimental and might change in the future without any backward
18 18
 // compatibility.
19
-func (cli *Client) ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error) {
19
+func (cli *Client) ImageList(ctx context.Context, options ImageListOptions) ([]image.Summary, error) {
20 20
 	var images []image.Summary
21 21
 
22 22
 	// Make sure we negotiated (if the client is configured to do so),
23 23
new file mode 100644
... ...
@@ -0,0 +1,24 @@
0
+package client
1
+
2
+import "github.com/moby/moby/api/types/filters"
3
+
4
+// ImageListOptions holds parameters to list images with.
5
+type ImageListOptions struct {
6
+	// All controls whether all images in the graph are filtered, or just
7
+	// the heads.
8
+	All bool
9
+
10
+	// Filters is a JSON-encoded set of filter arguments.
11
+	Filters filters.Args
12
+
13
+	// SharedSize indicates whether the shared size of images should be computed.
14
+	SharedSize bool
15
+
16
+	// ContainerCount indicates whether container count should be computed.
17
+	//
18
+	// Deprecated: This field has been unused and is no longer required and will be removed in a future version.
19
+	ContainerCount bool
20
+
21
+	// Manifests indicates whether the image manifests should be returned.
22
+	Manifests bool
23
+}
... ...
@@ -23,7 +23,7 @@ func TestImageListError(t *testing.T) {
23 23
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
24 24
 	}
25 25
 
26
-	_, err := client.ImageList(context.Background(), image.ListOptions{})
26
+	_, err := client.ImageList(context.Background(), ImageListOptions{})
27 27
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
28 28
 }
29 29
 
... ...
@@ -35,7 +35,7 @@ func TestImageListConnectionError(t *testing.T) {
35 35
 	client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
36 36
 	assert.NilError(t, err)
37 37
 
38
-	_, err = client.ImageList(context.Background(), image.ListOptions{})
38
+	_, err = client.ImageList(context.Background(), ImageListOptions{})
39 39
 	assert.Check(t, is.ErrorType(err, IsErrConnectionFailed))
40 40
 }
41 41
 
... ...
@@ -43,11 +43,11 @@ func TestImageList(t *testing.T) {
43 43
 	const expectedURL = "/images/json"
44 44
 
45 45
 	listCases := []struct {
46
-		options             image.ListOptions
46
+		options             ImageListOptions
47 47
 		expectedQueryParams map[string]string
48 48
 	}{
49 49
 		{
50
-			options: image.ListOptions{},
50
+			options: ImageListOptions{},
51 51
 			expectedQueryParams: map[string]string{
52 52
 				"all":     "",
53 53
 				"filter":  "",
... ...
@@ -55,7 +55,7 @@ func TestImageList(t *testing.T) {
55 55
 			},
56 56
 		},
57 57
 		{
58
-			options: image.ListOptions{
58
+			options: ImageListOptions{
59 59
 				Filters: filters.NewArgs(
60 60
 					filters.Arg("label", "label1"),
61 61
 					filters.Arg("label", "label2"),
... ...
@@ -69,7 +69,7 @@ func TestImageList(t *testing.T) {
69 69
 			},
70 70
 		},
71 71
 		{
72
-			options: image.ListOptions{
72
+			options: ImageListOptions{
73 73
 				Filters: filters.NewArgs(filters.Arg("dangling", "false")),
74 74
 			},
75 75
 			expectedQueryParams: map[string]string{
... ...
@@ -148,7 +148,7 @@ func TestImageListApiBefore125(t *testing.T) {
148 148
 		version: "1.24",
149 149
 	}
150 150
 
151
-	options := image.ListOptions{
151
+	options := ImageListOptions{
152 152
 		Filters: filters.NewArgs(filters.Arg("reference", "image:tag")),
153 153
 	}
154 154
 
... ...
@@ -165,12 +165,12 @@ func TestImageListWithSharedSize(t *testing.T) {
165 165
 	for _, tc := range []struct {
166 166
 		name       string
167 167
 		version    string
168
-		options    image.ListOptions
168
+		options    ImageListOptions
169 169
 		sharedSize string // expected value for the shared-size query param, or empty if it should not be set.
170 170
 	}{
171 171
 		{name: "unset after 1.42, no options set", version: "1.42"},
172
-		{name: "set after 1.42, if requested", version: "1.42", options: image.ListOptions{SharedSize: true}, sharedSize: "1"},
173
-		{name: "unset before 1.42, even if requested", version: "1.41", options: image.ListOptions{SharedSize: true}},
172
+		{name: "set after 1.42, if requested", version: "1.42", options: ImageListOptions{SharedSize: true}, sharedSize: "1"},
173
+		{name: "unset before 1.42, even if requested", version: "1.41", options: ImageListOptions{SharedSize: true}},
174 174
 	} {
175 175
 		t.Run(tc.name, func(t *testing.T) {
176 176
 			t.Parallel()
... ...
@@ -3,7 +3,6 @@ package client
3 3
 import (
4 4
 	"fmt"
5 5
 
6
-	"github.com/moby/moby/api/types/image"
7 6
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
8 7
 )
9 8
 
... ...
@@ -18,7 +17,16 @@ func (f imageLoadOptionFunc) Apply(o *imageLoadOpts) error {
18 18
 }
19 19
 
20 20
 type imageLoadOpts struct {
21
-	apiOptions image.LoadOptions
21
+	apiOptions imageLoadOptions
22
+}
23
+
24
+type imageLoadOptions struct {
25
+	// Quiet suppresses progress output
26
+	Quiet bool
27
+
28
+	// Platforms selects the platforms to load if the image is a
29
+	// multi-platform image and has multiple variants.
30
+	Platforms []ocispec.Platform
22 31
 }
23 32
 
24 33
 // ImageLoadWithQuiet sets the quiet option for the image load operation.
... ...
@@ -8,14 +8,13 @@ import (
8 8
 
9 9
 	cerrdefs "github.com/containerd/errdefs"
10 10
 	"github.com/distribution/reference"
11
-	"github.com/moby/moby/api/types/image"
12 11
 )
13 12
 
14 13
 // ImagePull requests the docker host to pull an image from a remote registry.
15 14
 // It executes the privileged function if the operation is unauthorized
16 15
 // and it tries one more time.
17 16
 // It's up to the caller to handle the [io.ReadCloser] and close it.
18
-func (cli *Client) ImagePull(ctx context.Context, refStr string, options image.PullOptions) (io.ReadCloser, error) {
17
+func (cli *Client) ImagePull(ctx context.Context, refStr string, options ImagePullOptions) (io.ReadCloser, error) {
19 18
 	// FIXME(vdemeester): there is currently used in a few way in docker/docker
20 19
 	// - if not in trusted content, ref is used to pass the whole reference, and tag is empty
21 20
 	// - if in trusted content, ref is used to pass the reference name, and tag for the digest
22 21
new file mode 100644
... ...
@@ -0,0 +1,18 @@
0
+package client
1
+
2
+import "context"
3
+
4
+// ImagePullOptions holds information to pull images.
5
+type ImagePullOptions struct {
6
+	All          bool
7
+	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
8
+
9
+	// PrivilegeFunc is a function that clients can supply to retry operations
10
+	// after getting an authorization error. This function returns the registry
11
+	// authentication header value in base64 encoded format, or an error if the
12
+	// privilege request fails.
13
+	//
14
+	// For details, refer to [github.com/moby/moby/api/types/registry.RequestAuthConfig].
15
+	PrivilegeFunc func(context.Context) (string, error)
16
+	Platform      string
17
+}
... ...
@@ -11,7 +11,6 @@ import (
11 11
 	"testing"
12 12
 
13 13
 	cerrdefs "github.com/containerd/errdefs"
14
-	"github.com/moby/moby/api/types/image"
15 14
 	"github.com/moby/moby/api/types/registry"
16 15
 	"gotest.tools/v3/assert"
17 16
 	is "gotest.tools/v3/assert/cmp"
... ...
@@ -24,7 +23,7 @@ func TestImagePullReferenceParseError(t *testing.T) {
24 24
 		}),
25 25
 	}
26 26
 	// An empty reference is an invalid reference
27
-	_, err := client.ImagePull(context.Background(), "", image.PullOptions{})
27
+	_, err := client.ImagePull(context.Background(), "", ImagePullOptions{})
28 28
 	assert.Check(t, is.ErrorContains(err, "invalid reference format"))
29 29
 }
30 30
 
... ...
@@ -32,7 +31,7 @@ func TestImagePullAnyError(t *testing.T) {
32 32
 	client := &Client{
33 33
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
34 34
 	}
35
-	_, err := client.ImagePull(context.Background(), "myimage", image.PullOptions{})
35
+	_, err := client.ImagePull(context.Background(), "myimage", ImagePullOptions{})
36 36
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
37 37
 }
38 38
 
... ...
@@ -40,7 +39,7 @@ func TestImagePullStatusUnauthorizedError(t *testing.T) {
40 40
 	client := &Client{
41 41
 		client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")),
42 42
 	}
43
-	_, err := client.ImagePull(context.Background(), "myimage", image.PullOptions{})
43
+	_, err := client.ImagePull(context.Background(), "myimage", ImagePullOptions{})
44 44
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsUnauthorized))
45 45
 }
46 46
 
... ...
@@ -48,7 +47,7 @@ func TestImagePullWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) {
48 48
 	client := &Client{
49 49
 		client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")),
50 50
 	}
51
-	_, err := client.ImagePull(context.Background(), "myimage", image.PullOptions{
51
+	_, err := client.ImagePull(context.Background(), "myimage", ImagePullOptions{
52 52
 		PrivilegeFunc: func(_ context.Context) (string, error) {
53 53
 			return "", errors.New("error requesting privilege")
54 54
 		},
... ...
@@ -60,7 +59,7 @@ func TestImagePullWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T)
60 60
 	client := &Client{
61 61
 		client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")),
62 62
 	}
63
-	_, err := client.ImagePull(context.Background(), "myimage", image.PullOptions{
63
+	_, err := client.ImagePull(context.Background(), "myimage", ImagePullOptions{
64 64
 		PrivilegeFunc: staticAuth("a-auth-header"),
65 65
 	})
66 66
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsUnauthorized))
... ...
@@ -100,7 +99,7 @@ func TestImagePullWithPrivilegedFuncNoError(t *testing.T) {
100 100
 			}, nil
101 101
 		}),
102 102
 	}
103
-	resp, err := client.ImagePull(context.Background(), "myimage", image.PullOptions{
103
+	resp, err := client.ImagePull(context.Background(), "myimage", ImagePullOptions{
104 104
 		RegistryAuth:  invalidAuth,
105 105
 		PrivilegeFunc: staticAuth(validAuth),
106 106
 	})
... ...
@@ -193,7 +192,7 @@ func TestImagePullWithoutErrors(t *testing.T) {
193 193
 					}, nil
194 194
 				}),
195 195
 			}
196
-			resp, err := client.ImagePull(context.Background(), pullCase.reference, image.PullOptions{
196
+			resp, err := client.ImagePull(context.Background(), pullCase.reference, ImagePullOptions{
197 197
 				All: pullCase.all,
198 198
 			})
199 199
 			assert.NilError(t, err)
... ...
@@ -11,7 +11,6 @@ import (
11 11
 
12 12
 	cerrdefs "github.com/containerd/errdefs"
13 13
 	"github.com/distribution/reference"
14
-	"github.com/moby/moby/api/types/image"
15 14
 	"github.com/moby/moby/api/types/registry"
16 15
 )
17 16
 
... ...
@@ -19,7 +18,7 @@ import (
19 19
 // It executes the privileged function if the operation is unauthorized
20 20
 // and it tries one more time.
21 21
 // It's up to the caller to handle the [io.ReadCloser] and close it.
22
-func (cli *Client) ImagePush(ctx context.Context, image string, options image.PushOptions) (io.ReadCloser, error) {
22
+func (cli *Client) ImagePush(ctx context.Context, image string, options ImagePushOptions) (io.ReadCloser, error) {
23 23
 	ref, err := reference.ParseNormalizedNamed(image)
24 24
 	if err != nil {
25 25
 		return nil, err
26 26
new file mode 100644
... ...
@@ -0,0 +1,26 @@
0
+package client
1
+
2
+import (
3
+	"context"
4
+
5
+	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
6
+)
7
+
8
+// ImagePushOptions holds information to push images.
9
+type ImagePushOptions struct {
10
+	All          bool
11
+	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
12
+
13
+	// PrivilegeFunc is a function that clients can supply to retry operations
14
+	// after getting an authorization error. This function returns the registry
15
+	// authentication header value in base64 encoded format, or an error if the
16
+	// privilege request fails.
17
+	//
18
+	// For details, refer to [github.com/moby/moby/api/types/registry.RequestAuthConfig].
19
+	PrivilegeFunc func(context.Context) (string, error)
20
+
21
+	// Platform is an optional field that selects a specific platform to push
22
+	// when the image is a multi-platform image.
23
+	// Using this will only push a single platform-specific manifest.
24
+	Platform *ocispec.Platform `json:",omitempty"`
25
+}
... ...
@@ -11,7 +11,6 @@ import (
11 11
 	"testing"
12 12
 
13 13
 	cerrdefs "github.com/containerd/errdefs"
14
-	"github.com/moby/moby/api/types/image"
15 14
 	"github.com/moby/moby/api/types/registry"
16 15
 	"gotest.tools/v3/assert"
17 16
 	is "gotest.tools/v3/assert/cmp"
... ...
@@ -24,10 +23,10 @@ func TestImagePushReferenceError(t *testing.T) {
24 24
 		}),
25 25
 	}
26 26
 	// An empty reference is an invalid reference
27
-	_, err := client.ImagePush(context.Background(), "", image.PushOptions{})
27
+	_, err := client.ImagePush(context.Background(), "", ImagePushOptions{})
28 28
 	assert.Check(t, is.ErrorContains(err, "invalid reference format"))
29 29
 	// An canonical reference cannot be pushed
30
-	_, err = client.ImagePush(context.Background(), "repo@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", image.PushOptions{})
30
+	_, err = client.ImagePush(context.Background(), "repo@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", ImagePushOptions{})
31 31
 	assert.Check(t, is.Error(err, "cannot push a digest reference"))
32 32
 }
33 33
 
... ...
@@ -35,7 +34,7 @@ func TestImagePushAnyError(t *testing.T) {
35 35
 	client := &Client{
36 36
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
37 37
 	}
38
-	_, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{})
38
+	_, err := client.ImagePush(context.Background(), "myimage", ImagePushOptions{})
39 39
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
40 40
 }
41 41
 
... ...
@@ -43,7 +42,7 @@ func TestImagePushStatusUnauthorizedError(t *testing.T) {
43 43
 	client := &Client{
44 44
 		client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")),
45 45
 	}
46
-	_, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{})
46
+	_, err := client.ImagePush(context.Background(), "myimage", ImagePushOptions{})
47 47
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsUnauthorized))
48 48
 }
49 49
 
... ...
@@ -54,7 +53,7 @@ func TestImagePushWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) {
54 54
 	privilegeFunc := func(_ context.Context) (string, error) {
55 55
 		return "", errors.New("Error requesting privilege")
56 56
 	}
57
-	_, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{
57
+	_, err := client.ImagePush(context.Background(), "myimage", ImagePushOptions{
58 58
 		PrivilegeFunc: privilegeFunc,
59 59
 	})
60 60
 	assert.Check(t, is.Error(err, "Error requesting privilege"))
... ...
@@ -67,7 +66,7 @@ func TestImagePushWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T)
67 67
 	privilegeFunc := func(_ context.Context) (string, error) {
68 68
 		return "a-auth-header", nil
69 69
 	}
70
-	_, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{
70
+	_, err := client.ImagePush(context.Background(), "myimage", ImagePushOptions{
71 71
 		PrivilegeFunc: privilegeFunc,
72 72
 	})
73 73
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsUnauthorized))
... ...
@@ -103,7 +102,7 @@ func TestImagePushWithPrivilegedFuncNoError(t *testing.T) {
103 103
 			}, nil
104 104
 		}),
105 105
 	}
106
-	resp, err := client.ImagePush(context.Background(), "myname/myimage:tag", image.PushOptions{
106
+	resp, err := client.ImagePush(context.Background(), "myname/myimage:tag", ImagePushOptions{
107 107
 		RegistryAuth:  invalidAuth,
108 108
 		PrivilegeFunc: staticAuth(validAuth),
109 109
 	})
... ...
@@ -193,7 +192,7 @@ func TestImagePushWithoutErrors(t *testing.T) {
193 193
 					}, nil
194 194
 				}),
195 195
 			}
196
-			resp, err := client.ImagePush(context.Background(), tc.reference, image.PushOptions{
196
+			resp, err := client.ImagePush(context.Background(), tc.reference, ImagePushOptions{
197 197
 				All: tc.all,
198 198
 			})
199 199
 			assert.NilError(t, err)
... ...
@@ -9,7 +9,7 @@ import (
9 9
 )
10 10
 
11 11
 // ImageRemove removes an image from the docker host.
12
-func (cli *Client) ImageRemove(ctx context.Context, imageID string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
12
+func (cli *Client) ImageRemove(ctx context.Context, imageID string, options ImageRemoveOptions) ([]image.DeleteResponse, error) {
13 13
 	query := url.Values{}
14 14
 
15 15
 	if options.Force {
16 16
new file mode 100644
... ...
@@ -0,0 +1,10 @@
0
+package client
1
+
2
+import ocispec "github.com/opencontainers/image-spec/specs-go/v1"
3
+
4
+// ImageRemoveOptions holds parameters to remove images.
5
+type ImageRemoveOptions struct {
6
+	Platforms     []ocispec.Platform
7
+	Force         bool
8
+	PruneChildren bool
9
+}
... ...
@@ -22,7 +22,7 @@ func TestImageRemoveError(t *testing.T) {
22 22
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
23 23
 	}
24 24
 
25
-	_, err := client.ImageRemove(context.Background(), "image_id", image.RemoveOptions{})
25
+	_, err := client.ImageRemove(context.Background(), "image_id", ImageRemoveOptions{})
26 26
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
27 27
 }
28 28
 
... ...
@@ -31,7 +31,7 @@ func TestImageRemoveImageNotFound(t *testing.T) {
31 31
 		client: newMockClient(errorMock(http.StatusNotFound, "no such image: unknown")),
32 32
 	}
33 33
 
34
-	_, err := client.ImageRemove(context.Background(), "unknown", image.RemoveOptions{})
34
+	_, err := client.ImageRemove(context.Background(), "unknown", ImageRemoveOptions{})
35 35
 	assert.Check(t, is.ErrorContains(err, "no such image: unknown"))
36 36
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
37 37
 }
... ...
@@ -105,7 +105,7 @@ func TestImageRemove(t *testing.T) {
105 105
 			}),
106 106
 		}
107 107
 
108
-		opts := image.RemoveOptions{
108
+		opts := ImageRemoveOptions{
109 109
 			Force:         removeCase.force,
110 110
 			PruneChildren: removeCase.pruneChildren,
111 111
 		}
... ...
@@ -3,7 +3,6 @@ package client
3 3
 import (
4 4
 	"fmt"
5 5
 
6
-	"github.com/moby/moby/api/types/image"
7 6
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
8 7
 )
9 8
 
... ...
@@ -29,5 +28,11 @@ func ImageSaveWithPlatforms(platforms ...ocispec.Platform) ImageSaveOption {
29 29
 }
30 30
 
31 31
 type imageSaveOpts struct {
32
-	apiOptions image.SaveOptions
32
+	apiOptions imageSaveOptions
33
+}
34
+
35
+type imageSaveOptions struct {
36
+	// Platforms selects the platforms to save if the image is a
37
+	// multi-platform image and has multiple variants.
38
+	Platforms []ocispec.Platform
33 39
 }
... ...
@@ -18,6 +18,7 @@ import (
18 18
 	"github.com/moby/moby/v2/daemon/internal/image"
19 19
 	"github.com/moby/moby/v2/daemon/internal/metrics"
20 20
 	"github.com/moby/moby/v2/daemon/internal/stringid"
21
+	"github.com/moby/moby/v2/daemon/server/imagebackend"
21 22
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
22 23
 )
23 24
 
... ...
@@ -54,7 +55,7 @@ import (
54 54
 // conflict will not be reported.
55 55
 //
56 56
 // TODO(thaJeztah): image delete should send prometheus counters; see https://github.com/moby/moby/issues/45268
57
-func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, options imagetypes.RemoveOptions) (response []imagetypes.DeleteResponse, retErr error) {
57
+func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, options imagebackend.RemoveOptions) (response []imagetypes.DeleteResponse, retErr error) {
58 58
 	start := time.Now()
59 59
 	defer func() {
60 60
 		if retErr == nil {
... ...
@@ -8,10 +8,10 @@ import (
8 8
 	"github.com/containerd/containerd/v2/core/metadata"
9 9
 	"github.com/containerd/containerd/v2/pkg/namespaces"
10 10
 	"github.com/containerd/log/logtest"
11
-	"github.com/moby/moby/api/types/image"
12 11
 	"github.com/moby/moby/v2/daemon/container"
13 12
 	daemonevents "github.com/moby/moby/v2/daemon/events"
14 13
 	dimages "github.com/moby/moby/v2/daemon/images"
14
+	"github.com/moby/moby/v2/daemon/server/imagebackend"
15 15
 	"gotest.tools/v3/assert"
16 16
 	is "gotest.tools/v3/assert/cmp"
17 17
 )
... ...
@@ -235,7 +235,7 @@ func TestImageDelete(t *testing.T) {
235 235
 				}
236 236
 			}
237 237
 
238
-			_, err := service.ImageDelete(ctx, tc.ref, image.RemoveOptions{})
238
+			_, err := service.ImageDelete(ctx, tc.ref, imagebackend.RemoveOptions{})
239 239
 			if tc.err == nil {
240 240
 				assert.NilError(t, err)
241 241
 			} else {
... ...
@@ -22,6 +22,7 @@ import (
22 22
 	imagetypes "github.com/moby/moby/api/types/image"
23 23
 	"github.com/moby/moby/v2/daemon/internal/timestamp"
24 24
 	"github.com/moby/moby/v2/daemon/server/backend"
25
+	"github.com/moby/moby/v2/daemon/server/imagebackend"
25 26
 	"github.com/moby/moby/v2/errdefs"
26 27
 	"github.com/opencontainers/go-digest"
27 28
 	"github.com/opencontainers/image-spec/identity"
... ...
@@ -62,7 +63,7 @@ func (r byCreated) Less(i, j int) bool { return r[i].Created < r[j].Created }
62 62
 //
63 63
 // TODO(thaJeztah): verify behavior of `RepoDigests` and `RepoTags` for images without (untagged) or multiple tags; see https://github.com/moby/moby/issues/43861
64 64
 // TODO(thaJeztah): verify "Size" vs "VirtualSize" in images; see https://github.com/moby/moby/issues/43862
65
-func (i *ImageService) Images(ctx context.Context, opts imagetypes.ListOptions) ([]*imagetypes.Summary, error) {
65
+func (i *ImageService) Images(ctx context.Context, opts imagebackend.ListOptions) ([]*imagetypes.Summary, error) {
66 66
 	if err := opts.Filters.Validate(acceptedImageFilterTags); err != nil {
67 67
 		return nil, err
68 68
 	}
... ...
@@ -375,7 +376,7 @@ func (i *ImageService) multiPlatformSummary(ctx context.Context, img c8dimages.I
375 375
 // It also returns the chainIDs of all the layers of the image (including all its platforms).
376 376
 // All return values will be nil if the image should be skipped.
377 377
 func (i *ImageService) imageSummary(ctx context.Context, img c8dimages.Image, platformMatcher platforms.MatchComparer,
378
-	opts imagetypes.ListOptions, tagsByDigest map[digest.Digest][]string,
378
+	opts imagebackend.ListOptions, tagsByDigest map[digest.Digest][]string,
379 379
 ) (*imagetypes.Summary, *multiPlatformSummary, error) {
380 380
 	summary, err := i.multiPlatformSummary(ctx, img, platformMatcher)
381 381
 	if err != nil {
... ...
@@ -17,6 +17,7 @@ import (
17 17
 	"github.com/containerd/platforms"
18 18
 	imagetypes "github.com/moby/moby/api/types/image"
19 19
 	"github.com/moby/moby/v2/daemon/container"
20
+	"github.com/moby/moby/v2/daemon/server/imagebackend"
20 21
 	"github.com/moby/moby/v2/internal/testutils/specialimage"
21 22
 	"github.com/opencontainers/go-digest"
22 23
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
... ...
@@ -104,7 +105,7 @@ func BenchmarkImageList(b *testing.B) {
104 104
 
105 105
 		b.Run(strconv.Itoa(count)+"-images", func(b *testing.B) {
106 106
 			for i := 0; i < b.N; i++ {
107
-				_, err := imgSvc.Images(ctx, imagetypes.ListOptions{All: true, SharedSize: true})
107
+				_, err := imgSvc.Images(ctx, imagebackend.ListOptions{All: true, SharedSize: true})
108 108
 				assert.NilError(b, err)
109 109
 			}
110 110
 		})
... ...
@@ -129,7 +130,7 @@ func TestImageListCheckTotalSize(t *testing.T) {
129 129
 	img, err := service.images.Create(ctx, imagesFromIndex(twoplatform)[0])
130 130
 	assert.NilError(t, err)
131 131
 
132
-	all, err := service.Images(ctx, imagetypes.ListOptions{Manifests: true, SharedSize: true})
132
+	all, err := service.Images(ctx, imagebackend.ListOptions{Manifests: true, SharedSize: true})
133 133
 	assert.NilError(t, err)
134 134
 
135 135
 	assert.Check(t, is.Len(all, 1))
... ...
@@ -189,7 +190,7 @@ func TestImageListCheckTotalSize(t *testing.T) {
189 189
 			assert.NilError(t, err, "failed to delete layer %s", layer.Digest)
190 190
 		}
191 191
 
192
-		all, err := service.Images(ctx, imagetypes.ListOptions{Manifests: true, SharedSize: true})
192
+		all, err := service.Images(ctx, imagebackend.ListOptions{Manifests: true, SharedSize: true})
193 193
 		assert.NilError(t, err)
194 194
 
195 195
 		assert.Assert(t, is.Len(all, 1))
... ...
@@ -377,7 +378,7 @@ func TestImageList(t *testing.T) {
377 377
 				assert.NilError(t, err)
378 378
 			}
379 379
 
380
-			opts := imagetypes.ListOptions{
380
+			opts := imagebackend.ListOptions{
381 381
 				Manifests:  true,
382 382
 				SharedSize: true,
383 383
 			}
... ...
@@ -15,8 +15,8 @@ import (
15 15
 	cerrdefs "github.com/containerd/errdefs"
16 16
 	"github.com/containerd/platforms"
17 17
 	"github.com/moby/go-archive"
18
-	"github.com/moby/moby/api/types/image"
19 18
 	"github.com/moby/moby/v2/daemon/server/backend"
19
+	"github.com/moby/moby/v2/daemon/server/imagebackend"
20 20
 	"github.com/moby/moby/v2/internal/testutils/labelstore"
21 21
 	"github.com/moby/moby/v2/internal/testutils/specialimage"
22 22
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
... ...
@@ -55,10 +55,10 @@ func TestImageLoad(t *testing.T) {
55 55
 
56 56
 	cleanup := func(ctx context.Context, t *testing.T) {
57 57
 		// Remove all existing images to start fresh
58
-		images, err := imgSvc.Images(ctx, image.ListOptions{})
58
+		images, err := imgSvc.Images(ctx, imagebackend.ListOptions{})
59 59
 		assert.NilError(t, err)
60 60
 		for _, img := range images {
61
-			_, err := imgSvc.ImageDelete(ctx, img.ID, image.RemoveOptions{PruneChildren: true})
61
+			_, err := imgSvc.ImageDelete(ctx, img.ID, imagebackend.RemoveOptions{PruneChildren: true})
62 62
 			assert.NilError(t, err)
63 63
 		}
64 64
 
... ...
@@ -8,6 +8,7 @@ import (
8 8
 	"github.com/moby/moby/api/types/filters"
9 9
 	"github.com/moby/moby/api/types/image"
10 10
 	"github.com/moby/moby/v2/daemon/server/backend"
11
+	"github.com/moby/moby/v2/daemon/server/imagebackend"
11 12
 	"github.com/pkg/errors"
12 13
 	"golang.org/x/sync/errgroup"
13 14
 )
... ...
@@ -54,7 +55,7 @@ func (daemon *Daemon) containerDiskUsage(ctx context.Context) (*backend.Containe
54 54
 func (daemon *Daemon) imageDiskUsage(ctx context.Context) ([]*image.Summary, error) {
55 55
 	imgs, _, err := daemon.usageImages.Do(ctx, struct{}{}, func(ctx context.Context) ([]*image.Summary, error) {
56 56
 		// Get all top images with extra attributes
57
-		imgs, err := daemon.imageService.Images(ctx, image.ListOptions{
57
+		imgs, err := daemon.imageService.Images(ctx, imagebackend.ListOptions{
58 58
 			Filters:    filters.NewArgs(),
59 59
 			SharedSize: true,
60 60
 		})
... ...
@@ -16,6 +16,7 @@ import (
16 16
 	"github.com/moby/moby/v2/daemon/internal/image"
17 17
 	"github.com/moby/moby/v2/daemon/internal/layer"
18 18
 	"github.com/moby/moby/v2/daemon/server/backend"
19
+	"github.com/moby/moby/v2/daemon/server/imagebackend"
19 20
 	"github.com/opencontainers/go-digest"
20 21
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
21 22
 )
... ...
@@ -29,10 +30,10 @@ type ImageService interface {
29 29
 	PullImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
30 30
 	PushImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
31 31
 	CreateImage(ctx context.Context, config []byte, parent string, contentStoreDigest digest.Digest) (builder.Image, error)
32
-	ImageDelete(ctx context.Context, imageRef string, options imagetype.RemoveOptions) ([]imagetype.DeleteResponse, error)
32
+	ImageDelete(ctx context.Context, imageRef string, options imagebackend.RemoveOptions) ([]imagetype.DeleteResponse, error)
33 33
 	ExportImage(ctx context.Context, names []string, platformList []ocispec.Platform, outStream io.Writer) error
34 34
 	LoadImage(ctx context.Context, inTar io.ReadCloser, platformList []ocispec.Platform, outStream io.Writer, quiet bool) error
35
-	Images(ctx context.Context, opts imagetype.ListOptions) ([]*imagetype.Summary, error)
35
+	Images(ctx context.Context, opts imagebackend.ListOptions) ([]*imagetype.Summary, error)
36 36
 	LogImageEvent(ctx context.Context, imageID, refName string, action events.Action)
37 37
 	CountImages(ctx context.Context) int
38 38
 	ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*imagetype.PruneReport, error)
... ...
@@ -14,6 +14,7 @@ import (
14 14
 	"github.com/moby/moby/v2/daemon/internal/metrics"
15 15
 	"github.com/moby/moby/v2/daemon/internal/stringid"
16 16
 	"github.com/moby/moby/v2/daemon/server/backend"
17
+	"github.com/moby/moby/v2/daemon/server/imagebackend"
17 18
 	"github.com/moby/moby/v2/errdefs"
18 19
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
19 20
 	"github.com/pkg/errors"
... ...
@@ -63,7 +64,7 @@ const (
63 63
 // If options.PruneChildren is true, ancestor images are attempted to be deleted quietly,
64 64
 // meaning any delete conflicts will cause the image to not be deleted and the
65 65
 // conflict will not be reported.
66
-func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, options imagetypes.RemoveOptions) ([]imagetypes.DeleteResponse, error) {
66
+func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, options imagebackend.RemoveOptions) ([]imagetypes.DeleteResponse, error) {
67 67
 	start := time.Now()
68 68
 	records := []imagetypes.DeleteResponse{}
69 69
 
... ...
@@ -14,6 +14,7 @@ import (
14 14
 	"github.com/moby/moby/v2/daemon/internal/layer"
15 15
 	"github.com/moby/moby/v2/daemon/internal/timestamp"
16 16
 	"github.com/moby/moby/v2/daemon/server/backend"
17
+	"github.com/moby/moby/v2/daemon/server/imagebackend"
17 18
 )
18 19
 
19 20
 var acceptedImageFilterTags = map[string]bool{
... ...
@@ -34,7 +35,7 @@ func (r byCreated) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
34 34
 func (r byCreated) Less(i, j int) bool { return r[i].Created < r[j].Created }
35 35
 
36 36
 // Images returns a filtered list of images.
37
-func (i *ImageService) Images(ctx context.Context, opts imagetypes.ListOptions) ([]*imagetypes.Summary, error) {
37
+func (i *ImageService) Images(ctx context.Context, opts imagebackend.ListOptions) ([]*imagetypes.Summary, error) {
38 38
 	if err := opts.Filters.Validate(acceptedImageFilterTags); err != nil {
39 39
 		return nil, err
40 40
 	}
... ...
@@ -14,6 +14,7 @@ import (
14 14
 	"github.com/moby/moby/v2/daemon/internal/image"
15 15
 	"github.com/moby/moby/v2/daemon/internal/layer"
16 16
 	"github.com/moby/moby/v2/daemon/internal/timestamp"
17
+	"github.com/moby/moby/v2/daemon/server/imagebackend"
17 18
 	"github.com/moby/moby/v2/errdefs"
18 19
 	"github.com/opencontainers/go-digest"
19 20
 	"github.com/pkg/errors"
... ...
@@ -114,7 +115,7 @@ deleteImagesLoop:
114 114
 
115 115
 			if shouldDelete {
116 116
 				for _, ref := range refs {
117
-					imgDel, err := i.ImageDelete(ctx, ref.String(), imagetypes.RemoveOptions{
117
+					imgDel, err := i.ImageDelete(ctx, ref.String(), imagebackend.RemoveOptions{
118 118
 						PruneChildren: true,
119 119
 					})
120 120
 					if imageDeleteFailed(ref.String(), err) {
... ...
@@ -125,7 +126,7 @@ deleteImagesLoop:
125 125
 			}
126 126
 		} else {
127 127
 			hex := id.Digest().Encoded()
128
-			imgDel, err := i.ImageDelete(ctx, hex, imagetypes.RemoveOptions{
128
+			imgDel, err := i.ImageDelete(ctx, hex, imagebackend.RemoveOptions{
129 129
 				PruneChildren: true,
130 130
 			})
131 131
 			if imageDeleteFailed(hex, err) {
132 132
new file mode 100644
... ...
@@ -0,0 +1,27 @@
0
+package imagebackend
1
+
2
+import (
3
+	"github.com/moby/moby/api/types/filters"
4
+	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
5
+)
6
+
7
+type RemoveOptions struct {
8
+	Platforms     []ocispec.Platform
9
+	Force         bool
10
+	PruneChildren bool
11
+}
12
+
13
+type ListOptions struct {
14
+	// All controls whether all images in the graph are filtered, or just
15
+	// the heads.
16
+	All bool
17
+
18
+	// Filters is a JSON-encoded set of filter arguments.
19
+	Filters filters.Args
20
+
21
+	// SharedSize indicates whether the shared size of images should be computed.
22
+	SharedSize bool
23
+
24
+	// Manifests indicates whether the image manifests should be returned.
25
+	Manifests bool
26
+}
... ...
@@ -10,6 +10,7 @@ import (
10 10
 	"github.com/moby/moby/api/types/registry"
11 11
 	dockerimage "github.com/moby/moby/v2/daemon/internal/image"
12 12
 	"github.com/moby/moby/v2/daemon/server/backend"
13
+	"github.com/moby/moby/v2/daemon/server/imagebackend"
13 14
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
14 15
 )
15 16
 
... ...
@@ -22,9 +23,9 @@ type Backend interface {
22 22
 }
23 23
 
24 24
 type imageBackend interface {
25
-	ImageDelete(ctx context.Context, imageRef string, options image.RemoveOptions) ([]image.DeleteResponse, error)
25
+	ImageDelete(ctx context.Context, imageRef string, options imagebackend.RemoveOptions) ([]image.DeleteResponse, error)
26 26
 	ImageHistory(ctx context.Context, imageName string, platform *ocispec.Platform) ([]*image.HistoryResponseItem, error)
27
-	Images(ctx context.Context, opts image.ListOptions) ([]*image.Summary, error)
27
+	Images(ctx context.Context, opts imagebackend.ListOptions) ([]*image.Summary, error)
28 28
 	GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*dockerimage.Image, error)
29 29
 	ImageInspect(ctx context.Context, refOrID string, options backend.ImageInspectOpts) (*image.InspectResponse, error)
30 30
 	TagImage(ctx context.Context, id dockerimage.ID, newRef reference.Named) error
... ...
@@ -15,13 +15,13 @@ import (
15 15
 	"github.com/moby/moby/api/pkg/progress"
16 16
 	"github.com/moby/moby/api/pkg/streamformatter"
17 17
 	"github.com/moby/moby/api/types/filters"
18
-	imagetypes "github.com/moby/moby/api/types/image"
19 18
 	"github.com/moby/moby/api/types/registry"
20 19
 	"github.com/moby/moby/api/types/versions"
21 20
 	"github.com/moby/moby/v2/daemon/builder/remotecontext"
22 21
 	"github.com/moby/moby/v2/daemon/internal/image"
23 22
 	"github.com/moby/moby/v2/daemon/server/backend"
24 23
 	"github.com/moby/moby/v2/daemon/server/httputils"
24
+	"github.com/moby/moby/v2/daemon/server/imagebackend"
25 25
 	"github.com/moby/moby/v2/dockerversion"
26 26
 	"github.com/moby/moby/v2/errdefs"
27 27
 	"github.com/moby/moby/v2/pkg/ioutils"
... ...
@@ -328,7 +328,7 @@ func (ir *imageRouter) deleteImages(ctx context.Context, w http.ResponseWriter,
328 328
 		p = val
329 329
 	}
330 330
 
331
-	list, err := ir.backend.ImageDelete(ctx, name, imagetypes.RemoveOptions{
331
+	list, err := ir.backend.ImageDelete(ctx, name, imagebackend.RemoveOptions{
332 332
 		Force:         force,
333 333
 		PruneChildren: prune,
334 334
 		Platforms:     p,
... ...
@@ -442,7 +442,7 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
442 442
 		manifests = httputils.BoolValue(r, "manifests")
443 443
 	}
444 444
 
445
-	images, err := ir.backend.Images(ctx, imagetypes.ListOptions{
445
+	images, err := ir.backend.Images(ctx, imagebackend.ListOptions{
446 446
 		All:        httputils.BoolValue(r, "all"),
447 447
 		Filters:    imageFilters,
448 448
 		SharedSize: sharedSize,
... ...
@@ -11,7 +11,7 @@ import (
11 11
 	"strings"
12 12
 	"testing"
13 13
 
14
-	"github.com/moby/moby/api/types/image"
14
+	"github.com/moby/moby/client"
15 15
 	"github.com/moby/moby/v2/testutil"
16 16
 	"github.com/moby/moby/v2/testutil/fakecontext"
17 17
 	"github.com/moby/moby/v2/testutil/fakegit"
... ...
@@ -327,15 +327,15 @@ func (s *DockerAPISuite) TestBuildOnBuildCache(c *testing.T) {
327 327
 }
328 328
 
329 329
 func (s *DockerRegistrySuite) TestBuildCopyFromForcePull(c *testing.T) {
330
-	client := testEnv.APIClient()
330
+	apiClient := testEnv.APIClient()
331 331
 
332 332
 	repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
333 333
 	// tag the image to upload it to the private registry
334 334
 	ctx := testutil.GetContext(c)
335
-	err := client.ImageTag(ctx, "busybox", repoName)
335
+	err := apiClient.ImageTag(ctx, "busybox", repoName)
336 336
 	assert.Check(c, err)
337 337
 	// push the image to the registry
338
-	rc, err := client.ImagePush(ctx, repoName, image.PushOptions{RegistryAuth: "{}"})
338
+	rc, err := apiClient.ImagePush(ctx, repoName, client.ImagePushOptions{RegistryAuth: "{}"})
339 339
 	assert.Check(c, err)
340 340
 	_, err = io.Copy(io.Discard, rc)
341 341
 	assert.Check(c, err)
... ...
@@ -6,7 +6,6 @@ import (
6 6
 	"strings"
7 7
 	"testing"
8 8
 
9
-	"github.com/moby/moby/api/types/image"
10 9
 	"github.com/moby/moby/client"
11 10
 	"github.com/moby/moby/v2/integration-cli/cli"
12 11
 	"github.com/moby/moby/v2/integration-cli/cli/build"
... ...
@@ -51,13 +50,13 @@ func (s *DockerAPISuite) TestAPIImagesDelete(c *testing.T) {
51 51
 
52 52
 	cli.DockerCmd(c, "tag", name, "test:tag1")
53 53
 
54
-	_, err = apiClient.ImageRemove(testutil.GetContext(c), id, image.RemoveOptions{})
54
+	_, err = apiClient.ImageRemove(testutil.GetContext(c), id, client.ImageRemoveOptions{})
55 55
 	assert.ErrorContains(c, err, "unable to delete")
56 56
 
57
-	_, err = apiClient.ImageRemove(testutil.GetContext(c), "test:noexist", image.RemoveOptions{})
57
+	_, err = apiClient.ImageRemove(testutil.GetContext(c), "test:noexist", client.ImageRemoveOptions{})
58 58
 	assert.ErrorContains(c, err, "No such image")
59 59
 
60
-	_, err = apiClient.ImageRemove(testutil.GetContext(c), "test:tag1", image.RemoveOptions{})
60
+	_, err = apiClient.ImageRemove(testutil.GetContext(c), "test:tag1", client.ImageRemoveOptions{})
61 61
 	assert.NilError(c, err)
62 62
 }
63 63
 
... ...
@@ -103,7 +102,7 @@ func (s *DockerAPISuite) TestAPIImagesSizeCompatibility(c *testing.T) {
103 103
 	apiclient := testEnv.APIClient()
104 104
 	defer apiclient.Close()
105 105
 
106
-	images, err := apiclient.ImageList(testutil.GetContext(c), image.ListOptions{})
106
+	images, err := apiclient.ImageList(testutil.GetContext(c), client.ImageListOptions{})
107 107
 	assert.NilError(c, err)
108 108
 	assert.Assert(c, len(images) != 0)
109 109
 	for _, img := range images {
... ...
@@ -114,7 +113,7 @@ func (s *DockerAPISuite) TestAPIImagesSizeCompatibility(c *testing.T) {
114 114
 	assert.NilError(c, err)
115 115
 	defer apiclient.Close()
116 116
 
117
-	v124Images, err := apiclient.ImageList(testutil.GetContext(c), image.ListOptions{})
117
+	v124Images, err := apiclient.ImageList(testutil.GetContext(c), client.ImageListOptions{})
118 118
 	assert.NilError(c, err)
119 119
 	assert.Assert(c, len(v124Images) != 0)
120 120
 	for _, img := range v124Images {
... ...
@@ -826,7 +826,7 @@ func TestBuildHistoryDoesNotPreventRemoval(t *testing.T) {
826 826
 	err := buildImage("history-a")
827 827
 	assert.NilError(t, err)
828 828
 
829
-	resp, err := apiClient.ImageRemove(ctx, "history-a", image.RemoveOptions{})
829
+	resp, err := apiClient.ImageRemove(ctx, "history-a", client.ImageRemoveOptions{})
830 830
 	assert.NilError(t, err)
831 831
 	assert.Check(t, slices.ContainsFunc(resp, func(r image.DeleteResponse) bool {
832 832
 		return r.Deleted != ""
... ...
@@ -6,7 +6,7 @@ import (
6 6
 	"testing"
7 7
 
8 8
 	"github.com/moby/moby/api/types/filters"
9
-	"github.com/moby/moby/api/types/image"
9
+	"github.com/moby/moby/client"
10 10
 	"github.com/moby/moby/client/pkg/jsonmessage"
11 11
 	"github.com/moby/moby/v2/integration/internal/container"
12 12
 	"github.com/moby/moby/v2/testutil"
... ...
@@ -30,10 +30,10 @@ func TestExportContainerAndImportImage(t *testing.T) {
30 30
 	reference := "repo/" + strings.ToLower(t.Name()) + ":v1"
31 31
 	exportResp, err := apiClient.ContainerExport(ctx, cID)
32 32
 	assert.NilError(t, err)
33
-	importResp, err := apiClient.ImageImport(ctx, image.ImportSource{
33
+	importResp, err := apiClient.ImageImport(ctx, client.ImageImportSource{
34 34
 		Source:     exportResp,
35 35
 		SourceName: "-",
36
-	}, reference, image.ImportOptions{})
36
+	}, reference, client.ImageImportOptions{})
37 37
 	assert.NilError(t, err)
38 38
 
39 39
 	// If the import is successfully, then the message output should contain
... ...
@@ -44,7 +44,7 @@ func TestExportContainerAndImportImage(t *testing.T) {
44 44
 	err = dec.Decode(&jm)
45 45
 	assert.NilError(t, err)
46 46
 
47
-	images, err := apiClient.ImageList(ctx, image.ListOptions{
47
+	images, err := apiClient.ImageList(ctx, client.ImageListOptions{
48 48
 		Filters: filters.NewArgs(filters.Arg("reference", reference)),
49 49
 	})
50 50
 	assert.NilError(t, err)
... ...
@@ -17,9 +17,9 @@ import (
17 17
 	cerrdefs "github.com/containerd/errdefs"
18 18
 	"github.com/moby/moby/api/pkg/stdcopy"
19 19
 	containertypes "github.com/moby/moby/api/types/container"
20
-	"github.com/moby/moby/api/types/image"
21 20
 	"github.com/moby/moby/api/types/mount"
22 21
 	"github.com/moby/moby/api/types/volume"
22
+	"github.com/moby/moby/client"
23 23
 	"github.com/moby/moby/v2/daemon/config"
24 24
 	"github.com/moby/moby/v2/integration/internal/container"
25 25
 	"github.com/moby/moby/v2/integration/internal/process"
... ...
@@ -297,12 +297,12 @@ func TestDaemonProxy(t *testing.T) {
297 297
 		assert.Check(t, is.Equal(info.HTTPSProxy, proxyServer.URL))
298 298
 		assert.Check(t, is.Equal(info.NoProxy, "example.com"))
299 299
 
300
-		_, err := c.ImagePull(ctx, "example.org:5000/some/image:latest", image.PullOptions{})
300
+		_, err := c.ImagePull(ctx, "example.org:5000/some/image:latest", client.ImagePullOptions{})
301 301
 		assert.ErrorContains(t, err, "", "pulling should have failed")
302 302
 		assert.Equal(t, received, "example.org:5000")
303 303
 
304 304
 		// Test NoProxy: example.com should not hit the proxy, and "received" variable should not be changed.
305
-		_, err = c.ImagePull(ctx, "example.com/some/image:latest", image.PullOptions{})
305
+		_, err = c.ImagePull(ctx, "example.com/some/image:latest", client.ImagePullOptions{})
306 306
 		assert.ErrorContains(t, err, "", "pulling should have failed")
307 307
 		assert.Equal(t, received, "example.org:5000", "should not have used proxy")
308 308
 	})
... ...
@@ -349,12 +349,12 @@ func TestDaemonProxy(t *testing.T) {
349 349
 		ok, logs := d.ScanLogsT(ctx, t, daemon.ScanLogsMatchString(userPass))
350 350
 		assert.Assert(t, !ok, "logs should not contain the non-sanitized proxy URL: %s", logs)
351 351
 
352
-		_, err := c.ImagePull(ctx, "example.org:5001/some/image:latest", image.PullOptions{})
352
+		_, err := c.ImagePull(ctx, "example.org:5001/some/image:latest", client.ImagePullOptions{})
353 353
 		assert.ErrorContains(t, err, "", "pulling should have failed")
354 354
 		assert.Equal(t, received, "example.org:5001")
355 355
 
356 356
 		// Test NoProxy: example.com should not hit the proxy, and "received" variable should not be changed.
357
-		_, err = c.ImagePull(ctx, "example.com/some/image:latest", image.PullOptions{})
357
+		_, err = c.ImagePull(ctx, "example.com/some/image:latest", client.ImagePullOptions{})
358 358
 		assert.ErrorContains(t, err, "", "pulling should have failed")
359 359
 		assert.Equal(t, received, "example.org:5001", "should not have used proxy")
360 360
 	})
... ...
@@ -400,12 +400,12 @@ func TestDaemonProxy(t *testing.T) {
400 400
 			"NO_PROXY",
401 401
 		))
402 402
 
403
-		_, err := c.ImagePull(ctx, "example.org:5002/some/image:latest", image.PullOptions{})
403
+		_, err := c.ImagePull(ctx, "example.org:5002/some/image:latest", client.ImagePullOptions{})
404 404
 		assert.ErrorContains(t, err, "", "pulling should have failed")
405 405
 		assert.Equal(t, received, "example.org:5002")
406 406
 
407 407
 		// Test NoProxy: example.com should not hit the proxy, and "received" variable should not be changed.
408
-		_, err = c.ImagePull(ctx, "example.com/some/image:latest", image.PullOptions{})
408
+		_, err = c.ImagePull(ctx, "example.com/some/image:latest", client.ImagePullOptions{})
409 409
 		assert.ErrorContains(t, err, "", "pulling should have failed")
410 410
 		assert.Equal(t, received, "example.org:5002", "should not have used proxy")
411 411
 	})
... ...
@@ -700,7 +700,7 @@ func testLiveRestoreVolumeReferences(t *testing.T) {
700 700
 			poll.WaitOn(t, waitFn)
701 701
 		})
702 702
 
703
-		_, err := c.ImageRemove(ctx, mountedImage, image.RemoveOptions{})
703
+		_, err := c.ImageRemove(ctx, mountedImage, client.ImageRemoveOptions{})
704 704
 		assert.ErrorContains(t, err, fmt.Sprintf("container %s is using its referenced image", cID[:12]))
705 705
 
706 706
 		// Remove that container which should free the references in the volume
... ...
@@ -708,7 +708,7 @@ func testLiveRestoreVolumeReferences(t *testing.T) {
708 708
 		assert.NilError(t, err)
709 709
 
710 710
 		// Now we should be able to remove the volume
711
-		_, err = c.ImageRemove(ctx, mountedImage, image.RemoveOptions{})
711
+		_, err = c.ImageRemove(ctx, mountedImage, client.ImageRemoveOptions{})
712 712
 		assert.NilError(t, err)
713 713
 	})
714 714
 
... ...
@@ -7,7 +7,6 @@ import (
7 7
 	"testing"
8 8
 
9 9
 	containertypes "github.com/moby/moby/api/types/container"
10
-	"github.com/moby/moby/api/types/image"
11 10
 	"github.com/moby/moby/client"
12 11
 	"github.com/moby/moby/v2/integration/internal/container"
13 12
 	"github.com/moby/moby/v2/testutil"
... ...
@@ -136,10 +135,10 @@ func TestMigrateSaveLoad(t *testing.T) {
136 136
 	rdr.Close()
137 137
 
138 138
 	// Delete all images
139
-	list, err := apiClient.ImageList(ctx, image.ListOptions{})
139
+	list, err := apiClient.ImageList(ctx, client.ImageListOptions{})
140 140
 	assert.NilError(t, err)
141 141
 	for _, i := range list {
142
-		_, err = apiClient.ImageRemove(ctx, i.ID, image.RemoveOptions{Force: true})
142
+		_, err = apiClient.ImageRemove(ctx, i.ID, client.ImageRemoveOptions{Force: true})
143 143
 		assert.NilError(t, err)
144 144
 	}
145 145
 
... ...
@@ -11,7 +11,7 @@ import (
11 11
 
12 12
 	cerrdefs "github.com/containerd/errdefs"
13 13
 	"github.com/containerd/platforms"
14
-	imagetypes "github.com/moby/moby/api/types/image"
14
+	"github.com/moby/moby/client"
15 15
 	"github.com/moby/moby/v2/testutil"
16 16
 	"github.com/moby/moby/v2/testutil/daemon"
17 17
 	"gotest.tools/v3/assert"
... ...
@@ -33,7 +33,7 @@ func TestImportExtremelyLargeImageWorks(t *testing.T) {
33 33
 	d.Start(t, "--iptables=false", "--ip6tables=false")
34 34
 	defer d.Stop(t)
35 35
 
36
-	client := d.NewClientT(t)
36
+	apiClient := d.NewClientT(t)
37 37
 
38 38
 	// Construct an empty tar archive with about 8GB of junk padding at the
39 39
 	// end. This should not cause any crashes (the padding should be mostly
... ...
@@ -46,10 +46,10 @@ func TestImportExtremelyLargeImageWorks(t *testing.T) {
46 46
 	imageRdr := io.MultiReader(&tarBuffer, io.LimitReader(testutil.DevZero, 8*1024*1024*1024))
47 47
 	reference := strings.ToLower(t.Name()) + ":v42"
48 48
 
49
-	_, err = client.ImageImport(ctx,
50
-		imagetypes.ImportSource{Source: imageRdr, SourceName: "-"},
49
+	_, err = apiClient.ImageImport(ctx,
50
+		client.ImageImportSource{Source: imageRdr, SourceName: "-"},
51 51
 		reference,
52
-		imagetypes.ImportOptions{})
52
+		client.ImageImportOptions{})
53 53
 	assert.NilError(t, err)
54 54
 }
55 55
 
... ...
@@ -58,7 +58,7 @@ func TestImportWithCustomPlatform(t *testing.T) {
58 58
 
59 59
 	ctx := setupTest(t)
60 60
 
61
-	client := testEnv.APIClient()
61
+	apiClient := testEnv.APIClient()
62 62
 
63 63
 	// Construct an empty tar archive.
64 64
 	var tarBuffer bytes.Buffer
... ...
@@ -108,13 +108,13 @@ func TestImportWithCustomPlatform(t *testing.T) {
108 108
 			ctx := testutil.StartSpan(ctx, t)
109 109
 			reference := "import-with-platform:tc-" + strconv.Itoa(i)
110 110
 
111
-			_, err = client.ImageImport(ctx,
112
-				imagetypes.ImportSource{Source: imageRdr, SourceName: "-"},
111
+			_, err = apiClient.ImageImport(ctx,
112
+				client.ImageImportSource{Source: imageRdr, SourceName: "-"},
113 113
 				reference,
114
-				imagetypes.ImportOptions{Platform: tc.platform})
114
+				client.ImageImportOptions{Platform: tc.platform})
115 115
 			assert.NilError(t, err)
116 116
 
117
-			inspect, err := client.ImageInspect(ctx, reference)
117
+			inspect, err := apiClient.ImageInspect(ctx, reference)
118 118
 			assert.NilError(t, err)
119 119
 			assert.Equal(t, inspect.Os, tc.expected.OS)
120 120
 			assert.Equal(t, inspect.Architecture, tc.expected.Architecture)
... ...
@@ -128,7 +128,7 @@ func TestImportWithCustomPlatformReject(t *testing.T) {
128 128
 
129 129
 	ctx := setupTest(t)
130 130
 
131
-	client := testEnv.APIClient()
131
+	apiClient := testEnv.APIClient()
132 132
 
133 133
 	// Construct an empty tar archive.
134 134
 	var tarBuffer bytes.Buffer
... ...
@@ -172,10 +172,10 @@ func TestImportWithCustomPlatformReject(t *testing.T) {
172 172
 		t.Run(tc.platform, func(t *testing.T) {
173 173
 			ctx := testutil.StartSpan(ctx, t)
174 174
 			reference := "import-with-platform:tc-" + strconv.Itoa(i)
175
-			_, err = client.ImageImport(ctx,
176
-				imagetypes.ImportSource{Source: imageRdr, SourceName: "-"},
175
+			_, err = apiClient.ImageImport(ctx,
176
+				client.ImageImportSource{Source: imageRdr, SourceName: "-"},
177 177
 				reference,
178
-				imagetypes.ImportOptions{Platform: tc.platform})
178
+				client.ImageImportOptions{Platform: tc.platform})
179 179
 
180 180
 			assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
181 181
 			assert.Check(t, is.ErrorContains(err, tc.expectedErr))
... ...
@@ -5,7 +5,6 @@ import (
5 5
 	"encoding/json"
6 6
 	"testing"
7 7
 
8
-	"github.com/moby/moby/api/types/image"
9 8
 	"github.com/moby/moby/client"
10 9
 	iimage "github.com/moby/moby/v2/integration/internal/image"
11 10
 	"github.com/moby/moby/v2/internal/testutils/specialimage"
... ...
@@ -55,7 +54,7 @@ func TestImageInspectUniqueRepoDigests(t *testing.T) {
55 55
 		err := apiClient.ImageTag(ctx, "busybox", imgName)
56 56
 		assert.NilError(t, err)
57 57
 		defer func() {
58
-			_, _ = apiClient.ImageRemove(ctx, imgName, image.RemoveOptions{Force: true})
58
+			_, _ = apiClient.ImageRemove(ctx, imgName, client.ImageRemoveOptions{Force: true})
59 59
 		}()
60 60
 	}
61 61
 
... ...
@@ -48,7 +48,7 @@ func TestImagesFilterMultiReference(t *testing.T) {
48 48
 	filter.Add("reference", repoTags[0])
49 49
 	filter.Add("reference", repoTags[1])
50 50
 	filter.Add("reference", repoTags[2])
51
-	options := image.ListOptions{
51
+	options := client.ImageListOptions{
52 52
 		Filters: filter,
53 53
 	}
54 54
 	images, err := apiClient.ImageList(ctx, options)
... ...
@@ -96,7 +96,7 @@ func TestImagesFilterUntil(t *testing.T) {
96 96
 		filters.Arg("until", laterUntil),
97 97
 		filters.Arg("before", imgs[len(imgs)-1]),
98 98
 	)
99
-	list, err := apiClient.ImageList(ctx, image.ListOptions{Filters: filter})
99
+	list, err := apiClient.ImageList(ctx, client.ImageListOptions{Filters: filter})
100 100
 	assert.NilError(t, err)
101 101
 
102 102
 	var listedIDs []string
... ...
@@ -130,7 +130,7 @@ func TestImagesFilterBeforeSince(t *testing.T) {
130 130
 		filters.Arg("since", imgs[0]),
131 131
 		filters.Arg("before", imgs[len(imgs)-1]),
132 132
 	)
133
-	list, err := apiClient.ImageList(ctx, image.ListOptions{Filters: filter})
133
+	list, err := apiClient.ImageList(ctx, client.ImageListOptions{Filters: filter})
134 134
 	assert.NilError(t, err)
135 135
 
136 136
 	var listedIDs []string
... ...
@@ -191,7 +191,7 @@ func TestAPIImagesFilters(t *testing.T) {
191 191
 			t.Parallel()
192 192
 
193 193
 			ctx := testutil.StartSpan(ctx, t)
194
-			images, err := apiClient.ImageList(ctx, image.ListOptions{
194
+			images, err := apiClient.ImageList(ctx, client.ImageListOptions{
195 195
 				Filters: filters.NewArgs(tc.filters...),
196 196
 			})
197 197
 			assert.Check(t, err)
... ...
@@ -228,7 +228,7 @@ func TestAPIImagesListSizeShared(t *testing.T) {
228 228
 		})
229 229
 	})
230 230
 
231
-	_, err := apiClient.ImageList(ctx, image.ListOptions{SharedSize: true})
231
+	_, err := apiClient.ImageList(ctx, client.ImageListOptions{SharedSize: true})
232 232
 	assert.NilError(t, err)
233 233
 }
234 234
 
... ...
@@ -265,7 +265,7 @@ func TestAPIImagesListManifests(t *testing.T) {
265 265
 		// TODO: Remove when MinSupportedAPIVersion >= 1.47
266 266
 		c := d.NewClientT(t, client.WithVersion(api.MinSupportedAPIVersion))
267 267
 
268
-		images, err := c.ImageList(ctx, image.ListOptions{Manifests: true})
268
+		images, err := c.ImageList(ctx, client.ImageListOptions{Manifests: true})
269 269
 		assert.NilError(t, err)
270 270
 
271 271
 		assert.Assert(t, is.Len(images, 1))
... ...
@@ -277,14 +277,14 @@ func TestAPIImagesListManifests(t *testing.T) {
277 277
 	api147 := d.NewClientT(t, client.WithVersion("1.47"))
278 278
 
279 279
 	t.Run("no manifests if not requested", func(t *testing.T) {
280
-		images, err := api147.ImageList(ctx, image.ListOptions{})
280
+		images, err := api147.ImageList(ctx, client.ImageListOptions{})
281 281
 		assert.NilError(t, err)
282 282
 
283 283
 		assert.Assert(t, is.Len(images, 1))
284 284
 		assert.Check(t, is.Nil(images[0].Manifests))
285 285
 	})
286 286
 
287
-	images, err := api147.ImageList(ctx, image.ListOptions{Manifests: true})
287
+	images, err := api147.ImageList(ctx, client.ImageListOptions{Manifests: true})
288 288
 	assert.NilError(t, err)
289 289
 
290 290
 	assert.Check(t, is.Len(images, 1))
... ...
@@ -6,6 +6,7 @@ import (
6 6
 
7 7
 	cerrdefs "github.com/containerd/errdefs"
8 8
 	"github.com/moby/moby/api/types/image"
9
+	"github.com/moby/moby/client"
9 10
 	iimage "github.com/moby/moby/v2/integration/internal/image"
10 11
 	"github.com/moby/moby/v2/internal/testutils/specialimage"
11 12
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
... ...
@@ -19,16 +20,16 @@ func TestLoadDanglingImages(t *testing.T) {
19 19
 
20 20
 	ctx := setupTest(t)
21 21
 
22
-	client := testEnv.APIClient()
22
+	apiClient := testEnv.APIClient()
23 23
 
24
-	iimage.Load(ctx, t, client, func(dir string) (*ocispec.Index, error) {
24
+	iimage.Load(ctx, t, apiClient, func(dir string) (*ocispec.Index, error) {
25 25
 		return specialimage.MultiLayerCustom(dir, "namedimage:latest", []specialimage.SingleFileLayer{
26 26
 			{Name: "bar", Content: []byte("1")},
27 27
 		})
28 28
 	})
29 29
 
30 30
 	// Should be one image.
31
-	images, err := client.ImageList(ctx, image.ListOptions{})
31
+	images, err := apiClient.ImageList(ctx, client.ImageListOptions{})
32 32
 	assert.NilError(t, err)
33 33
 
34 34
 	findImageByName := func(images []image.Summary, imageName string) (image.Summary, error) {
... ...
@@ -45,13 +46,13 @@ func TestLoadDanglingImages(t *testing.T) {
45 45
 	assert.NilError(t, err)
46 46
 
47 47
 	// Retain a copy of the old image and then replace it with a new one.
48
-	iimage.Load(ctx, t, client, func(dir string) (*ocispec.Index, error) {
48
+	iimage.Load(ctx, t, apiClient, func(dir string) (*ocispec.Index, error) {
49 49
 		return specialimage.MultiLayerCustom(dir, "namedimage:latest", []specialimage.SingleFileLayer{
50 50
 			{Name: "bar", Content: []byte("2")},
51 51
 		})
52 52
 	})
53 53
 
54
-	images, err = client.ImageList(ctx, image.ListOptions{})
54
+	images, err = apiClient.ImageList(ctx, client.ImageListOptions{})
55 55
 	assert.NilError(t, err)
56 56
 
57 57
 	newImage, err := findImageByName(images, "namedimage:latest")
... ...
@@ -82,7 +82,7 @@ func TestPruneLexographicalOrder(t *testing.T) {
82 82
 	err = apiClient.ImageTag(ctx, id, "busybox:z")
83 83
 	assert.NilError(t, err)
84 84
 
85
-	_, err = apiClient.ImageRemove(ctx, "busybox:latest", image.RemoveOptions{Force: true})
85
+	_, err = apiClient.ImageRemove(ctx, "busybox:latest", client.ImageRemoveOptions{Force: true})
86 86
 	assert.NilError(t, err)
87 87
 
88 88
 	// run container
... ...
@@ -17,7 +17,7 @@ import (
17 17
 	"github.com/containerd/containerd/v2/plugins/content/local"
18 18
 	cerrdefs "github.com/containerd/errdefs"
19 19
 	"github.com/containerd/platforms"
20
-	"github.com/moby/moby/api/types/image"
20
+	"github.com/moby/moby/client"
21 21
 	"github.com/moby/moby/v2/testutil/daemon"
22 22
 	"github.com/moby/moby/v2/testutil/registry"
23 23
 	"github.com/opencontainers/go-digest"
... ...
@@ -31,9 +31,9 @@ import (
31 31
 func TestImagePullPlatformInvalid(t *testing.T) {
32 32
 	ctx := setupTest(t)
33 33
 
34
-	client := testEnv.APIClient()
34
+	apiClient := testEnv.APIClient()
35 35
 
36
-	_, err := client.ImagePull(ctx, "docker.io/library/hello-world:latest", image.PullOptions{Platform: "foobar"})
36
+	_, err := apiClient.ImagePull(ctx, "docker.io/library/hello-world:latest", client.ImagePullOptions{Platform: "foobar"})
37 37
 	assert.Assert(t, err != nil)
38 38
 	assert.Check(t, is.ErrorContains(err, "unknown operating system or architecture"))
39 39
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
... ...
@@ -144,15 +144,15 @@ func TestImagePullStoredDigestForOtherRepo(t *testing.T) {
144 144
 	err = c8dClient.Push(ctx, remote, desc)
145 145
 	assert.NilError(t, err)
146 146
 
147
-	client := testEnv.APIClient()
148
-	rdr, err := client.ImagePull(ctx, remote, image.PullOptions{})
147
+	apiClient := testEnv.APIClient()
148
+	rdr, err := apiClient.ImagePull(ctx, remote, client.ImagePullOptions{})
149 149
 	assert.NilError(t, err)
150 150
 	defer rdr.Close()
151 151
 	_, err = io.Copy(io.Discard, rdr)
152 152
 	assert.Check(t, err)
153 153
 
154 154
 	// Now, pull a totally different repo with a the same digest
155
-	rdr, err = client.ImagePull(ctx, path.Join(registry.DefaultURL, "other:image@"+desc.Digest.String()), image.PullOptions{})
155
+	rdr, err = apiClient.ImagePull(ctx, path.Join(registry.DefaultURL, "other:image@"+desc.Digest.String()), client.ImagePullOptions{})
156 156
 	if rdr != nil {
157 157
 		assert.Check(t, rdr.Close())
158 158
 	}
... ...
@@ -178,8 +178,8 @@ func TestImagePullNonExisting(t *testing.T) {
178 178
 		t.Run(ref, func(t *testing.T) {
179 179
 			t.Parallel()
180 180
 
181
-			client := testEnv.APIClient()
182
-			rdr, err := client.ImagePull(ctx, ref, image.PullOptions{
181
+			apiClient := testEnv.APIClient()
182
+			rdr, err := apiClient.ImagePull(ctx, ref, client.ImagePullOptions{
183 183
 				All: all,
184 184
 			})
185 185
 			if err == nil {
... ...
@@ -218,10 +218,10 @@ func TestImagePullKeepOldAsDangling(t *testing.T) {
218 218
 
219 219
 	assert.NilError(t, apiClient.ImageTag(ctx, "busybox:latest", "alpine:latest"))
220 220
 
221
-	_, err = apiClient.ImageRemove(ctx, "busybox:latest", image.RemoveOptions{})
221
+	_, err = apiClient.ImageRemove(ctx, "busybox:latest", client.ImageRemoveOptions{})
222 222
 	assert.NilError(t, err)
223 223
 
224
-	rc, err := apiClient.ImagePull(ctx, "alpine:latest", image.PullOptions{})
224
+	rc, err := apiClient.ImagePull(ctx, "alpine:latest", client.ImagePullOptions{})
225 225
 	assert.NilError(t, err)
226 226
 
227 227
 	defer rc.Close()
... ...
@@ -9,6 +9,7 @@ import (
9 9
 
10 10
 	containertypes "github.com/moby/moby/api/types/container"
11 11
 	"github.com/moby/moby/api/types/image"
12
+	"github.com/moby/moby/client"
12 13
 	"github.com/moby/moby/v2/integration/internal/container"
13 14
 	iimage "github.com/moby/moby/v2/integration/internal/image"
14 15
 	"github.com/moby/moby/v2/internal/testutils/specialimage"
... ...
@@ -21,47 +22,47 @@ import (
21 21
 func TestRemoveImageOrphaning(t *testing.T) {
22 22
 	ctx := setupTest(t)
23 23
 
24
-	client := testEnv.APIClient()
24
+	apiClient := testEnv.APIClient()
25 25
 
26 26
 	imgName := strings.ToLower(t.Name())
27 27
 
28 28
 	// Create a container from busybox, and commit a small change so we have a new image
29
-	cID1 := container.Create(ctx, t, client, container.WithCmd(""))
30
-	commitResp1, err := client.ContainerCommit(ctx, cID1, containertypes.CommitOptions{
29
+	cID1 := container.Create(ctx, t, apiClient, container.WithCmd(""))
30
+	commitResp1, err := apiClient.ContainerCommit(ctx, cID1, containertypes.CommitOptions{
31 31
 		Changes:   []string{`ENTRYPOINT ["true"]`},
32 32
 		Reference: imgName,
33 33
 	})
34 34
 	assert.NilError(t, err)
35 35
 
36 36
 	// verifies that reference now points to first image
37
-	resp, err := client.ImageInspect(ctx, imgName)
37
+	resp, err := apiClient.ImageInspect(ctx, imgName)
38 38
 	assert.NilError(t, err)
39 39
 	assert.Check(t, is.Equal(resp.ID, commitResp1.ID))
40 40
 
41 41
 	// Create a container from created image, and commit a small change with same reference name
42
-	cID2 := container.Create(ctx, t, client, container.WithImage(imgName), container.WithCmd(""))
43
-	commitResp2, err := client.ContainerCommit(ctx, cID2, containertypes.CommitOptions{
42
+	cID2 := container.Create(ctx, t, apiClient, container.WithImage(imgName), container.WithCmd(""))
43
+	commitResp2, err := apiClient.ContainerCommit(ctx, cID2, containertypes.CommitOptions{
44 44
 		Changes:   []string{`LABEL Maintainer="Integration Tests"`},
45 45
 		Reference: imgName,
46 46
 	})
47 47
 	assert.NilError(t, err)
48 48
 
49 49
 	// verifies that reference now points to second image
50
-	resp, err = client.ImageInspect(ctx, imgName)
50
+	resp, err = apiClient.ImageInspect(ctx, imgName)
51 51
 	assert.NilError(t, err)
52 52
 	assert.Check(t, is.Equal(resp.ID, commitResp2.ID))
53 53
 
54 54
 	// try to remove the image, should not error out.
55
-	_, err = client.ImageRemove(ctx, imgName, image.RemoveOptions{})
55
+	_, err = apiClient.ImageRemove(ctx, imgName, client.ImageRemoveOptions{})
56 56
 	assert.NilError(t, err)
57 57
 
58 58
 	// check if the first image is still there
59
-	resp, err = client.ImageInspect(ctx, commitResp1.ID)
59
+	resp, err = apiClient.ImageInspect(ctx, commitResp1.ID)
60 60
 	assert.NilError(t, err)
61 61
 	assert.Check(t, is.Equal(resp.ID, commitResp1.ID))
62 62
 
63 63
 	// check if the second image has been deleted
64
-	_, err = client.ImageInspect(ctx, commitResp2.ID)
64
+	_, err = apiClient.ImageInspect(ctx, commitResp2.ID)
65 65
 	assert.Check(t, is.ErrorContains(err, "No such image:"))
66 66
 }
67 67
 
... ...
@@ -69,12 +70,12 @@ func TestRemoveByDigest(t *testing.T) {
69 69
 	skip.If(t, !testEnv.UsingSnapshotter(), "RepoDigests doesn't include tags when using graphdrivers")
70 70
 
71 71
 	ctx := setupTest(t)
72
-	client := testEnv.APIClient()
72
+	apiClient := testEnv.APIClient()
73 73
 
74
-	err := client.ImageTag(ctx, "busybox", "test-remove-by-digest:latest")
74
+	err := apiClient.ImageTag(ctx, "busybox", "test-remove-by-digest:latest")
75 75
 	assert.NilError(t, err)
76 76
 
77
-	inspect, err := client.ImageInspect(ctx, "test-remove-by-digest")
77
+	inspect, err := apiClient.ImageInspect(ctx, "test-remove-by-digest")
78 78
 	assert.NilError(t, err)
79 79
 
80 80
 	id := ""
... ...
@@ -86,13 +87,13 @@ func TestRemoveByDigest(t *testing.T) {
86 86
 	}
87 87
 	assert.Assert(t, id != "")
88 88
 
89
-	_, err = client.ImageRemove(ctx, id, image.RemoveOptions{})
89
+	_, err = apiClient.ImageRemove(ctx, id, client.ImageRemoveOptions{})
90 90
 	assert.NilError(t, err, "error removing %s", id)
91 91
 
92
-	_, err = client.ImageInspect(ctx, "busybox")
92
+	_, err = apiClient.ImageInspect(ctx, "busybox")
93 93
 	assert.NilError(t, err, "busybox image got deleted")
94 94
 
95
-	inspect, err = client.ImageInspect(ctx, "test-remove-by-digest")
95
+	inspect, err = apiClient.ImageInspect(ctx, "test-remove-by-digest")
96 96
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
97 97
 	assert.Check(t, is.DeepEqual(inspect, image.InspectResponse{}))
98 98
 }
... ...
@@ -142,7 +143,7 @@ func TestRemoveWithPlatform(t *testing.T) {
142 142
 		{&platformHost, descs[0]},
143 143
 		{&someOtherPlatform, descs[3]},
144 144
 	} {
145
-		resp, err := apiClient.ImageRemove(ctx, imgName, image.RemoveOptions{
145
+		resp, err := apiClient.ImageRemove(ctx, imgName, client.ImageRemoveOptions{
146 146
 			Platforms: []ocispec.Platform{*tc.platform},
147 147
 			Force:     true,
148 148
 		})
... ...
@@ -155,7 +156,7 @@ func TestRemoveWithPlatform(t *testing.T) {
155 155
 	}
156 156
 
157 157
 	// Delete the rest
158
-	resp, err := apiClient.ImageRemove(ctx, imgName, image.RemoveOptions{})
158
+	resp, err := apiClient.ImageRemove(ctx, imgName, client.ImageRemoveOptions{})
159 159
 	assert.NilError(t, err)
160 160
 
161 161
 	assert.Check(t, is.Len(resp, 2))
... ...
@@ -16,7 +16,6 @@ import (
16 16
 	"github.com/cpuguy83/tar2go"
17 17
 	"github.com/moby/go-archive/compression"
18 18
 	containertypes "github.com/moby/moby/api/types/container"
19
-	"github.com/moby/moby/api/types/image"
20 19
 	"github.com/moby/moby/api/types/versions"
21 20
 	"github.com/moby/moby/client"
22 21
 	"github.com/moby/moby/v2/integration/internal/build"
... ...
@@ -315,7 +314,7 @@ func TestSaveAndLoadPlatform(t *testing.T) {
315 315
 		t.Run(tc.testName, func(t *testing.T) {
316 316
 			// pull the image
317 317
 			for _, p := range tc.pullPlatforms {
318
-				resp, err := apiClient.ImagePull(ctx, repoName, image.PullOptions{Platform: p})
318
+				resp, err := apiClient.ImagePull(ctx, repoName, client.ImagePullOptions{Platform: p})
319 319
 				assert.NilError(t, err)
320 320
 				_, err = io.ReadAll(resp)
321 321
 				resp.Close()
... ...
@@ -327,7 +326,7 @@ func TestSaveAndLoadPlatform(t *testing.T) {
327 327
 			assert.NilError(t, err)
328 328
 
329 329
 			// remove the pulled image
330
-			_, err = apiClient.ImageRemove(ctx, repoName, image.RemoveOptions{})
330
+			_, err = apiClient.ImageRemove(ctx, repoName, client.ImageRemoveOptions{})
331 331
 			assert.NilError(t, err)
332 332
 
333 333
 			// load the full exported image (all platforms in it)
... ...
@@ -348,12 +347,12 @@ func TestSaveAndLoadPlatform(t *testing.T) {
348 348
 			}
349 349
 
350 350
 			// remove the loaded image
351
-			_, err = apiClient.ImageRemove(ctx, repoName, image.RemoveOptions{})
351
+			_, err = apiClient.ImageRemove(ctx, repoName, client.ImageRemoveOptions{})
352 352
 			assert.NilError(t, err)
353 353
 
354 354
 			// pull the image again (start fresh)
355 355
 			for _, p := range tc.pullPlatforms {
356
-				resp, err := apiClient.ImagePull(ctx, repoName, image.PullOptions{Platform: p})
356
+				resp, err := apiClient.ImagePull(ctx, repoName, client.ImagePullOptions{Platform: p})
357 357
 				assert.NilError(t, err)
358 358
 				_, err = io.ReadAll(resp)
359 359
 				resp.Close()
... ...
@@ -365,7 +364,7 @@ func TestSaveAndLoadPlatform(t *testing.T) {
365 365
 			assert.NilError(t, err)
366 366
 
367 367
 			// remove the pulled image
368
-			_, err = apiClient.ImageRemove(ctx, repoName, image.RemoveOptions{})
368
+			_, err = apiClient.ImageRemove(ctx, repoName, client.ImageRemoveOptions{})
369 369
 			assert.NilError(t, err)
370 370
 
371 371
 			// load the exported image on the specified platforms only
... ...
@@ -7,7 +7,6 @@ import (
7 7
 	"testing"
8 8
 
9 9
 	"github.com/moby/moby/api/types/build"
10
-	"github.com/moby/moby/api/types/image"
11 10
 	"github.com/moby/moby/client"
12 11
 	"github.com/moby/moby/client/pkg/jsonmessage"
13 12
 	"github.com/moby/moby/v2/testutil/fakecontext"
... ...
@@ -15,15 +14,15 @@ import (
15 15
 )
16 16
 
17 17
 // Do builds an image from the given context and returns the image ID.
18
-func Do(ctx context.Context, t *testing.T, client client.APIClient, buildCtx *fakecontext.Fake) string {
19
-	resp, err := client.ImageBuild(ctx, buildCtx.AsTarReader(t), build.ImageBuildOptions{})
18
+func Do(ctx context.Context, t *testing.T, apiClient client.APIClient, buildCtx *fakecontext.Fake) string {
19
+	resp, err := apiClient.ImageBuild(ctx, buildCtx.AsTarReader(t), build.ImageBuildOptions{})
20 20
 	if resp.Body != nil {
21 21
 		defer resp.Body.Close()
22 22
 	}
23 23
 	assert.NilError(t, err)
24 24
 	img := GetImageIDFromBody(t, resp.Body)
25 25
 	t.Cleanup(func() {
26
-		client.ImageRemove(ctx, img, image.RemoveOptions{Force: true})
26
+		apiClient.ImageRemove(ctx, img, client.ImageRemoveOptions{Force: true})
27 27
 	})
28 28
 	return img
29 29
 }
... ...
@@ -21,7 +21,6 @@ import (
21 21
 	"github.com/moby/go-archive"
22 22
 	containertypes "github.com/moby/moby/api/types/container"
23 23
 	eventtypes "github.com/moby/moby/api/types/events"
24
-	"github.com/moby/moby/api/types/image"
25 24
 	"github.com/moby/moby/client"
26 25
 	"github.com/moby/moby/v2/integration/internal/container"
27 26
 	"github.com/moby/moby/v2/pkg/authorization"
... ...
@@ -460,9 +459,9 @@ func imageImport(ctx context.Context, apiClient client.APIClient, path string) e
460 460
 		return err
461 461
 	}
462 462
 	defer file.Close()
463
-	options := image.ImportOptions{}
463
+	options := client.ImageImportOptions{}
464 464
 	ref := ""
465
-	source := image.ImportSource{
465
+	source := client.ImageImportSource{
466 466
 		Source:     file,
467 467
 		SourceName: "-",
468 468
 	}
... ...
@@ -11,7 +11,6 @@ import (
11 11
 
12 12
 	"github.com/moby/moby/api/types/build"
13 13
 	containertypes "github.com/moby/moby/api/types/container"
14
-	"github.com/moby/moby/api/types/image"
15 14
 	"github.com/moby/moby/api/types/mount"
16 15
 	"github.com/moby/moby/api/types/network"
17 16
 	"github.com/moby/moby/api/types/versions"
... ...
@@ -149,7 +148,7 @@ func TestRunMountImage(t *testing.T) {
149 149
 		t.Run(tc.name, func(t *testing.T) {
150 150
 			testImage := setupTestImage(t, ctx, apiClient, tc.name)
151 151
 			if testImage != "" {
152
-				defer apiClient.ImageRemove(ctx, testImage, image.RemoveOptions{Force: true})
152
+				defer apiClient.ImageRemove(ctx, testImage, client.ImageRemoveOptions{Force: true})
153 153
 			}
154 154
 
155 155
 			cfg := containertypes.Config{
... ...
@@ -195,7 +194,7 @@ func TestRunMountImage(t *testing.T) {
195 195
 			if tc.name == "image_remove" {
196 196
 				img, _ := apiClient.ImageInspect(ctx, testImage)
197 197
 				imgId := strings.Split(img.ID, ":")[1]
198
-				_, removeErr := apiClient.ImageRemove(ctx, testImage, image.RemoveOptions{})
198
+				_, removeErr := apiClient.ImageRemove(ctx, testImage, client.ImageRemoveOptions{})
199 199
 				assert.ErrorContains(t, removeErr, fmt.Sprintf(`container %s is using its referenced image %s`, id[:12], imgId[:12]))
200 200
 			}
201 201
 
... ...
@@ -204,7 +203,7 @@ func TestRunMountImage(t *testing.T) {
204 204
 				stopErr := apiClient.ContainerStop(ctx, id, containertypes.StopOptions{})
205 205
 				assert.NilError(t, stopErr)
206 206
 
207
-				_, removeErr := apiClient.ImageRemove(ctx, testImage, image.RemoveOptions{Force: true})
207
+				_, removeErr := apiClient.ImageRemove(ctx, testImage, client.ImageRemoveOptions{Force: true})
208 208
 				assert.NilError(t, removeErr)
209 209
 
210 210
 				startContainer(id)
... ...
@@ -8,7 +8,6 @@ import (
8 8
 	cerrdefs "github.com/containerd/errdefs"
9 9
 	"github.com/moby/moby/api/types/container"
10 10
 	"github.com/moby/moby/api/types/filters"
11
-	"github.com/moby/moby/api/types/image"
12 11
 	"github.com/moby/moby/api/types/network"
13 12
 	"github.com/moby/moby/client"
14 13
 	"go.opentelemetry.io/otel"
... ...
@@ -96,7 +95,7 @@ func getAllContainers(ctx context.Context, t testing.TB, client client.Container
96 96
 
97 97
 func deleteAllImages(ctx context.Context, t testing.TB, apiclient client.ImageAPIClient, protectedImages map[string]struct{}) {
98 98
 	t.Helper()
99
-	images, err := apiclient.ImageList(ctx, image.ListOptions{})
99
+	images, err := apiclient.ImageList(ctx, client.ImageListOptions{})
100 100
 	assert.Check(t, err, "failed to list images")
101 101
 
102 102
 	for _, img := range images {
... ...
@@ -118,7 +117,7 @@ func deleteAllImages(ctx context.Context, t testing.TB, apiclient client.ImageAP
118 118
 
119 119
 func removeImage(ctx context.Context, t testing.TB, apiclient client.ImageAPIClient, ref string) {
120 120
 	t.Helper()
121
-	_, err := apiclient.ImageRemove(ctx, ref, image.RemoveOptions{
121
+	_, err := apiclient.ImageRemove(ctx, ref, client.ImageRemoveOptions{
122 122
 		Force: true,
123 123
 	})
124 124
 	if cerrdefs.IsNotFound(err) {
... ...
@@ -10,7 +10,6 @@ import (
10 10
 
11 11
 	"github.com/moby/moby/api/types"
12 12
 	"github.com/moby/moby/api/types/filters"
13
-	"github.com/moby/moby/api/types/image"
14 13
 	"github.com/moby/moby/api/types/system"
15 14
 	"github.com/moby/moby/client"
16 15
 	"github.com/moby/moby/v2/testutil/fixtures/load"
... ...
@@ -198,7 +197,7 @@ func (e *Execution) UsingSnapshotter() bool {
198 198
 // Note that this is done by filtering and then checking whether there were any
199 199
 // results -- so ambiguous references might result in false-positives.
200 200
 func (e *Execution) HasExistingImage(t testing.TB, reference string) bool {
201
-	imageList, err := e.APIClient().ImageList(context.Background(), image.ListOptions{
201
+	imageList, err := e.APIClient().ImageList(context.Background(), client.ImageListOptions{
202 202
 		All: true,
203 203
 		Filters: filters.NewArgs(
204 204
 			filters.Arg("dangling", "false"),
... ...
@@ -116,8 +116,8 @@ func ProtectImages(ctx context.Context, t testing.TB, testEnv *Execution) {
116 116
 
117 117
 func getExistingImages(ctx context.Context, t testing.TB, testEnv *Execution) []string {
118 118
 	t.Helper()
119
-	client := testEnv.APIClient()
120
-	imageList, err := client.ImageList(ctx, image.ListOptions{
119
+	apiClient := testEnv.APIClient()
120
+	imageList, err := apiClient.ImageList(ctx, client.ImageListOptions{
121 121
 		All:     true,
122 122
 		Filters: filters.NewArgs(filters.Arg("dangling", "false")),
123 123
 	})
... ...
@@ -13,7 +13,6 @@ import (
13 13
 
14 14
 	"github.com/moby/moby/api/types/build"
15 15
 	containertypes "github.com/moby/moby/api/types/container"
16
-	"github.com/moby/moby/api/types/image"
17 16
 	"github.com/moby/moby/client"
18 17
 	"github.com/moby/moby/v2/testutil"
19 18
 	"github.com/moby/moby/v2/testutil/environment"
... ...
@@ -114,7 +113,7 @@ func (f *remoteFileServer) Close() error {
114 114
 			}
115 115
 		}
116 116
 		if f.image != "" {
117
-			if _, err := f.client.ImageRemove(context.Background(), f.image, image.RemoveOptions{Force: true}); err != nil {
117
+			if _, err := f.client.ImageRemove(context.Background(), f.image, client.ImageRemoveOptions{Force: true}); err != nil {
118 118
 				_, _ = fmt.Fprintf(os.Stderr, "Error closing remote file server: removing image: %v\n", err)
119 119
 			}
120 120
 		}
... ...
@@ -10,7 +10,6 @@ import (
10 10
 	"strings"
11 11
 	"sync"
12 12
 
13
-	"github.com/moby/moby/api/types/image"
14 13
 	"github.com/moby/moby/client"
15 14
 	"github.com/moby/moby/client/pkg/jsonmessage"
16 15
 	"github.com/moby/term"
... ...
@@ -28,13 +27,13 @@ const frozenImgDir = "/docker-frozen-images"
28 28
 // TODO: This loads whatever is in the frozen image dir, regardless of what
29 29
 // images were passed in. If the images need to be downloaded, then it will respect
30 30
 // the passed in images
31
-func FrozenImagesLinux(ctx context.Context, client client.APIClient, images ...string) error {
31
+func FrozenImagesLinux(ctx context.Context, apiClient client.APIClient, images ...string) error {
32 32
 	ctx, span := otel.Tracer("").Start(ctx, "LoadFrozenImages")
33 33
 	defer span.End()
34 34
 
35 35
 	var loadImages []struct{ srcName, destName string }
36 36
 	for _, img := range images {
37
-		if !imageExists(ctx, client, img) {
37
+		if !imageExists(ctx, apiClient, img) {
38 38
 			srcName := img
39 39
 			// hello-world:latest gets re-tagged as hello-world:frozen
40 40
 			// there are some tests that use hello-world:latest specifically so it pulls
... ...
@@ -60,21 +59,21 @@ func FrozenImagesLinux(ctx context.Context, client client.APIClient, images ...s
60 60
 		for _, img := range loadImages {
61 61
 			srcImages = append(srcImages, img.srcName)
62 62
 		}
63
-		if err := pullImages(ctx, client, srcImages); err != nil {
63
+		if err := pullImages(ctx, apiClient, srcImages); err != nil {
64 64
 			return errors.Wrap(err, "error pulling image list")
65 65
 		}
66 66
 	} else {
67
-		if err := loadFrozenImages(ctx, client); err != nil {
67
+		if err := loadFrozenImages(ctx, apiClient); err != nil {
68 68
 			return err
69 69
 		}
70 70
 	}
71 71
 
72 72
 	for _, img := range loadImages {
73 73
 		if img.srcName != img.destName {
74
-			if err := client.ImageTag(ctx, img.srcName, img.destName); err != nil {
74
+			if err := apiClient.ImageTag(ctx, img.srcName, img.destName); err != nil {
75 75
 				return errors.Wrapf(err, "failed to tag %s as %s", img.srcName, img.destName)
76 76
 			}
77
-			if _, err := client.ImageRemove(ctx, img.srcName, image.RemoveOptions{}); err != nil {
77
+			if _, err := apiClient.ImageRemove(ctx, img.srcName, client.ImageRemoveOptions{}); err != nil {
78 78
 				return errors.Wrapf(err, "failed to remove %s", img.srcName)
79 79
 			}
80 80
 		}
... ...
@@ -152,7 +151,7 @@ func pullImages(ctx context.Context, client client.APIClient, images []string) e
152 152
 	return <-chErr
153 153
 }
154 154
 
155
-func pullTagAndRemove(ctx context.Context, client client.APIClient, ref string, tag string) (retErr error) {
155
+func pullTagAndRemove(ctx context.Context, apiClient client.APIClient, ref string, tag string) (retErr error) {
156 156
 	ctx, span := otel.Tracer("").Start(ctx, "pull image: "+ref+" with tag: "+tag)
157 157
 	defer func() {
158 158
 		if retErr != nil {
... ...
@@ -162,7 +161,7 @@ func pullTagAndRemove(ctx context.Context, client client.APIClient, ref string,
162 162
 		span.End()
163 163
 	}()
164 164
 
165
-	resp, err := client.ImagePull(ctx, ref, image.PullOptions{})
165
+	resp, err := apiClient.ImagePull(ctx, ref, client.ImagePullOptions{})
166 166
 	if err != nil {
167 167
 		return errors.Wrapf(err, "failed to pull %s", ref)
168 168
 	}
... ...
@@ -172,10 +171,10 @@ func pullTagAndRemove(ctx context.Context, client client.APIClient, ref string,
172 172
 		return err
173 173
 	}
174 174
 
175
-	if err := client.ImageTag(ctx, ref, tag); err != nil {
175
+	if err := apiClient.ImageTag(ctx, ref, tag); err != nil {
176 176
 		return errors.Wrapf(err, "failed to tag %s as %s", ref, tag)
177 177
 	}
178
-	_, err = client.ImageRemove(ctx, ref, image.RemoveOptions{})
178
+	_, err = apiClient.ImageRemove(ctx, ref, client.ImageRemoveOptions{})
179 179
 	return errors.Wrapf(err, "failed to remove %s", ref)
180 180
 }
181 181
 
182 182
deleted file mode 100644
... ...
@@ -1,124 +0,0 @@
1
-package image
2
-
3
-import (
4
-	"context"
5
-	"io"
6
-
7
-	"github.com/moby/moby/api/types/filters"
8
-	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
9
-)
10
-
11
-// ImportSource holds source information for ImageImport
12
-type ImportSource struct {
13
-	Source     io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
14
-	SourceName string    // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
15
-}
16
-
17
-// ImportOptions holds information to import images from the client host.
18
-type ImportOptions struct {
19
-	Tag      string   // Tag is the name to tag this image with. This attribute is deprecated.
20
-	Message  string   // Message is the message to tag the image with
21
-	Changes  []string // Changes are the raw changes to apply to this image
22
-	Platform string   // Platform is the target platform of the image
23
-}
24
-
25
-// CreateOptions holds information to create images.
26
-type CreateOptions struct {
27
-	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry.
28
-	Platform     string // Platform is the target platform of the image if it needs to be pulled from the registry.
29
-}
30
-
31
-// PullOptions holds information to pull images.
32
-type PullOptions struct {
33
-	All          bool
34
-	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
35
-
36
-	// PrivilegeFunc is a function that clients can supply to retry operations
37
-	// after getting an authorization error. This function returns the registry
38
-	// authentication header value in base64 encoded format, or an error if the
39
-	// privilege request fails.
40
-	//
41
-	// For details, refer to [github.com/moby/moby/api/types/registry.RequestAuthConfig].
42
-	PrivilegeFunc func(context.Context) (string, error)
43
-	Platform      string
44
-}
45
-
46
-// PushOptions holds information to push images.
47
-type PushOptions struct {
48
-	All          bool
49
-	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
50
-
51
-	// PrivilegeFunc is a function that clients can supply to retry operations
52
-	// after getting an authorization error. This function returns the registry
53
-	// authentication header value in base64 encoded format, or an error if the
54
-	// privilege request fails.
55
-	//
56
-	// For details, refer to [github.com/moby/moby/api/types/registry.RequestAuthConfig].
57
-	PrivilegeFunc func(context.Context) (string, error)
58
-
59
-	// Platform is an optional field that selects a specific platform to push
60
-	// when the image is a multi-platform image.
61
-	// Using this will only push a single platform-specific manifest.
62
-	Platform *ocispec.Platform `json:",omitempty"`
63
-}
64
-
65
-// ListOptions holds parameters to list images with.
66
-type ListOptions struct {
67
-	// All controls whether all images in the graph are filtered, or just
68
-	// the heads.
69
-	All bool
70
-
71
-	// Filters is a JSON-encoded set of filter arguments.
72
-	Filters filters.Args
73
-
74
-	// SharedSize indicates whether the shared size of images should be computed.
75
-	SharedSize bool
76
-
77
-	// ContainerCount indicates whether container count should be computed.
78
-	//
79
-	// Deprecated: This field has been unused and is no longer required and will be removed in a future version.
80
-	ContainerCount bool
81
-
82
-	// Manifests indicates whether the image manifests should be returned.
83
-	Manifests bool
84
-}
85
-
86
-// RemoveOptions holds parameters to remove images.
87
-type RemoveOptions struct {
88
-	Platforms     []ocispec.Platform
89
-	Force         bool
90
-	PruneChildren bool
91
-}
92
-
93
-// HistoryOptions holds parameters to get image history.
94
-type HistoryOptions struct {
95
-	// Platform from the manifest list to use for history.
96
-	Platform *ocispec.Platform
97
-}
98
-
99
-// LoadOptions holds parameters to load images.
100
-type LoadOptions struct {
101
-	// Quiet suppresses progress output
102
-	Quiet bool
103
-
104
-	// Platforms selects the platforms to load if the image is a
105
-	// multi-platform image and has multiple variants.
106
-	Platforms []ocispec.Platform
107
-}
108
-
109
-type InspectOptions struct {
110
-	// Manifests returns the image manifests.
111
-	Manifests bool
112
-
113
-	// Platform selects the specific platform of a multi-platform image to inspect.
114
-	//
115
-	// This option is only available for API version 1.49 and up.
116
-	Platform *ocispec.Platform
117
-}
118
-
119
-// SaveOptions holds parameters to save images.
120
-type SaveOptions struct {
121
-	// Platforms selects the platforms to save if the image is a
122
-	// multi-platform image and has multiple variants.
123
-	Platforms []ocispec.Platform
124
-}
... ...
@@ -109,13 +109,13 @@ type ImageAPIClient interface {
109 109
 	ImageBuild(ctx context.Context, context io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error)
110 110
 	BuildCachePrune(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error)
111 111
 	BuildCancel(ctx context.Context, id string) error
112
-	ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error)
113
-	ImageImport(ctx context.Context, source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error)
112
+	ImageCreate(ctx context.Context, parentReference string, options ImageCreateOptions) (io.ReadCloser, error)
113
+	ImageImport(ctx context.Context, source ImageImportSource, ref string, options ImageImportOptions) (io.ReadCloser, error)
114 114
 
115
-	ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error)
116
-	ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error)
117
-	ImagePush(ctx context.Context, ref string, options image.PushOptions) (io.ReadCloser, error)
118
-	ImageRemove(ctx context.Context, image string, options image.RemoveOptions) ([]image.DeleteResponse, error)
115
+	ImageList(ctx context.Context, options ImageListOptions) ([]image.Summary, error)
116
+	ImagePull(ctx context.Context, ref string, options ImagePullOptions) (io.ReadCloser, error)
117
+	ImagePush(ctx context.Context, ref string, options ImagePushOptions) (io.ReadCloser, error)
118
+	ImageRemove(ctx context.Context, image string, options ImageRemoveOptions) ([]image.DeleteResponse, error)
119 119
 	ImageSearch(ctx context.Context, term string, options ImageSearchOptions) ([]registry.SearchResult, error)
120 120
 	ImageTag(ctx context.Context, image, ref string) error
121 121
 	ImagesPrune(ctx context.Context, pruneFilter filters.Args) (image.PruneReport, error)
... ...
@@ -8,13 +8,12 @@ import (
8 8
 	"strings"
9 9
 
10 10
 	"github.com/distribution/reference"
11
-	"github.com/moby/moby/api/types/image"
12 11
 	"github.com/moby/moby/api/types/registry"
13 12
 )
14 13
 
15 14
 // ImageCreate creates a new image based on the parent options.
16 15
 // It returns the JSON content in the response body.
17
-func (cli *Client) ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error) {
16
+func (cli *Client) ImageCreate(ctx context.Context, parentReference string, options ImageCreateOptions) (io.ReadCloser, error) {
18 17
 	ref, err := reference.ParseNormalizedNamed(parentReference)
19 18
 	if err != nil {
20 19
 		return nil, err
21 20
new file mode 100644
... ...
@@ -0,0 +1,7 @@
0
+package client
1
+
2
+// ImageCreateOptions holds information to create images.
3
+type ImageCreateOptions struct {
4
+	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry.
5
+	Platform     string // Platform is the target platform of the image if it needs to be pulled from the registry.
6
+}
... ...
@@ -1,8 +1,6 @@
1 1
 package client
2 2
 
3
-import (
4
-	"github.com/moby/moby/api/types/image"
5
-)
3
+import ocispec "github.com/opencontainers/image-spec/specs-go/v1"
6 4
 
7 5
 // ImageHistoryOption is a type representing functional options for the image history operation.
8 6
 type ImageHistoryOption interface {
... ...
@@ -15,5 +13,10 @@ func (f imageHistoryOptionFunc) Apply(o *imageHistoryOpts) error {
15 15
 }
16 16
 
17 17
 type imageHistoryOpts struct {
18
-	apiOptions image.HistoryOptions
18
+	apiOptions imageHistoryOptions
19
+}
20
+
21
+type imageHistoryOptions struct {
22
+	// Platform from the manifest list to use for history.
23
+	Platform *ocispec.Platform
19 24
 }
... ...
@@ -7,12 +7,11 @@ import (
7 7
 	"strings"
8 8
 
9 9
 	"github.com/distribution/reference"
10
-	"github.com/moby/moby/api/types/image"
11 10
 )
12 11
 
13 12
 // ImageImport creates a new image based on the source options.
14 13
 // It returns the JSON content in the response body.
15
-func (cli *Client) ImageImport(ctx context.Context, source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) {
14
+func (cli *Client) ImageImport(ctx context.Context, source ImageImportSource, ref string, options ImageImportOptions) (io.ReadCloser, error) {
16 15
 	if ref != "" {
17 16
 		// Check if the given image name can be resolved
18 17
 		if _, err := reference.ParseNormalizedNamed(ref); err != nil {
19 18
new file mode 100644
... ...
@@ -0,0 +1,19 @@
0
+package client
1
+
2
+import (
3
+	"io"
4
+)
5
+
6
+// ImageImportSource holds source information for ImageImport
7
+type ImageImportSource struct {
8
+	Source     io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
9
+	SourceName string    // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
10
+}
11
+
12
+// ImageImportOptions holds information to import images from the client host.
13
+type ImageImportOptions struct {
14
+	Tag      string   // Tag is the name to tag this image with. This attribute is deprecated.
15
+	Message  string   // Message is the message to tag the image with
16
+	Changes  []string // Changes are the raw changes to apply to this image
17
+	Platform string   // Platform is the target platform of the image
18
+}
... ...
@@ -3,7 +3,6 @@ package client
3 3
 import (
4 4
 	"bytes"
5 5
 
6
-	"github.com/moby/moby/api/types/image"
7 6
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
8 7
 )
9 8
 
... ...
@@ -50,7 +49,7 @@ func ImageInspectWithPlatform(platform *ocispec.Platform) ImageInspectOption {
50 50
 }
51 51
 
52 52
 // ImageInspectWithAPIOpts sets the API options for the image inspect operation.
53
-func ImageInspectWithAPIOpts(opts image.InspectOptions) ImageInspectOption {
53
+func ImageInspectWithAPIOpts(opts ImageInspectOptions) ImageInspectOption {
54 54
 	return imageInspectOptionFunc(func(clientOpts *imageInspectOpts) error {
55 55
 		clientOpts.apiOptions = opts
56 56
 		return nil
... ...
@@ -59,5 +58,15 @@ func ImageInspectWithAPIOpts(opts image.InspectOptions) ImageInspectOption {
59 59
 
60 60
 type imageInspectOpts struct {
61 61
 	raw        *bytes.Buffer
62
-	apiOptions image.InspectOptions
62
+	apiOptions ImageInspectOptions
63
+}
64
+
65
+type ImageInspectOptions struct {
66
+	// Manifests returns the image manifests.
67
+	Manifests bool
68
+
69
+	// Platform selects the specific platform of a multi-platform image to inspect.
70
+	//
71
+	// This option is only available for API version 1.49 and up.
72
+	Platform *ocispec.Platform
63 73
 }
... ...
@@ -16,7 +16,7 @@ import (
16 16
 // to include [image.Summary.Manifests] with information about image manifests.
17 17
 // This is experimental and might change in the future without any backward
18 18
 // compatibility.
19
-func (cli *Client) ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error) {
19
+func (cli *Client) ImageList(ctx context.Context, options ImageListOptions) ([]image.Summary, error) {
20 20
 	var images []image.Summary
21 21
 
22 22
 	// Make sure we negotiated (if the client is configured to do so),
23 23
new file mode 100644
... ...
@@ -0,0 +1,24 @@
0
+package client
1
+
2
+import "github.com/moby/moby/api/types/filters"
3
+
4
+// ImageListOptions holds parameters to list images with.
5
+type ImageListOptions struct {
6
+	// All controls whether all images in the graph are filtered, or just
7
+	// the heads.
8
+	All bool
9
+
10
+	// Filters is a JSON-encoded set of filter arguments.
11
+	Filters filters.Args
12
+
13
+	// SharedSize indicates whether the shared size of images should be computed.
14
+	SharedSize bool
15
+
16
+	// ContainerCount indicates whether container count should be computed.
17
+	//
18
+	// Deprecated: This field has been unused and is no longer required and will be removed in a future version.
19
+	ContainerCount bool
20
+
21
+	// Manifests indicates whether the image manifests should be returned.
22
+	Manifests bool
23
+}
... ...
@@ -3,7 +3,6 @@ package client
3 3
 import (
4 4
 	"fmt"
5 5
 
6
-	"github.com/moby/moby/api/types/image"
7 6
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
8 7
 )
9 8
 
... ...
@@ -18,7 +17,16 @@ func (f imageLoadOptionFunc) Apply(o *imageLoadOpts) error {
18 18
 }
19 19
 
20 20
 type imageLoadOpts struct {
21
-	apiOptions image.LoadOptions
21
+	apiOptions imageLoadOptions
22
+}
23
+
24
+type imageLoadOptions struct {
25
+	// Quiet suppresses progress output
26
+	Quiet bool
27
+
28
+	// Platforms selects the platforms to load if the image is a
29
+	// multi-platform image and has multiple variants.
30
+	Platforms []ocispec.Platform
22 31
 }
23 32
 
24 33
 // ImageLoadWithQuiet sets the quiet option for the image load operation.
... ...
@@ -8,14 +8,13 @@ import (
8 8
 
9 9
 	cerrdefs "github.com/containerd/errdefs"
10 10
 	"github.com/distribution/reference"
11
-	"github.com/moby/moby/api/types/image"
12 11
 )
13 12
 
14 13
 // ImagePull requests the docker host to pull an image from a remote registry.
15 14
 // It executes the privileged function if the operation is unauthorized
16 15
 // and it tries one more time.
17 16
 // It's up to the caller to handle the [io.ReadCloser] and close it.
18
-func (cli *Client) ImagePull(ctx context.Context, refStr string, options image.PullOptions) (io.ReadCloser, error) {
17
+func (cli *Client) ImagePull(ctx context.Context, refStr string, options ImagePullOptions) (io.ReadCloser, error) {
19 18
 	// FIXME(vdemeester): there is currently used in a few way in docker/docker
20 19
 	// - if not in trusted content, ref is used to pass the whole reference, and tag is empty
21 20
 	// - if in trusted content, ref is used to pass the reference name, and tag for the digest
22 21
new file mode 100644
... ...
@@ -0,0 +1,18 @@
0
+package client
1
+
2
+import "context"
3
+
4
+// ImagePullOptions holds information to pull images.
5
+type ImagePullOptions struct {
6
+	All          bool
7
+	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
8
+
9
+	// PrivilegeFunc is a function that clients can supply to retry operations
10
+	// after getting an authorization error. This function returns the registry
11
+	// authentication header value in base64 encoded format, or an error if the
12
+	// privilege request fails.
13
+	//
14
+	// For details, refer to [github.com/moby/moby/api/types/registry.RequestAuthConfig].
15
+	PrivilegeFunc func(context.Context) (string, error)
16
+	Platform      string
17
+}
... ...
@@ -11,7 +11,6 @@ import (
11 11
 
12 12
 	cerrdefs "github.com/containerd/errdefs"
13 13
 	"github.com/distribution/reference"
14
-	"github.com/moby/moby/api/types/image"
15 14
 	"github.com/moby/moby/api/types/registry"
16 15
 )
17 16
 
... ...
@@ -19,7 +18,7 @@ import (
19 19
 // It executes the privileged function if the operation is unauthorized
20 20
 // and it tries one more time.
21 21
 // It's up to the caller to handle the [io.ReadCloser] and close it.
22
-func (cli *Client) ImagePush(ctx context.Context, image string, options image.PushOptions) (io.ReadCloser, error) {
22
+func (cli *Client) ImagePush(ctx context.Context, image string, options ImagePushOptions) (io.ReadCloser, error) {
23 23
 	ref, err := reference.ParseNormalizedNamed(image)
24 24
 	if err != nil {
25 25
 		return nil, err
26 26
new file mode 100644
... ...
@@ -0,0 +1,26 @@
0
+package client
1
+
2
+import (
3
+	"context"
4
+
5
+	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
6
+)
7
+
8
+// ImagePushOptions holds information to push images.
9
+type ImagePushOptions struct {
10
+	All          bool
11
+	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
12
+
13
+	// PrivilegeFunc is a function that clients can supply to retry operations
14
+	// after getting an authorization error. This function returns the registry
15
+	// authentication header value in base64 encoded format, or an error if the
16
+	// privilege request fails.
17
+	//
18
+	// For details, refer to [github.com/moby/moby/api/types/registry.RequestAuthConfig].
19
+	PrivilegeFunc func(context.Context) (string, error)
20
+
21
+	// Platform is an optional field that selects a specific platform to push
22
+	// when the image is a multi-platform image.
23
+	// Using this will only push a single platform-specific manifest.
24
+	Platform *ocispec.Platform `json:",omitempty"`
25
+}
... ...
@@ -9,7 +9,7 @@ import (
9 9
 )
10 10
 
11 11
 // ImageRemove removes an image from the docker host.
12
-func (cli *Client) ImageRemove(ctx context.Context, imageID string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
12
+func (cli *Client) ImageRemove(ctx context.Context, imageID string, options ImageRemoveOptions) ([]image.DeleteResponse, error) {
13 13
 	query := url.Values{}
14 14
 
15 15
 	if options.Force {
16 16
new file mode 100644
... ...
@@ -0,0 +1,10 @@
0
+package client
1
+
2
+import ocispec "github.com/opencontainers/image-spec/specs-go/v1"
3
+
4
+// ImageRemoveOptions holds parameters to remove images.
5
+type ImageRemoveOptions struct {
6
+	Platforms     []ocispec.Platform
7
+	Force         bool
8
+	PruneChildren bool
9
+}
... ...
@@ -3,7 +3,6 @@ package client
3 3
 import (
4 4
 	"fmt"
5 5
 
6
-	"github.com/moby/moby/api/types/image"
7 6
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
8 7
 )
9 8
 
... ...
@@ -29,5 +28,11 @@ func ImageSaveWithPlatforms(platforms ...ocispec.Platform) ImageSaveOption {
29 29
 }
30 30
 
31 31
 type imageSaveOpts struct {
32
-	apiOptions image.SaveOptions
32
+	apiOptions imageSaveOptions
33
+}
34
+
35
+type imageSaveOptions struct {
36
+	// Platforms selects the platforms to save if the image is a
37
+	// multi-platform image and has multiple variants.
38
+	Platforms []ocispec.Platform
33 39
 }