diff --git a/api/server/router/image/backend.go b/api/server/router/image/backend.go index af56b2e745..ecac8b3225 100644 --- a/api/server/router/image/backend.go +++ b/api/server/router/image/backend.go @@ -25,7 +25,7 @@ type Backend interface { type imageBackend interface { ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]image.DeleteResponse, error) ImageHistory(ctx context.Context, imageName string) ([]*image.HistoryResponseItem, error) - Images(ctx context.Context, opts types.ImageListOptions) ([]*image.Summary, error) + Images(ctx context.Context, opts image.ListOptions) ([]*image.Summary, error) GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*dockerimage.Image, error) TagImage(ctx context.Context, id dockerimage.ID, newRef reference.Named) error ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error) diff --git a/api/server/router/image/image_routes.go b/api/server/router/image/image_routes.go index e17d8ac218..4a9f494a3b 100644 --- a/api/server/router/image/image_routes.go +++ b/api/server/router/image/image_routes.go @@ -190,7 +190,7 @@ func (ir *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter var ref reference.Named - // Tag is empty only in case ImagePushOptions.All is true. + // Tag is empty only in case PushOptions.All is true. if tag != "" { r, err := httputils.RepoTagReference(img, tag) if err != nil { @@ -396,7 +396,7 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter, sharedSize = httputils.BoolValue(r, "shared-size") } - images, err := ir.backend.Images(ctx, types.ImageListOptions{ + images, err := ir.backend.Images(ctx, imagetypes.ListOptions{ All: httputils.BoolValue(r, "all"), Filters: imageFilters, SharedSize: sharedSize, diff --git a/api/types/client.go b/api/types/client.go index 24b00a2759..882201f0ea 100644 --- a/api/types/client.go +++ b/api/types/client.go @@ -157,42 +157,12 @@ type ImageBuildResponse struct { OSType string } -// ImageCreateOptions holds information to create images. -type ImageCreateOptions struct { - RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry. - Platform string // Platform is the target platform of the image if it needs to be pulled from the registry. -} - // ImageImportSource holds source information for ImageImport type ImageImportSource struct { 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. SourceName string // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute. } -// ImageImportOptions holds information to import images from the client host. -type ImageImportOptions struct { - Tag string // Tag is the name to tag this image with. This attribute is deprecated. - Message string // Message is the message to tag the image with - Changes []string // Changes are the raw changes to apply to this image - Platform string // Platform is the target platform of the image -} - -// ImageListOptions holds parameters to list images with. -type ImageListOptions struct { - // All controls whether all images in the graph are filtered, or just - // the heads. - All bool - - // Filters is a JSON-encoded set of filter arguments. - Filters filters.Args - - // SharedSize indicates whether the shared size of images should be computed. - SharedSize bool - - // ContainerCount indicates whether container count should be computed. - ContainerCount bool -} - // ImageLoadResponse returns information to the client about a load process. type ImageLoadResponse struct { // Body must be closed to avoid a resource leak @@ -200,14 +170,6 @@ type ImageLoadResponse struct { JSON bool } -// ImagePullOptions holds information to pull images. -type ImagePullOptions struct { - All bool - RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry - PrivilegeFunc RequestPrivilegeFunc - Platform string -} - // RequestPrivilegeFunc is a function interface that // clients can supply to retry operations after // getting an authorization error. @@ -216,15 +178,6 @@ type ImagePullOptions struct { // if the privilege request fails. type RequestPrivilegeFunc func() (string, error) -// ImagePushOptions holds information to push images. -type ImagePushOptions ImagePullOptions - -// ImageRemoveOptions holds parameters to remove images. -type ImageRemoveOptions struct { - Force bool - PruneChildren bool -} - // ImageSearchOptions holds parameters to search images with. type ImageSearchOptions struct { RegistryAuth string diff --git a/api/types/image/opts.go b/api/types/image/opts.go new file mode 100644 index 0000000000..c6b1f351b4 --- /dev/null +++ b/api/types/image/opts.go @@ -0,0 +1,57 @@ +package image + +import "github.com/docker/docker/api/types/filters" + +// ImportOptions holds information to import images from the client host. +type ImportOptions struct { + Tag string // Tag is the name to tag this image with. This attribute is deprecated. + Message string // Message is the message to tag the image with + Changes []string // Changes are the raw changes to apply to this image + Platform string // Platform is the target platform of the image +} + +// CreateOptions holds information to create images. +type CreateOptions struct { + RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry. + Platform string // Platform is the target platform of the image if it needs to be pulled from the registry. +} + +// PullOptions holds information to pull images. +type PullOptions struct { + All bool + RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry + + // PrivilegeFunc is a function that clients can supply to retry operations + // after getting an authorization error. This function returns the registry + // authentication header value in base64 encoded format, or an error if the + // privilege request fails. + // + // Also see [github.com/docker/docker/api/types.RequestPrivilegeFunc]. + PrivilegeFunc func() (string, error) + Platform string +} + +// PushOptions holds information to push images. +type PushOptions PullOptions + +// ListOptions holds parameters to list images with. +type ListOptions struct { + // All controls whether all images in the graph are filtered, or just + // the heads. + All bool + + // Filters is a JSON-encoded set of filter arguments. + Filters filters.Args + + // SharedSize indicates whether the shared size of images should be computed. + SharedSize bool + + // ContainerCount indicates whether container count should be computed. + ContainerCount bool +} + +// RemoveOptions holds parameters to remove images. +type RemoveOptions struct { + Force bool + PruneChildren bool +} diff --git a/api/types/types_deprecated.go b/api/types/types_deprecated.go index e332a7bb6d..d6eef82150 100644 --- a/api/types/types_deprecated.go +++ b/api/types/types_deprecated.go @@ -136,3 +136,33 @@ type ContainerRemoveOptions = container.RemoveOptions func DecodeSecurityOptions(opts []string) ([]system.SecurityOpt, error) { return system.DecodeSecurityOptions(opts) } + +// ImageImportOptions holds information to import images from the client host. +// +// Deprecated: use [image.ImportOptions]. +type ImageImportOptions = image.ImportOptions + +// ImageCreateOptions holds information to create images. +// +// Deprecated: use [image.CreateOptions]. +type ImageCreateOptions = image.CreateOptions + +// ImagePullOptions holds information to pull images. +// +// Deprecated: use [image.PullOptions]. +type ImagePullOptions = image.PullOptions + +// ImagePushOptions holds information to push images. +// +// Deprecated: use [image.PushOptions]. +type ImagePushOptions = image.PushOptions + +// ImageListOptions holds parameters to list images with. +// +// Deprecated: use [image.ListOptions]. +type ImageListOptions = image.ListOptions + +// ImageRemoveOptions holds parameters to remove images. +// +// Deprecated: use [image.RemoveOptions]. +type ImageRemoveOptions = image.RemoveOptions diff --git a/client/image_create.go b/client/image_create.go index 29cd0b4373..7c7873dca5 100644 --- a/client/image_create.go +++ b/client/image_create.go @@ -8,13 +8,13 @@ import ( "strings" "github.com/distribution/reference" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" ) // ImageCreate creates a new image based on the parent options. // It returns the JSON content in the response body. -func (cli *Client) ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) { +func (cli *Client) ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error) { ref, err := reference.ParseNormalizedNamed(parentReference) if err != nil { return nil, err diff --git a/client/image_create_test.go b/client/image_create_test.go index 80107696ae..9098c8f0f3 100644 --- a/client/image_create_test.go +++ b/client/image_create_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" @@ -20,7 +20,7 @@ func TestImageCreateError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.ImageCreate(context.Background(), "reference", types.ImageCreateOptions{}) + _, err := client.ImageCreate(context.Background(), "reference", image.CreateOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } @@ -58,7 +58,7 @@ func TestImageCreate(t *testing.T) { }), } - createResponse, err := client.ImageCreate(context.Background(), expectedReference, types.ImageCreateOptions{ + createResponse, err := client.ImageCreate(context.Background(), expectedReference, image.CreateOptions{ RegistryAuth: expectedRegistryAuth, }) if err != nil { diff --git a/client/image_import.go b/client/image_import.go index cd376a14e5..5a890b0c59 100644 --- a/client/image_import.go +++ b/client/image_import.go @@ -8,11 +8,12 @@ import ( "github.com/distribution/reference" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" ) // ImageImport creates a new image based on the source options. // It returns the JSON content in the response body. -func (cli *Client) ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) { +func (cli *Client) ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) { if ref != "" { // Check if the given image name can be resolved if _, err := reference.ParseNormalizedNamed(ref); err != nil { diff --git a/client/image_import_test.go b/client/image_import_test.go index abc381f652..237b5ae88c 100644 --- a/client/image_import_test.go +++ b/client/image_import_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -20,7 +21,7 @@ func TestImageImportError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.ImageImport(context.Background(), types.ImageImportSource{}, "image:tag", types.ImageImportOptions{}) + _, err := client.ImageImport(context.Background(), types.ImageImportSource{}, "image:tag", image.ImportOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } @@ -63,7 +64,7 @@ func TestImageImport(t *testing.T) { importResponse, err := client.ImageImport(context.Background(), types.ImageImportSource{ Source: strings.NewReader("source"), SourceName: "image_source", - }, "repository_name:imported", types.ImageImportOptions{ + }, "repository_name:imported", image.ImportOptions{ Tag: "imported", Message: "A message", Changes: []string{"change1", "change2"}, diff --git a/client/image_list.go b/client/image_list.go index f3f2280e32..b4df6ff86a 100644 --- a/client/image_list.go +++ b/client/image_list.go @@ -5,14 +5,13 @@ import ( "encoding/json" "net/url" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/versions" ) // ImageList returns a list of images in the docker host. -func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]image.Summary, error) { +func (cli *Client) ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error) { // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // diff --git a/client/image_list_test.go b/client/image_list_test.go index bcd6db7d98..0320b14258 100644 --- a/client/image_list_test.go +++ b/client/image_list_test.go @@ -11,7 +11,6 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/image" "github.com/docker/docker/errdefs" @@ -24,7 +23,7 @@ func TestImageListError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.ImageList(context.Background(), types.ImageListOptions{}) + _, err := client.ImageList(context.Background(), image.ListOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } @@ -32,11 +31,11 @@ func TestImageList(t *testing.T) { const expectedURL = "/images/json" listCases := []struct { - options types.ImageListOptions + options image.ListOptions expectedQueryParams map[string]string }{ { - options: types.ImageListOptions{}, + options: image.ListOptions{}, expectedQueryParams: map[string]string{ "all": "", "filter": "", @@ -44,7 +43,7 @@ func TestImageList(t *testing.T) { }, }, { - options: types.ImageListOptions{ + options: image.ListOptions{ Filters: filters.NewArgs( filters.Arg("label", "label1"), filters.Arg("label", "label2"), @@ -58,7 +57,7 @@ func TestImageList(t *testing.T) { }, }, { - options: types.ImageListOptions{ + options: image.ListOptions{ Filters: filters.NewArgs(filters.Arg("dangling", "false")), }, expectedQueryParams: map[string]string{ @@ -141,7 +140,7 @@ func TestImageListApiBefore125(t *testing.T) { version: "1.24", } - options := types.ImageListOptions{ + options := image.ListOptions{ Filters: filters.NewArgs(filters.Arg("reference", "image:tag")), } @@ -162,12 +161,12 @@ func TestImageListWithSharedSize(t *testing.T) { for _, tc := range []struct { name string version string - options types.ImageListOptions + options image.ListOptions sharedSize string // expected value for the shared-size query param, or empty if it should not be set. }{ {name: "unset after 1.42, no options set", version: "1.42"}, - {name: "set after 1.42, if requested", version: "1.42", options: types.ImageListOptions{SharedSize: true}, sharedSize: "1"}, - {name: "unset before 1.42, even if requested", version: "1.41", options: types.ImageListOptions{SharedSize: true}}, + {name: "set after 1.42, if requested", version: "1.42", options: image.ListOptions{SharedSize: true}, sharedSize: "1"}, + {name: "unset before 1.42, even if requested", version: "1.41", options: image.ListOptions{SharedSize: true}}, } { tc := tc t.Run(tc.name, func(t *testing.T) { diff --git a/client/image_pull.go b/client/image_pull.go index d92049d588..6438cf6a96 100644 --- a/client/image_pull.go +++ b/client/image_pull.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/distribution/reference" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/errdefs" ) @@ -19,7 +19,7 @@ import ( // FIXME(vdemeester): there is currently used in a few way in docker/docker // - if not in trusted content, ref is used to pass the whole reference, and tag is empty // - if in trusted content, ref is used to pass the reference name, and tag for the digest -func (cli *Client) ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) { +func (cli *Client) ImagePull(ctx context.Context, refStr string, options image.PullOptions) (io.ReadCloser, error) { ref, err := reference.ParseNormalizedNamed(refStr) if err != nil { return nil, err diff --git a/client/image_pull_test.go b/client/image_pull_test.go index 2c81cddff3..d5a6b26069 100644 --- a/client/image_pull_test.go +++ b/client/image_pull_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" @@ -23,7 +23,7 @@ func TestImagePullReferenceParseError(t *testing.T) { }), } // An empty reference is an invalid reference - _, err := client.ImagePull(context.Background(), "", types.ImagePullOptions{}) + _, err := client.ImagePull(context.Background(), "", image.PullOptions{}) if err == nil || !strings.Contains(err.Error(), "invalid reference format") { t.Fatalf("expected an error, got %v", err) } @@ -33,7 +33,7 @@ func TestImagePullAnyError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{}) + _, err := client.ImagePull(context.Background(), "myimage", image.PullOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } @@ -41,7 +41,7 @@ func TestImagePullStatusUnauthorizedError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")), } - _, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{}) + _, err := client.ImagePull(context.Background(), "myimage", image.PullOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized)) } @@ -52,7 +52,7 @@ func TestImagePullWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) { privilegeFunc := func() (string, error) { return "", fmt.Errorf("Error requesting privilege") } - _, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{ + _, err := client.ImagePull(context.Background(), "myimage", image.PullOptions{ PrivilegeFunc: privilegeFunc, }) if err == nil || err.Error() != "Error requesting privilege" { @@ -67,7 +67,7 @@ func TestImagePullWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T) privilegeFunc := func() (string, error) { return "a-auth-header", nil } - _, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{ + _, err := client.ImagePull(context.Background(), "myimage", image.PullOptions{ PrivilegeFunc: privilegeFunc, }) assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized)) @@ -108,7 +108,7 @@ func TestImagePullWithPrivilegedFuncNoError(t *testing.T) { privilegeFunc := func() (string, error) { return "IAmValid", nil } - resp, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{ + resp, err := client.ImagePull(context.Background(), "myimage", image.PullOptions{ RegistryAuth: "NotValid", PrivilegeFunc: privilegeFunc, }) @@ -179,7 +179,7 @@ func TestImagePullWithoutErrors(t *testing.T) { }, nil }), } - resp, err := client.ImagePull(context.Background(), pullCase.reference, types.ImagePullOptions{ + resp, err := client.ImagePull(context.Background(), pullCase.reference, image.PullOptions{ All: pullCase.all, }) if err != nil { diff --git a/client/image_push.go b/client/image_push.go index 6839a89e07..e6a6b11eea 100644 --- a/client/image_push.go +++ b/client/image_push.go @@ -8,7 +8,7 @@ import ( "net/url" "github.com/distribution/reference" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/errdefs" ) @@ -17,7 +17,7 @@ import ( // It executes the privileged function if the operation is unauthorized // and it tries one more time. // It's up to the caller to handle the io.ReadCloser and close it properly. -func (cli *Client) ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error) { +func (cli *Client) ImagePush(ctx context.Context, image string, options image.PushOptions) (io.ReadCloser, error) { ref, err := reference.ParseNormalizedNamed(image) if err != nil { return nil, err diff --git a/client/image_push_test.go b/client/image_push_test.go index d39af7d410..b79ce49d68 100644 --- a/client/image_push_test.go +++ b/client/image_push_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" @@ -23,12 +23,12 @@ func TestImagePushReferenceError(t *testing.T) { }), } // An empty reference is an invalid reference - _, err := client.ImagePush(context.Background(), "", types.ImagePushOptions{}) + _, err := client.ImagePush(context.Background(), "", image.PushOptions{}) if err == nil || !strings.Contains(err.Error(), "invalid reference format") { t.Fatalf("expected an error, got %v", err) } // An canonical reference cannot be pushed - _, err = client.ImagePush(context.Background(), "repo@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", types.ImagePushOptions{}) + _, err = client.ImagePush(context.Background(), "repo@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", image.PushOptions{}) if err == nil || err.Error() != "cannot push a digest reference" { t.Fatalf("expected an error, got %v", err) } @@ -38,7 +38,7 @@ func TestImagePushAnyError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{}) + _, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } @@ -46,7 +46,7 @@ func TestImagePushStatusUnauthorizedError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")), } - _, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{}) + _, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized)) } @@ -57,7 +57,7 @@ func TestImagePushWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) { privilegeFunc := func() (string, error) { return "", fmt.Errorf("Error requesting privilege") } - _, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{ + _, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{ PrivilegeFunc: privilegeFunc, }) if err == nil || err.Error() != "Error requesting privilege" { @@ -72,7 +72,7 @@ func TestImagePushWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T) privilegeFunc := func() (string, error) { return "a-auth-header", nil } - _, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{ + _, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{ PrivilegeFunc: privilegeFunc, }) assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized)) @@ -109,7 +109,7 @@ func TestImagePushWithPrivilegedFuncNoError(t *testing.T) { privilegeFunc := func() (string, error) { return "IAmValid", nil } - resp, err := client.ImagePush(context.Background(), "myimage:tag", types.ImagePushOptions{ + resp, err := client.ImagePush(context.Background(), "myimage:tag", image.PushOptions{ RegistryAuth: "NotValid", PrivilegeFunc: privilegeFunc, }) @@ -179,7 +179,7 @@ func TestImagePushWithoutErrors(t *testing.T) { }, nil }), } - resp, err := client.ImagePush(context.Background(), tc.reference, types.ImagePushOptions{ + resp, err := client.ImagePush(context.Background(), tc.reference, image.PushOptions{ All: tc.all, }) if err != nil { diff --git a/client/image_remove.go b/client/image_remove.go index b936d20830..652d1bfa3e 100644 --- a/client/image_remove.go +++ b/client/image_remove.go @@ -5,12 +5,11 @@ import ( "encoding/json" "net/url" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/image" ) // ImageRemove removes an image from the docker host. -func (cli *Client) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error) { +func (cli *Client) ImageRemove(ctx context.Context, imageID string, options image.RemoveOptions) ([]image.DeleteResponse, error) { query := url.Values{} if options.Force { diff --git a/client/image_remove_test.go b/client/image_remove_test.go index 9614f8572c..dfe6c03441 100644 --- a/client/image_remove_test.go +++ b/client/image_remove_test.go @@ -10,7 +10,6 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/image" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" @@ -22,7 +21,7 @@ func TestImageRemoveError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.ImageRemove(context.Background(), "image_id", types.ImageRemoveOptions{}) + _, err := client.ImageRemove(context.Background(), "image_id", image.RemoveOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } @@ -31,7 +30,7 @@ func TestImageRemoveImageNotFound(t *testing.T) { client: newMockClient(errorMock(http.StatusNotFound, "no such image: unknown")), } - _, err := client.ImageRemove(context.Background(), "unknown", types.ImageRemoveOptions{}) + _, err := client.ImageRemove(context.Background(), "unknown", image.RemoveOptions{}) assert.Check(t, is.ErrorContains(err, "no such image: unknown")) assert.Check(t, is.ErrorType(err, errdefs.IsNotFound)) } @@ -93,7 +92,7 @@ func TestImageRemove(t *testing.T) { }, nil }), } - imageDeletes, err := client.ImageRemove(context.Background(), "image_id", types.ImageRemoveOptions{ + imageDeletes, err := client.ImageRemove(context.Background(), "image_id", image.RemoveOptions{ Force: removeCase.force, PruneChildren: removeCase.pruneChildren, }) diff --git a/client/interface.go b/client/interface.go index 302f5fb13e..45d233f253 100644 --- a/client/interface.go +++ b/client/interface.go @@ -90,15 +90,15 @@ type ImageAPIClient interface { ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) BuildCancel(ctx context.Context, id string) error - ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) + ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error) ImageHistory(ctx context.Context, image string) ([]image.HistoryResponseItem, error) - ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) + ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error) - ImageList(ctx context.Context, options types.ImageListOptions) ([]image.Summary, error) + ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error) ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error) - ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error) - ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) - ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error) + ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error) + ImagePush(ctx context.Context, ref string, options image.PushOptions) (io.ReadCloser, error) + ImageRemove(ctx context.Context, image string, options image.RemoveOptions) ([]image.DeleteResponse, error) ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error) ImageSave(ctx context.Context, images []string) (io.ReadCloser, error) ImageTag(ctx context.Context, image, ref string) error diff --git a/daemon/containerd/image_list.go b/daemon/containerd/image_list.go index cb5b04a8ce..bc4761acc6 100644 --- a/daemon/containerd/image_list.go +++ b/daemon/containerd/image_list.go @@ -14,7 +14,6 @@ import ( "github.com/containerd/containerd/snapshots" "github.com/containerd/log" "github.com/distribution/reference" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" "github.com/docker/docker/api/types/filters" imagetypes "github.com/docker/docker/api/types/image" @@ -61,7 +60,7 @@ func (r byCreated) Less(i, j int) bool { return r[i].Created < r[j].Created } // TODO(thaJeztah): implement opts.ContainerCount (used for docker system df); see https://github.com/moby/moby/issues/43853 // TODO(thaJeztah): verify behavior of `RepoDigests` and `RepoTags` for images without (untagged) or multiple tags; see https://github.com/moby/moby/issues/43861 // TODO(thaJeztah): verify "Size" vs "VirtualSize" in images; see https://github.com/moby/moby/issues/43862 -func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) ([]*imagetypes.Summary, error) { +func (i *ImageService) Images(ctx context.Context, opts imagetypes.ListOptions) ([]*imagetypes.Summary, error) { if err := opts.Filters.Validate(acceptedImageFilterTags); err != nil { return nil, err } @@ -212,7 +211,7 @@ func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) return summaries, nil } -func (i *ImageService) singlePlatformImage(ctx context.Context, contentStore content.Store, repoTags []string, imageManifest *ImageManifest, opts types.ImageListOptions, allContainers []*container.Container) (*imagetypes.Summary, []digest.Digest, error) { +func (i *ImageService) singlePlatformImage(ctx context.Context, contentStore content.Store, repoTags []string, imageManifest *ImageManifest, opts imagetypes.ListOptions, allContainers []*container.Container) (*imagetypes.Summary, []digest.Digest, error) { diffIDs, err := imageManifest.RootFS(ctx) if err != nil { return nil, nil, errors.Wrapf(err, "failed to get rootfs of image %s", imageManifest.Name()) diff --git a/daemon/disk_usage.go b/daemon/disk_usage.go index f9987e2dd1..5ed6c1b729 100644 --- a/daemon/disk_usage.go +++ b/daemon/disk_usage.go @@ -36,7 +36,7 @@ func (daemon *Daemon) containerDiskUsage(ctx context.Context) ([]*types.Containe func (daemon *Daemon) imageDiskUsage(ctx context.Context) ([]*image.Summary, error) { imgs, _, err := daemon.usageImages.Do(ctx, struct{}{}, func(ctx context.Context) ([]*image.Summary, error) { // Get all top images with extra attributes - imgs, err := daemon.imageService.Images(ctx, types.ImageListOptions{ + imgs, err := daemon.imageService.Images(ctx, image.ListOptions{ Filters: filters.NewArgs(), SharedSize: true, ContainerCount: true, diff --git a/daemon/image_service.go b/daemon/image_service.go index c782b1e52c..12a61b4022 100644 --- a/daemon/image_service.go +++ b/daemon/image_service.go @@ -34,7 +34,7 @@ type ImageService interface { ExportImage(ctx context.Context, names []string, outStream io.Writer) error PerformWithBaseFS(ctx context.Context, c *container.Container, fn func(string) error) error LoadImage(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) error - Images(ctx context.Context, opts types.ImageListOptions) ([]*imagetype.Summary, error) + Images(ctx context.Context, opts imagetype.ListOptions) ([]*imagetype.Summary, error) LogImageEvent(imageID, refName string, action events.Action) CountImages(ctx context.Context) int ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error) diff --git a/daemon/images/image_list.go b/daemon/images/image_list.go index 8e30ae5518..833ecc35f9 100644 --- a/daemon/images/image_list.go +++ b/daemon/images/image_list.go @@ -8,7 +8,6 @@ import ( "time" "github.com/distribution/reference" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" imagetypes "github.com/docker/docker/api/types/image" timetypes "github.com/docker/docker/api/types/time" @@ -35,7 +34,7 @@ func (r byCreated) Swap(i, j int) { r[i], r[j] = r[j], r[i] } func (r byCreated) Less(i, j int) bool { return r[i].Created < r[j].Created } // Images returns a filtered list of images. -func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) ([]*imagetypes.Summary, error) { +func (i *ImageService) Images(ctx context.Context, opts imagetypes.ListOptions) ([]*imagetypes.Summary, error) { if err := opts.Filters.Validate(acceptedImageFilterTags); err != nil { return nil, err } diff --git a/distribution/xfer/download.go b/distribution/xfer/download.go index 1f8d7c10a7..4839134188 100644 --- a/distribution/xfer/download.go +++ b/distribution/xfer/download.go @@ -364,7 +364,7 @@ func (ldm *LayerDownloadManager) makeDownloadFunc(descriptor DownloadDescriptor, return } - progress.Update(progressOutput, descriptor.ID(), "Pull complete") + progress.Update(progressOutput, descriptor.ID(), "PullOptions complete") if withRegistered, ok := descriptor.(DigestRegisterer); ok { withRegistered.Registered(d.layer.DiffID()) diff --git a/distribution/xfer/download_test.go b/distribution/xfer/download_test.go index ca48388977..f6e6e3f8b7 100644 --- a/distribution/xfer/download_test.go +++ b/distribution/xfer/download_test.go @@ -316,8 +316,8 @@ func TestSuccessfulDownload(t *testing.T) { if receivedProgress[d.ID()].Action != "Already exists" { t.Fatalf("did not get 'Already exists' message for %v", d.ID()) } - } else if receivedProgress[d.ID()].Action != "Pull complete" { - t.Fatalf("did not get 'Pull complete' message for %v", d.ID()) + } else if receivedProgress[d.ID()].Action != "PullOptions complete" { + t.Fatalf("did not get 'PullOptions complete' message for %v", d.ID()) } if rootFS.DiffIDs[i] != descriptor.expectedDiffID { diff --git a/integration-cli/docker_api_build_test.go b/integration-cli/docker_api_build_test.go index 046cb01c01..6dbc271c6c 100644 --- a/integration-cli/docker_api_build_test.go +++ b/integration-cli/docker_api_build_test.go @@ -11,7 +11,7 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/testutil" "github.com/docker/docker/testutil/fakecontext" "github.com/docker/docker/testutil/fakegit" @@ -336,7 +336,7 @@ func (s *DockerRegistrySuite) TestBuildCopyFromForcePull(c *testing.T) { err := client.ImageTag(ctx, "busybox", repoName) assert.Check(c, err) // push the image to the registry - rc, err := client.ImagePush(ctx, repoName, types.ImagePushOptions{RegistryAuth: "{}"}) + rc, err := client.ImagePush(ctx, repoName, image.PushOptions{RegistryAuth: "{}"}) assert.Check(c, err) _, err = io.Copy(io.Discard, rc) assert.Check(c, err) diff --git a/integration-cli/docker_api_images_test.go b/integration-cli/docker_api_images_test.go index f7ac555855..e03ad4df4d 100644 --- a/integration-cli/docker_api_images_test.go +++ b/integration-cli/docker_api_images_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" @@ -51,13 +51,13 @@ func (s *DockerAPISuite) TestAPIImagesDelete(c *testing.T) { cli.DockerCmd(c, "tag", name, "test:tag1") - _, err = apiClient.ImageRemove(testutil.GetContext(c), id, types.ImageRemoveOptions{}) + _, err = apiClient.ImageRemove(testutil.GetContext(c), id, image.RemoveOptions{}) assert.ErrorContains(c, err, "unable to delete") - _, err = apiClient.ImageRemove(testutil.GetContext(c), "test:noexist", types.ImageRemoveOptions{}) + _, err = apiClient.ImageRemove(testutil.GetContext(c), "test:noexist", image.RemoveOptions{}) assert.ErrorContains(c, err, "No such image") - _, err = apiClient.ImageRemove(testutil.GetContext(c), "test:tag1", types.ImageRemoveOptions{}) + _, err = apiClient.ImageRemove(testutil.GetContext(c), "test:tag1", image.RemoveOptions{}) assert.NilError(c, err) } @@ -129,7 +129,7 @@ func (s *DockerAPISuite) TestAPIImagesSizeCompatibility(c *testing.T) { apiclient := testEnv.APIClient() defer apiclient.Close() - images, err := apiclient.ImageList(testutil.GetContext(c), types.ImageListOptions{}) + images, err := apiclient.ImageList(testutil.GetContext(c), image.ListOptions{}) assert.NilError(c, err) assert.Assert(c, len(images) != 0) for _, img := range images { @@ -140,7 +140,7 @@ func (s *DockerAPISuite) TestAPIImagesSizeCompatibility(c *testing.T) { assert.NilError(c, err) defer apiclient.Close() - v124Images, err := apiclient.ImageList(testutil.GetContext(c), types.ImageListOptions{}) + v124Images, err := apiclient.ImageList(testutil.GetContext(c), image.ListOptions{}) assert.NilError(c, err) assert.Assert(c, len(v124Images) != 0) for _, img := range v124Images { diff --git a/integration/container/export_test.go b/integration/container/export_test.go index 41609d00a9..fd35a61ffc 100644 --- a/integration/container/export_test.go +++ b/integration/container/export_test.go @@ -8,6 +8,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/testutil" @@ -34,7 +35,7 @@ func TestExportContainerAndImportImage(t *testing.T) { importResp, err := apiClient.ImageImport(ctx, types.ImageImportSource{ Source: exportResp, SourceName: "-", - }, reference, types.ImageImportOptions{}) + }, reference, image.ImportOptions{}) assert.NilError(t, err) // If the import is successfully, then the message output should contain @@ -45,7 +46,7 @@ func TestExportContainerAndImportImage(t *testing.T) { err = dec.Decode(&jm) assert.NilError(t, err) - images, err := apiClient.ImageList(ctx, types.ImageListOptions{ + images, err := apiClient.ImageList(ctx, image.ListOptions{ Filters: filters.NewArgs(filters.Arg("reference", reference)), }) assert.NilError(t, err) diff --git a/integration/daemon/daemon_test.go b/integration/daemon/daemon_test.go index e7605b2b23..60a9b3bc69 100644 --- a/integration/daemon/daemon_test.go +++ b/integration/daemon/daemon_test.go @@ -14,8 +14,8 @@ import ( "syscall" "testing" - "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/volume" "github.com/docker/docker/daemon/config" @@ -219,12 +219,12 @@ func TestDaemonProxy(t *testing.T) { assert.Check(t, is.Equal(info.HTTPSProxy, proxyServer.URL)) assert.Check(t, is.Equal(info.NoProxy, "example.com")) - _, err := c.ImagePull(ctx, "example.org:5000/some/image:latest", types.ImagePullOptions{}) + _, err := c.ImagePull(ctx, "example.org:5000/some/image:latest", image.PullOptions{}) assert.ErrorContains(t, err, "", "pulling should have failed") assert.Equal(t, received, "example.org:5000") // Test NoProxy: example.com should not hit the proxy, and "received" variable should not be changed. - _, err = c.ImagePull(ctx, "example.com/some/image:latest", types.ImagePullOptions{}) + _, err = c.ImagePull(ctx, "example.com/some/image:latest", image.PullOptions{}) assert.ErrorContains(t, err, "", "pulling should have failed") assert.Equal(t, received, "example.org:5000", "should not have used proxy") }) @@ -270,12 +270,12 @@ func TestDaemonProxy(t *testing.T) { ok, logs := d.ScanLogsT(ctx, t, daemon.ScanLogsMatchString(userPass)) assert.Assert(t, !ok, "logs should not contain the non-sanitized proxy URL: %s", logs) - _, err := c.ImagePull(ctx, "example.org:5001/some/image:latest", types.ImagePullOptions{}) + _, err := c.ImagePull(ctx, "example.org:5001/some/image:latest", image.PullOptions{}) assert.ErrorContains(t, err, "", "pulling should have failed") assert.Equal(t, received, "example.org:5001") // Test NoProxy: example.com should not hit the proxy, and "received" variable should not be changed. - _, err = c.ImagePull(ctx, "example.com/some/image:latest", types.ImagePullOptions{}) + _, err = c.ImagePull(ctx, "example.com/some/image:latest", image.PullOptions{}) assert.ErrorContains(t, err, "", "pulling should have failed") assert.Equal(t, received, "example.org:5001", "should not have used proxy") }) @@ -320,12 +320,12 @@ func TestDaemonProxy(t *testing.T) { "NO_PROXY", )) - _, err := c.ImagePull(ctx, "example.org:5002/some/image:latest", types.ImagePullOptions{}) + _, err := c.ImagePull(ctx, "example.org:5002/some/image:latest", image.PullOptions{}) assert.ErrorContains(t, err, "", "pulling should have failed") assert.Equal(t, received, "example.org:5002") // Test NoProxy: example.com should not hit the proxy, and "received" variable should not be changed. - _, err = c.ImagePull(ctx, "example.com/some/image:latest", types.ImagePullOptions{}) + _, err = c.ImagePull(ctx, "example.com/some/image:latest", image.PullOptions{}) assert.ErrorContains(t, err, "", "pulling should have failed") assert.Equal(t, received, "example.org:5002", "should not have used proxy") }) diff --git a/integration/image/import_test.go b/integration/image/import_test.go index b624498533..5821ae3b47 100644 --- a/integration/image/import_test.go +++ b/integration/image/import_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/docker/docker/api/types" + imagetypes "github.com/docker/docker/api/types/image" "github.com/docker/docker/image" "github.com/docker/docker/testutil" "github.com/docker/docker/testutil/daemon" @@ -47,7 +48,7 @@ func TestImportExtremelyLargeImageWorks(t *testing.T) { _, err = client.ImageImport(ctx, types.ImageImportSource{Source: imageRdr, SourceName: "-"}, reference, - types.ImageImportOptions{}) + imagetypes.ImportOptions{}) assert.NilError(t, err) } @@ -110,7 +111,7 @@ func TestImportWithCustomPlatform(t *testing.T) { _, err = client.ImageImport(ctx, types.ImageImportSource{Source: imageRdr, SourceName: "-"}, reference, - types.ImageImportOptions{Platform: tc.platform}) + imagetypes.ImportOptions{Platform: tc.platform}) assert.NilError(t, err) inspect, _, err := client.ImageInspectWithRaw(ctx, reference) @@ -176,7 +177,7 @@ func TestImportWithCustomPlatformReject(t *testing.T) { _, err = client.ImageImport(ctx, types.ImageImportSource{Source: imageRdr, SourceName: "-"}, reference, - types.ImageImportOptions{Platform: tc.platform}) + imagetypes.ImportOptions{Platform: tc.platform}) assert.ErrorContains(t, err, tc.expectedErr) }) diff --git a/integration/image/list_test.go b/integration/image/list_test.go index 5e3256c7ae..88a89b7060 100644 --- a/integration/image/list_test.go +++ b/integration/image/list_test.go @@ -6,9 +6,9 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/testutil" "github.com/google/go-cmp/cmp/cmpopts" @@ -39,7 +39,7 @@ func TestImagesFilterMultiReference(t *testing.T) { filter.Add("reference", repoTags[0]) filter.Add("reference", repoTags[1]) filter.Add("reference", repoTags[2]) - options := types.ImageListOptions{ + options := image.ListOptions{ Filters: filter, } images, err := client.ImageList(ctx, options) @@ -87,7 +87,7 @@ func TestImagesFilterUntil(t *testing.T) { filters.Arg("until", laterUntil), filters.Arg("before", imgs[len(imgs)-1]), ) - list, err := client.ImageList(ctx, types.ImageListOptions{Filters: filter}) + list, err := client.ImageList(ctx, image.ListOptions{Filters: filter}) assert.NilError(t, err) var listedIDs []string @@ -121,7 +121,7 @@ func TestImagesFilterBeforeSince(t *testing.T) { filters.Arg("since", imgs[0]), filters.Arg("before", imgs[len(imgs)-1]), ) - list, err := client.ImageList(ctx, types.ImageListOptions{Filters: filter}) + list, err := client.ImageList(ctx, image.ListOptions{Filters: filter}) assert.NilError(t, err) var listedIDs []string @@ -183,7 +183,7 @@ func TestAPIImagesFilters(t *testing.T) { t.Parallel() ctx := testutil.StartSpan(ctx, t) - images, err := client.ImageList(ctx, types.ImageListOptions{ + images, err := client.ImageList(ctx, image.ListOptions{ Filters: filters.NewArgs(tc.filters...), }) assert.Check(t, err) diff --git a/integration/image/pull_test.go b/integration/image/pull_test.go index 5089e2c250..ed9aced148 100644 --- a/integration/image/pull_test.go +++ b/integration/image/pull_test.go @@ -15,7 +15,7 @@ import ( "github.com/containerd/containerd/content/local" "github.com/containerd/containerd/images" "github.com/containerd/containerd/platforms" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/errdefs" "github.com/docker/docker/testutil/registry" "github.com/opencontainers/go-digest" @@ -31,7 +31,7 @@ func TestImagePullPlatformInvalid(t *testing.T) { client := testEnv.APIClient() - _, err := client.ImagePull(ctx, "docker.io/library/hello-world:latest", types.ImagePullOptions{Platform: "foobar"}) + _, err := client.ImagePull(ctx, "docker.io/library/hello-world:latest", image.PullOptions{Platform: "foobar"}) assert.Assert(t, err != nil) assert.Check(t, is.ErrorContains(err, "unknown operating system or architecture")) assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter)) @@ -143,14 +143,14 @@ func TestImagePullStoredDigestForOtherRepo(t *testing.T) { assert.NilError(t, err) client := testEnv.APIClient() - rdr, err := client.ImagePull(ctx, remote, types.ImagePullOptions{}) + rdr, err := client.ImagePull(ctx, remote, image.PullOptions{}) assert.NilError(t, err) defer rdr.Close() _, err = io.Copy(io.Discard, rdr) assert.Check(t, err) // Now, pull a totally different repo with a the same digest - rdr, err = client.ImagePull(ctx, path.Join(registry.DefaultURL, "other:image@"+desc.Digest.String()), types.ImagePullOptions{}) + rdr, err = client.ImagePull(ctx, path.Join(registry.DefaultURL, "other:image@"+desc.Digest.String()), image.PullOptions{}) if rdr != nil { assert.Check(t, rdr.Close()) } @@ -178,7 +178,7 @@ func TestImagePullNonExisting(t *testing.T) { t.Parallel() client := testEnv.APIClient() - rdr, err := client.ImagePull(ctx, ref, types.ImagePullOptions{ + rdr, err := client.ImagePull(ctx, ref, image.PullOptions{ All: all, }) if err == nil { diff --git a/integration/image/remove_test.go b/integration/image/remove_test.go index a029ff6c4c..898fd37401 100644 --- a/integration/image/remove_test.go +++ b/integration/image/remove_test.go @@ -4,8 +4,8 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/errdefs" "github.com/docker/docker/integration/internal/container" "gotest.tools/v3/assert" @@ -47,7 +47,7 @@ func TestRemoveImageOrphaning(t *testing.T) { assert.Check(t, is.Equal(resp.ID, commitResp2.ID)) // try to remove the image, should not error out. - _, err = client.ImageRemove(ctx, imgName, types.ImageRemoveOptions{}) + _, err = client.ImageRemove(ctx, imgName, image.RemoveOptions{}) assert.NilError(t, err) // check if the first image is still there @@ -82,7 +82,7 @@ func TestRemoveByDigest(t *testing.T) { assert.Assert(t, id != "") t.Logf("removing %s", id) - _, err = client.ImageRemove(ctx, id, types.ImageRemoveOptions{}) + _, err = client.ImageRemove(ctx, id, image.RemoveOptions{}) assert.NilError(t, err) inspect, _, err = client.ImageInspectWithRaw(ctx, "busybox") diff --git a/integration/image/remove_unix_test.go b/integration/image/remove_unix_test.go index d84bfcf039..06d3983047 100644 --- a/integration/image/remove_unix_test.go +++ b/integration/image/remove_unix_test.go @@ -13,6 +13,7 @@ import ( "unsafe" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" _ "github.com/docker/docker/daemon/graphdriver/register" // register graph drivers "github.com/docker/docker/daemon/images" "github.com/docker/docker/layer" @@ -76,11 +77,11 @@ func TestRemoveImageGarbageCollector(t *testing.T) { _, err = io.Copy(io.Discard, resp.Body) resp.Body.Close() assert.NilError(t, err) - image, _, err := client.ImageInspectWithRaw(ctx, imgName) + img, _, err := client.ImageInspectWithRaw(ctx, imgName) assert.NilError(t, err) // Mark latest image layer to immutable - data := image.GraphDriver.Data + data := img.GraphDriver.Data file, _ := os.Open(data["UpperDir"]) attr := 0x00000010 fsflags := uintptr(0x40086602) @@ -90,7 +91,7 @@ func TestRemoveImageGarbageCollector(t *testing.T) { // Try to remove the image, it should generate error // but marking layer back to mutable before checking errors (so we don't break CI server) - _, err = client.ImageRemove(ctx, imgName, types.ImageRemoveOptions{}) + _, err = client.ImageRemove(ctx, imgName, image.RemoveOptions{}) attr = 0x00000000 argp = uintptr(unsafe.Pointer(&attr)) _, _, errno = syscall.Syscall(syscall.SYS_IOCTL, file.Fd(), fsflags, argp) diff --git a/integration/internal/build/build.go b/integration/internal/build/build.go index 0631a53605..6c3d64c0d4 100644 --- a/integration/internal/build/build.go +++ b/integration/internal/build/build.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" "github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/testutil/fakecontext" @@ -22,7 +23,7 @@ func Do(ctx context.Context, t *testing.T, client client.APIClient, buildCtx *fa assert.NilError(t, err) img := GetImageIDFromBody(t, resp.Body) t.Cleanup(func() { - client.ImageRemove(ctx, img, types.ImageRemoveOptions{Force: true}) + client.ImageRemove(ctx, img, image.RemoveOptions{Force: true}) }) return img } diff --git a/integration/plugin/authz/authz_plugin_test.go b/integration/plugin/authz/authz_plugin_test.go index f271bfb9fe..8fbe48f273 100644 --- a/integration/plugin/authz/authz_plugin_test.go +++ b/integration/plugin/authz/authz_plugin_test.go @@ -19,6 +19,7 @@ import ( "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" eventtypes "github.com/docker/docker/api/types/events" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/pkg/archive" @@ -460,7 +461,7 @@ func imageImport(ctx context.Context, client client.APIClient, path string) erro return err } defer file.Close() - options := types.ImageImportOptions{} + options := image.ImportOptions{} ref := "" source := types.ImageImportSource{ Source: file, diff --git a/integration/plugin/graphdriver/external_test.go b/integration/plugin/graphdriver/external_test.go index 1c74f123de..f2228f89f7 100644 --- a/integration/plugin/graphdriver/external_test.go +++ b/integration/plugin/graphdriver/external_test.go @@ -13,6 +13,7 @@ import ( "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/daemon/graphdriver/vfs" @@ -398,7 +399,7 @@ func testGraphDriverPull(ctx context.Context, c client.APIClient, d *daemon.Daem d.Start(t) defer d.Stop(t) - r, err := c.ImagePull(ctx, "busybox:latest@sha256:95cf004f559831017cdf4628aaf1bb30133677be8702a8c5f2994629f637a209", types.ImagePullOptions{}) + r, err := c.ImagePull(ctx, "busybox:latest@sha256:95cf004f559831017cdf4628aaf1bb30133677be8702a8c5f2994629f637a209", image.PullOptions{}) assert.NilError(t, err) _, err = io.Copy(io.Discard, r) assert.NilError(t, err) diff --git a/testutil/environment/clean.go b/testutil/environment/clean.go index 40642143fb..7c137245e5 100644 --- a/testutil/environment/clean.go +++ b/testutil/environment/clean.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/volume" "github.com/docker/docker/client" @@ -97,7 +98,7 @@ func getAllContainers(ctx context.Context, t testing.TB, client client.Container func deleteAllImages(ctx context.Context, t testing.TB, apiclient client.ImageAPIClient, protectedImages map[string]struct{}) { t.Helper() - images, err := apiclient.ImageList(ctx, types.ImageListOptions{}) + images, err := apiclient.ImageList(ctx, image.ListOptions{}) assert.Check(t, err, "failed to list images") for _, img := range images { @@ -119,7 +120,7 @@ func deleteAllImages(ctx context.Context, t testing.TB, apiclient client.ImageAP func removeImage(ctx context.Context, t testing.TB, apiclient client.ImageAPIClient, ref string) { t.Helper() - _, err := apiclient.ImageRemove(ctx, ref, types.ImageRemoveOptions{ + _, err := apiclient.ImageRemove(ctx, ref, image.RemoveOptions{ Force: true, }) if errdefs.IsNotFound(err) { diff --git a/testutil/environment/environment.go b/testutil/environment/environment.go index b5b52f678f..939bbc54d4 100644 --- a/testutil/environment/environment.go +++ b/testutil/environment/environment.go @@ -10,6 +10,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/system" "github.com/docker/docker/client" "github.com/docker/docker/testutil/fixtures/load" @@ -198,7 +199,7 @@ func (e *Execution) UsingSnapshotter() bool { // Note that this is done by filtering and then checking whether there were any // results -- so ambiguous references might result in false-positives. func (e *Execution) HasExistingImage(t testing.TB, reference string) bool { - imageList, err := e.APIClient().ImageList(context.Background(), types.ImageListOptions{ + imageList, err := e.APIClient().ImageList(context.Background(), image.ListOptions{ All: true, Filters: filters.NewArgs( filters.Arg("dangling", "false"), diff --git a/testutil/environment/protect.go b/testutil/environment/protect.go index 55f95b158f..eae83c1413 100644 --- a/testutil/environment/protect.go +++ b/testutil/environment/protect.go @@ -109,7 +109,7 @@ func ProtectImages(ctx context.Context, t testing.TB, testEnv *Execution) { func getExistingImages(ctx context.Context, t testing.TB, testEnv *Execution) []string { t.Helper() client := testEnv.APIClient() - imageList, err := client.ImageList(ctx, types.ImageListOptions{ + imageList, err := client.ImageList(ctx, image.ListOptions{ All: true, Filters: filters.NewArgs(filters.Arg("dangling", "false")), }) diff --git a/testutil/fakestorage/storage.go b/testutil/fakestorage/storage.go index 0a67b9c50a..7ccd38ea27 100644 --- a/testutil/fakestorage/storage.go +++ b/testutil/fakestorage/storage.go @@ -13,6 +13,7 @@ import ( "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" "github.com/docker/docker/testutil" "github.com/docker/docker/testutil/environment" @@ -112,7 +113,7 @@ func (f *remoteFileServer) Close() error { f.ctx.Close() } if f.image != "" { - if _, err := f.client.ImageRemove(context.Background(), f.image, types.ImageRemoveOptions{ + if _, err := f.client.ImageRemove(context.Background(), f.image, image.RemoveOptions{ Force: true, }); err != nil { fmt.Fprintf(os.Stderr, "Error closing remote file server : %v\n", err) diff --git a/testutil/fixtures/load/frozen.go b/testutil/fixtures/load/frozen.go index 85cddf7527..40b7d7a619 100644 --- a/testutil/fixtures/load/frozen.go +++ b/testutil/fixtures/load/frozen.go @@ -10,7 +10,7 @@ import ( "strings" "sync" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" "github.com/docker/docker/pkg/jsonmessage" "github.com/moby/term" @@ -74,7 +74,7 @@ func FrozenImagesLinux(ctx context.Context, client client.APIClient, images ...s if err := client.ImageTag(ctx, img.srcName, img.destName); err != nil { return errors.Wrapf(err, "failed to tag %s as %s", img.srcName, img.destName) } - if _, err := client.ImageRemove(ctx, img.srcName, types.ImageRemoveOptions{}); err != nil { + if _, err := client.ImageRemove(ctx, img.srcName, image.RemoveOptions{}); err != nil { return errors.Wrapf(err, "failed to remove %s", img.srcName) } } @@ -162,7 +162,7 @@ func pullTagAndRemove(ctx context.Context, client client.APIClient, ref string, span.End() }() - resp, err := client.ImagePull(ctx, ref, types.ImagePullOptions{}) + resp, err := client.ImagePull(ctx, ref, image.PullOptions{}) if err != nil { return errors.Wrapf(err, "failed to pull %s", ref) } @@ -175,7 +175,7 @@ func pullTagAndRemove(ctx context.Context, client client.APIClient, ref string, if err := client.ImageTag(ctx, ref, tag); err != nil { return errors.Wrapf(err, "failed to tag %s as %s", ref, tag) } - _, err = client.ImageRemove(ctx, ref, types.ImageRemoveOptions{}) + _, err = client.ImageRemove(ctx, ref, image.RemoveOptions{}) return errors.Wrapf(err, "failed to remove %s", ref) }