api/types: move image options to api/types/image

To prevent a circular import between api/types and api/types image,
the RequestPrivilegeFunc reference was not moved, but defined as
part of the PullOptions / PushOptions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-07-07 13:40:24 +02:00
parent 8906adc8d4
commit ac2a028dcc
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
41 changed files with 206 additions and 161 deletions

View file

@ -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)

View file

@ -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,

View file

@ -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

57
api/types/image/opts.go Normal file
View file

@ -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
}

View file

@ -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

View file

@ -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

View file

@ -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 {

View file

@ -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 {

View file

@ -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"},

View file

@ -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.
//

View file

@ -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) {

View file

@ -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

View file

@ -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 {

View file

@ -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

View file

@ -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 {

View file

@ -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 {

View file

@ -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,
})

View file

@ -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

View file

@ -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())

View file

@ -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,

View file

@ -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)

View file

@ -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
}

View file

@ -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())

View file

@ -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 {

View file

@ -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)

View file

@ -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 {

View file

@ -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)

View file

@ -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")
})

View file

@ -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)
})

View file

@ -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)

View file

@ -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 {

View file

@ -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")

View file

@ -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)

View file

@ -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
}

View file

@ -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,

View file

@ -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)

View file

@ -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) {

View file

@ -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"),

View file

@ -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")),
})

View file

@ -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)

View file

@ -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)
}