diff --git a/api/server/httputils/write_log_stream.go b/api/server/httputils/write_log_stream.go index 22be5bb1c3..8faacc029e 100644 --- a/api/server/httputils/write_log_stream.go +++ b/api/server/httputils/write_log_stream.go @@ -7,8 +7,8 @@ import ( "net/url" "sort" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/pkg/stdcopy" @@ -16,7 +16,7 @@ import ( // WriteLogStream writes an encoded byte stream of log messages from the // messages channel, multiplexing them with a stdcopy.Writer if mux is true -func WriteLogStream(_ context.Context, w io.Writer, msgs <-chan *backend.LogMessage, config *types.ContainerLogsOptions, mux bool) { +func WriteLogStream(_ context.Context, w io.Writer, msgs <-chan *backend.LogMessage, config *container.LogsOptions, mux bool) { wf := ioutils.NewWriteFlusher(w) defer wf.Close() diff --git a/api/server/router/container/backend.go b/api/server/router/container/backend.go index c69273680a..0819911d9e 100644 --- a/api/server/router/container/backend.go +++ b/api/server/router/container/backend.go @@ -50,10 +50,10 @@ type stateBackend interface { type monitorBackend interface { ContainerChanges(ctx context.Context, name string) ([]archive.Change, error) ContainerInspect(ctx context.Context, name string, size bool, version string) (interface{}, error) - ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error) + ContainerLogs(ctx context.Context, name string, config *container.LogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error) ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error) - Containers(ctx context.Context, config *types.ContainerListOptions) ([]*types.Container, error) + Containers(ctx context.Context, config *container.ListOptions) ([]*types.Container, error) } // attachBackend includes function to implement to provide container attaching functionality. diff --git a/api/server/router/container/container_routes.go b/api/server/router/container/container_routes.go index 87faf9e811..530d2168e5 100644 --- a/api/server/router/container/container_routes.go +++ b/api/server/router/container/container_routes.go @@ -78,7 +78,7 @@ func (s *containerRouter) getContainersJSON(ctx context.Context, w http.Response return err } - config := &types.ContainerListOptions{ + config := &container.ListOptions{ All: httputils.BoolValue(r, "all"), Size: httputils.BoolValue(r, "size"), Since: r.Form.Get("since"), @@ -142,7 +142,7 @@ func (s *containerRouter) getContainersLogs(ctx context.Context, w http.Response } containerName := vars["name"] - logsConfig := &types.ContainerLogsOptions{ + logsConfig := &container.LogsOptions{ Follow: httputils.BoolValue(r, "follow"), Timestamps: httputils.BoolValue(r, "timestamps"), Since: r.Form.Get("since"), diff --git a/api/server/router/image/backend.go b/api/server/router/image/backend.go index d599538dca..57d16f0bf6 100644 --- a/api/server/router/image/backend.go +++ b/api/server/router/image/backend.go @@ -22,9 +22,9 @@ type Backend interface { } type imageBackend interface { - ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error) + 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) ([]*types.ImageSummary, error) + Images(ctx context.Context, opts types.ImageListOptions) ([]*image.Summary, error) GetImage(ctx context.Context, refOrID string, options image.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 5d37565c1d..a8eb4a40ca 100644 --- a/api/server/router/image/image_routes.go +++ b/api/server/router/image/image_routes.go @@ -353,7 +353,7 @@ func (ir *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, er Data: img.Details.Metadata, }, RootFS: rootFSToAPIType(img.RootFS), - Metadata: types.ImageMetadata{ + Metadata: opts.Metadata{ LastTagTime: img.Details.LastUpdated, }, }, nil diff --git a/api/server/router/swarm/backend.go b/api/server/router/swarm/backend.go index b2a14b06b9..a340f5b0be 100644 --- a/api/server/router/swarm/backend.go +++ b/api/server/router/swarm/backend.go @@ -3,40 +3,41 @@ package swarm // import "github.com/docker/docker/api/server/router/swarm" import ( "context" - basictypes "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" - types "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/swarm" ) // Backend abstracts a swarm manager. type Backend interface { - Init(req types.InitRequest) (string, error) - Join(req types.JoinRequest) error + Init(req swarm.InitRequest) (string, error) + Join(req swarm.JoinRequest) error Leave(ctx context.Context, force bool) error - Inspect() (types.Swarm, error) - Update(uint64, types.Spec, types.UpdateFlags) error + Inspect() (swarm.Swarm, error) + Update(uint64, swarm.Spec, swarm.UpdateFlags) error GetUnlockKey() (string, error) - UnlockSwarm(req types.UnlockRequest) error - GetServices(basictypes.ServiceListOptions) ([]types.Service, error) - GetService(idOrName string, insertDefaults bool) (types.Service, error) - CreateService(types.ServiceSpec, string, bool) (*basictypes.ServiceCreateResponse, error) - UpdateService(string, uint64, types.ServiceSpec, basictypes.ServiceUpdateOptions, bool) (*basictypes.ServiceUpdateResponse, error) + UnlockSwarm(req swarm.UnlockRequest) error + GetServices(types.ServiceListOptions) ([]swarm.Service, error) + GetService(idOrName string, insertDefaults bool) (swarm.Service, error) + CreateService(swarm.ServiceSpec, string, bool) (*swarm.ServiceCreateResponse, error) + UpdateService(string, uint64, swarm.ServiceSpec, types.ServiceUpdateOptions, bool) (*swarm.ServiceUpdateResponse, error) RemoveService(string) error - ServiceLogs(context.Context, *backend.LogSelector, *basictypes.ContainerLogsOptions) (<-chan *backend.LogMessage, error) - GetNodes(basictypes.NodeListOptions) ([]types.Node, error) - GetNode(string) (types.Node, error) - UpdateNode(string, uint64, types.NodeSpec) error + ServiceLogs(context.Context, *backend.LogSelector, *container.LogsOptions) (<-chan *backend.LogMessage, error) + GetNodes(types.NodeListOptions) ([]swarm.Node, error) + GetNode(string) (swarm.Node, error) + UpdateNode(string, uint64, swarm.NodeSpec) error RemoveNode(string, bool) error - GetTasks(basictypes.TaskListOptions) ([]types.Task, error) - GetTask(string) (types.Task, error) - GetSecrets(opts basictypes.SecretListOptions) ([]types.Secret, error) - CreateSecret(s types.SecretSpec) (string, error) + GetTasks(types.TaskListOptions) ([]swarm.Task, error) + GetTask(string) (swarm.Task, error) + GetSecrets(opts types.SecretListOptions) ([]swarm.Secret, error) + CreateSecret(s swarm.SecretSpec) (string, error) RemoveSecret(idOrName string) error - GetSecret(id string) (types.Secret, error) - UpdateSecret(idOrName string, version uint64, spec types.SecretSpec) error - GetConfigs(opts basictypes.ConfigListOptions) ([]types.Config, error) - CreateConfig(s types.ConfigSpec) (string, error) + GetSecret(id string) (swarm.Secret, error) + UpdateSecret(idOrName string, version uint64, spec swarm.SecretSpec) error + GetConfigs(opts types.ConfigListOptions) ([]swarm.Config, error) + CreateConfig(s swarm.ConfigSpec) (string, error) RemoveConfig(id string) error - GetConfig(id string) (types.Config, error) - UpdateConfig(idOrName string, version uint64, spec types.ConfigSpec) error + GetConfig(id string) (swarm.Config, error) + UpdateConfig(idOrName string, version uint64, spec swarm.ConfigSpec) error } diff --git a/api/server/router/swarm/helpers.go b/api/server/router/swarm/helpers.go index 16de015cda..816ba7c9fa 100644 --- a/api/server/router/swarm/helpers.go +++ b/api/server/router/swarm/helpers.go @@ -8,6 +8,7 @@ import ( "github.com/docker/docker/api/server/httputils" basictypes "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/versions" ) @@ -25,9 +26,9 @@ func (sr *swarmRouter) swarmLogs(ctx context.Context, w http.ResponseWriter, r * return fmt.Errorf("Bad parameters: you must choose at least one stream") } - // there is probably a neater way to manufacture the ContainerLogsOptions + // there is probably a neater way to manufacture the LogsOptions // struct, probably in the caller, to eliminate the dependency on net/http - logsConfig := &basictypes.ContainerLogsOptions{ + logsConfig := &container.LogsOptions{ Follow: httputils.BoolValue(r, "follow"), Timestamps: httputils.BoolValue(r, "timestamps"), Since: r.Form.Get("since"), diff --git a/api/swagger.yaml b/api/swagger.yaml index 943c53811a..3c3d83fb9a 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -1840,6 +1840,7 @@ definitions: x-nullable: true ImageSummary: type: "object" + x-go-name: "Summary" required: - Id - ParentId @@ -4477,6 +4478,7 @@ definitions: ImageDeleteResponseItem: type: "object" + x-go-name: "DeleteResponse" properties: Untagged: description: "The image ID of an image that was untagged" @@ -4485,6 +4487,29 @@ definitions: description: "The image ID of an image that was deleted" type: "string" + ServiceCreateResponse: + type: "object" + description: | + contains the information returned to a client on the + creation of a new service. + properties: + ID: + description: "The ID of the created service." + type: "string" + x-nullable: false + example: "ak7w3gjqoa3kuz8xcpnyy0pvl" + Warnings: + description: | + Optional warning message. + + FIXME(thaJeztah): this should have "omitempty" in the generated type. + type: "array" + x-nullable: true + items: + type: "string" + example: + - "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found" + ServiceUpdateResponse: type: "object" properties: @@ -4494,7 +4519,8 @@ definitions: items: type: "string" example: - Warning: "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found" + Warnings: + - "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found" ContainerSummary: type: "object" @@ -11097,18 +11123,7 @@ paths: 201: description: "no error" schema: - type: "object" - title: "ServiceCreateResponse" - properties: - ID: - description: "The ID of the created service." - type: "string" - Warning: - description: "Optional warning message" - type: "string" - example: - ID: "ak7w3gjqoa3kuz8xcpnyy0pvl" - Warning: "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found" + $ref: "#/definitions/ServiceCreateResponse" 400: description: "bad parameter" schema: diff --git a/api/types/client.go b/api/types/client.go index 80691034e8..24b00a2759 100644 --- a/api/types/client.go +++ b/api/types/client.go @@ -11,26 +11,6 @@ import ( units "github.com/docker/go-units" ) -// ContainerAttachOptions holds parameters to attach to a container. -type ContainerAttachOptions struct { - Stream bool - Stdin bool - Stdout bool - Stderr bool - DetachKeys string - Logs bool -} - -// ContainerCommitOptions holds parameters to commit changes into a container. -type ContainerCommitOptions struct { - Reference string - Comment string - Author string - Changes []string - Pause bool - Config *container.Config -} - // ContainerExecInspect holds information returned by exec inspect. type ContainerExecInspect struct { ExecID string `json:"ID"` @@ -40,42 +20,6 @@ type ContainerExecInspect struct { Pid int } -// ContainerListOptions holds parameters to list containers with. -type ContainerListOptions struct { - Size bool - All bool - Latest bool - Since string - Before string - Limit int - Filters filters.Args -} - -// ContainerLogsOptions holds parameters to filter logs with. -type ContainerLogsOptions struct { - ShowStdout bool - ShowStderr bool - Since string - Until string - Timestamps bool - Follow bool - Tail string - Details bool -} - -// ContainerRemoveOptions holds parameters to remove containers. -type ContainerRemoveOptions struct { - RemoveVolumes bool - RemoveLinks bool - Force bool -} - -// ContainerStartOptions holds parameters to start containers. -type ContainerStartOptions struct { - CheckpointID string - CheckpointDir string -} - // CopyToContainerOptions holds information // about files to copy into a container type CopyToContainerOptions struct { @@ -289,14 +233,6 @@ type ImageSearchOptions struct { Limit int } -// ResizeOptions holds parameters to resize a tty. -// It can be used to resize container ttys and -// exec process ttys too. -type ResizeOptions struct { - Height uint - Width uint -} - // NodeListOptions holds parameters to list nodes with. type NodeListOptions struct { Filters filters.Args @@ -322,15 +258,6 @@ type ServiceCreateOptions struct { QueryRegistry bool } -// ServiceCreateResponse contains the information returned to a client -// on the creation of a new service. -type ServiceCreateResponse struct { - // ID is the ID of the created service. - ID string - // Warnings is a set of non-fatal warning messages to pass on to the user. - Warnings []string `json:",omitempty"` -} - // Values for RegistryAuthFrom in ServiceUpdateOptions const ( RegistryAuthFromSpec = "spec" diff --git a/api/types/container/options.go b/api/types/container/options.go new file mode 100644 index 0000000000..7a23005769 --- /dev/null +++ b/api/types/container/options.go @@ -0,0 +1,67 @@ +package container + +import "github.com/docker/docker/api/types/filters" + +// ResizeOptions holds parameters to resize a TTY. +// It can be used to resize container TTYs and +// exec process TTYs too. +type ResizeOptions struct { + Height uint + Width uint +} + +// AttachOptions holds parameters to attach to a container. +type AttachOptions struct { + Stream bool + Stdin bool + Stdout bool + Stderr bool + DetachKeys string + Logs bool +} + +// CommitOptions holds parameters to commit changes into a container. +type CommitOptions struct { + Reference string + Comment string + Author string + Changes []string + Pause bool + Config *Config +} + +// RemoveOptions holds parameters to remove containers. +type RemoveOptions struct { + RemoveVolumes bool + RemoveLinks bool + Force bool +} + +// StartOptions holds parameters to start containers. +type StartOptions struct { + CheckpointID string + CheckpointDir string +} + +// ListOptions holds parameters to list containers with. +type ListOptions struct { + Size bool + All bool + Latest bool + Since string + Before string + Limit int + Filters filters.Args +} + +// LogsOptions holds parameters to filter logs with. +type LogsOptions struct { + ShowStdout bool + ShowStderr bool + Since string + Until string + Timestamps bool + Follow bool + Tail string + Details bool +} diff --git a/api/types/image_delete_response_item.go b/api/types/image/delete_response.go similarity index 68% rename from api/types/image_delete_response_item.go rename to api/types/image/delete_response.go index b9a65a0d8e..998620dc6a 100644 --- a/api/types/image_delete_response_item.go +++ b/api/types/image/delete_response.go @@ -1,11 +1,11 @@ -package types +package image // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command -// ImageDeleteResponseItem image delete response item -// swagger:model ImageDeleteResponseItem -type ImageDeleteResponseItem struct { +// DeleteResponse delete response +// swagger:model DeleteResponse +type DeleteResponse struct { // The image ID of an image that was deleted Deleted string `json:"Deleted,omitempty"` diff --git a/api/types/image/image.go b/api/types/image/image.go new file mode 100644 index 0000000000..167df28c7b --- /dev/null +++ b/api/types/image/image.go @@ -0,0 +1,9 @@ +package image + +import "time" + +// Metadata contains engine-local data about the image. +type Metadata struct { + // LastTagTime is the date and time at which the image was last tagged. + LastTagTime time.Time `json:",omitempty"` +} diff --git a/api/types/image_summary.go b/api/types/image/summary.go similarity index 96% rename from api/types/image_summary.go rename to api/types/image/summary.go index 076848ad5f..f1e3e2ef01 100644 --- a/api/types/image_summary.go +++ b/api/types/image/summary.go @@ -1,11 +1,11 @@ -package types +package image // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command -// ImageSummary image summary -// swagger:model ImageSummary -type ImageSummary struct { +// Summary summary +// swagger:model Summary +type Summary struct { // Number of containers using this image. Includes both stopped and running // containers. diff --git a/api/types/swarm/service_create_response.go b/api/types/swarm/service_create_response.go new file mode 100644 index 0000000000..9a268ff1b9 --- /dev/null +++ b/api/types/swarm/service_create_response.go @@ -0,0 +1,20 @@ +package swarm + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// ServiceCreateResponse contains the information returned to a client on the +// creation of a new service. +// +// swagger:model ServiceCreateResponse +type ServiceCreateResponse struct { + + // The ID of the created service. + ID string `json:"ID,omitempty"` + + // Optional warning message. + // + // FIXME(thaJeztah): this should have "omitempty" in the generated type. + // + Warnings []string `json:"Warnings"` +} diff --git a/api/types/service_update_response.go b/api/types/swarm/service_update_response.go similarity index 95% rename from api/types/service_update_response.go rename to api/types/swarm/service_update_response.go index 74ea64b1bb..0417467dae 100644 --- a/api/types/service_update_response.go +++ b/api/types/swarm/service_update_response.go @@ -1,4 +1,4 @@ -package types +package swarm // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command diff --git a/api/types/types.go b/api/types/types.go index 84a85df786..a28224c191 100644 --- a/api/types/types.go +++ b/api/types/types.go @@ -7,6 +7,7 @@ import ( "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/mount" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/swarm" @@ -128,13 +129,7 @@ type ImageInspect struct { // Metadata of the image in the local cache. // // This information is local to the daemon, and not part of the image itself. - Metadata ImageMetadata -} - -// ImageMetadata contains engine-local data about the image -type ImageMetadata struct { - // LastTagTime is the date and time at which the image was last tagged. - LastTagTime time.Time `json:",omitempty"` + Metadata image.Metadata } // Container contains response of Engine API: @@ -514,7 +509,7 @@ type DiskUsageOptions struct { // GET "/system/df" type DiskUsage struct { LayersSize int64 - Images []*ImageSummary + Images []*image.Summary Containers []*Container Volumes []*volume.Volume BuildCache []*BuildCache @@ -538,7 +533,7 @@ type VolumesPruneReport struct { // ImagesPruneReport contains the response for Engine API: // POST "/images/prune" type ImagesPruneReport struct { - ImagesDeleted []ImageDeleteResponseItem + ImagesDeleted []image.DeleteResponse SpaceReclaimed uint64 } diff --git a/api/types/types_deprecated.go b/api/types/types_deprecated.go index 3d0174b756..e332a7bb6d 100644 --- a/api/types/types_deprecated.go +++ b/api/types/types_deprecated.go @@ -2,6 +2,9 @@ package types import ( "github.com/docker/docker/api/types/checkpoint" + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" + "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/system" ) @@ -63,6 +66,69 @@ type SecurityOpt = system.SecurityOpt // Deprecated: use [system.KeyValue]. type KeyValue = system.KeyValue +// ImageDeleteResponseItem image delete response item. +// +// Deprecated: use [image.DeleteResponse]. +type ImageDeleteResponseItem = image.DeleteResponse + +// ImageSummary image summary. +// +// Deprecated: use [image.Summary]. +type ImageSummary = image.Summary + +// ImageMetadata contains engine-local data about the image. +// +// Deprecated: use [image.Metadata]. +type ImageMetadata = image.Metadata + +// ServiceCreateResponse contains the information returned to a client +// on the creation of a new service. +// +// Deprecated: use [swarm.ServiceCreateResponse]. +type ServiceCreateResponse = swarm.ServiceCreateResponse + +// ServiceUpdateResponse service update response. +// +// Deprecated: use [swarm.ServiceUpdateResponse]. +type ServiceUpdateResponse = swarm.ServiceUpdateResponse + +// ContainerStartOptions holds parameters to start containers. +// +// Deprecated: use [container.StartOptions]. +type ContainerStartOptions = container.StartOptions + +// ResizeOptions holds parameters to resize a TTY. +// It can be used to resize container TTYs and +// exec process TTYs too. +// +// Deprecated: use [container.ResizeOptions]. +type ResizeOptions = container.ResizeOptions + +// ContainerAttachOptions holds parameters to attach to a container. +// +// Deprecated: use [container.AttachOptions]. +type ContainerAttachOptions = container.AttachOptions + +// ContainerCommitOptions holds parameters to commit changes into a container. +// +// Deprecated: use [container.CommitOptions]. +type ContainerCommitOptions = container.CommitOptions + +// ContainerListOptions holds parameters to list containers with. +// +// Deprecated: use [container.ListOptions]. +type ContainerListOptions = container.ListOptions + +// ContainerLogsOptions holds parameters to filter logs with. +// +// Deprecated: use [container.LogsOptions]. +type ContainerLogsOptions = container.LogsOptions + +// ContainerRemoveOptions holds parameters to remove containers. +// +// Deprecated: use [container.RemoveOptions]. +type ContainerRemoveOptions = container.RemoveOptions + // DecodeSecurityOptions decodes a security options string slice to a type safe // [system.SecurityOpt]. // diff --git a/client/client.go b/client/client.go index 7eab41185d..6fb3f3eb04 100644 --- a/client/client.go +++ b/client/client.go @@ -19,7 +19,7 @@ For example, to list running containers (the equivalent of "docker ps"): "context" "fmt" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" ) @@ -29,13 +29,13 @@ For example, to list running containers (the equivalent of "docker ps"): panic(err) } - containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{}) + containers, err := cli.ContainerList(context.Background(), container.ListOptions{}) if err != nil { panic(err) } - for _, container := range containers { - fmt.Printf("%s %s\n", container.ID[:10], container.Image) + for _, ctr := range containers { + fmt.Printf("%s %s\n", ctr.ID, ctr.Image) } } */ diff --git a/client/container_attach.go b/client/container_attach.go index a3a009050d..6a32e5f664 100644 --- a/client/container_attach.go +++ b/client/container_attach.go @@ -6,6 +6,7 @@ import ( "net/url" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" ) // ContainerAttach attaches a connection to a container in the server. @@ -32,7 +33,7 @@ import ( // // You can use github.com/docker/docker/pkg/stdcopy.StdCopy to demultiplex this // stream. -func (cli *Client) ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) { +func (cli *Client) ContainerAttach(ctx context.Context, container string, options container.AttachOptions) (types.HijackedResponse, error) { query := url.Values{} if options.Stream { query.Set("stream", "1") diff --git a/client/container_commit.go b/client/container_commit.go index d3e597bd7c..26b3f09158 100644 --- a/client/container_commit.go +++ b/client/container_commit.go @@ -8,10 +8,11 @@ import ( "github.com/distribution/reference" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" ) // ContainerCommit applies changes to a container and creates a new tagged image. -func (cli *Client) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error) { +func (cli *Client) ContainerCommit(ctx context.Context, container string, options container.CommitOptions) (types.IDResponse, error) { var repository, tag string if options.Reference != "" { ref, err := reference.ParseNormalizedNamed(options.Reference) diff --git a/client/container_commit_test.go b/client/container_commit_test.go index da3f542079..44980b1f76 100644 --- a/client/container_commit_test.go +++ b/client/container_commit_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -20,7 +21,7 @@ func TestContainerCommitError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.ContainerCommit(context.Background(), "nothing", types.ContainerCommitOptions{}) + _, err := client.ContainerCommit(context.Background(), "nothing", container.CommitOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } @@ -81,7 +82,7 @@ func TestContainerCommit(t *testing.T) { }), } - r, err := client.ContainerCommit(context.Background(), expectedContainerID, types.ContainerCommitOptions{ + r, err := client.ContainerCommit(context.Background(), expectedContainerID, container.CommitOptions{ Reference: specifiedReference, Comment: expectedComment, Author: expectedAuthor, diff --git a/client/container_list.go b/client/container_list.go index 127a57cfd8..782e1b3c62 100644 --- a/client/container_list.go +++ b/client/container_list.go @@ -7,11 +7,12 @@ import ( "strconv" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" ) // ContainerList returns the list of containers in the docker host. -func (cli *Client) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) { +func (cli *Client) ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error) { query := url.Values{} if options.All { diff --git a/client/container_list_test.go b/client/container_list_test.go index 920231edba..dbe4647af1 100644 --- a/client/container_list_test.go +++ b/client/container_list_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" @@ -21,7 +22,7 @@ func TestContainerListError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.ContainerList(context.Background(), types.ContainerListOptions{}) + _, err := client.ContainerList(context.Background(), container.ListOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } @@ -78,7 +79,7 @@ func TestContainerList(t *testing.T) { }), } - containers, err := client.ContainerList(context.Background(), types.ContainerListOptions{ + containers, err := client.ContainerList(context.Background(), container.ListOptions{ Size: true, All: true, Since: "container", diff --git a/client/container_logs.go b/client/container_logs.go index 9bdf2b0fa6..61197d8407 100644 --- a/client/container_logs.go +++ b/client/container_logs.go @@ -6,7 +6,7 @@ import ( "net/url" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" timetypes "github.com/docker/docker/api/types/time" "github.com/pkg/errors" ) @@ -33,7 +33,7 @@ import ( // // You can use github.com/docker/docker/pkg/stdcopy.StdCopy to demultiplex this // stream. -func (cli *Client) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) { +func (cli *Client) ContainerLogs(ctx context.Context, container string, options container.LogsOptions) (io.ReadCloser, error) { query := url.Values{} if options.ShowStdout { query.Set("stdout", "1") diff --git a/client/container_logs_test.go b/client/container_logs_test.go index ce7a1bee55..4e04da253b 100644 --- a/client/container_logs_test.go +++ b/client/container_logs_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -22,7 +22,7 @@ func TestContainerLogsNotFoundError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusNotFound, "Not found")), } - _, err := client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{}) + _, err := client.ContainerLogs(context.Background(), "container_id", container.LogsOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsNotFound)) } @@ -30,14 +30,14 @@ func TestContainerLogsError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{}) + _, err := client.ContainerLogs(context.Background(), "container_id", container.LogsOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) - _, err = client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{ + _, err = client.ContainerLogs(context.Background(), "container_id", container.LogsOptions{ Since: "2006-01-02TZ", }) assert.Check(t, is.ErrorContains(err, `parsing time "2006-01-02TZ"`)) - _, err = client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{ + _, err = client.ContainerLogs(context.Background(), "container_id", container.LogsOptions{ Until: "2006-01-02TZ", }) assert.Check(t, is.ErrorContains(err, `parsing time "2006-01-02TZ"`)) @@ -46,7 +46,7 @@ func TestContainerLogsError(t *testing.T) { func TestContainerLogs(t *testing.T) { expectedURL := "/containers/container_id/logs" cases := []struct { - options types.ContainerLogsOptions + options container.LogsOptions expectedQueryParams map[string]string expectedError string }{ @@ -56,7 +56,7 @@ func TestContainerLogs(t *testing.T) { }, }, { - options: types.ContainerLogsOptions{ + options: container.LogsOptions{ Tail: "any", }, expectedQueryParams: map[string]string{ @@ -64,7 +64,7 @@ func TestContainerLogs(t *testing.T) { }, }, { - options: types.ContainerLogsOptions{ + options: container.LogsOptions{ ShowStdout: true, ShowStderr: true, Timestamps: true, @@ -81,7 +81,7 @@ func TestContainerLogs(t *testing.T) { }, }, { - options: types.ContainerLogsOptions{ + options: container.LogsOptions{ // timestamp will be passed as is Since: "1136073600.000000001", }, @@ -91,7 +91,7 @@ func TestContainerLogs(t *testing.T) { }, }, { - options: types.ContainerLogsOptions{ + options: container.LogsOptions{ // timestamp will be passed as is Until: "1136073600.000000001", }, @@ -101,14 +101,14 @@ func TestContainerLogs(t *testing.T) { }, }, { - options: types.ContainerLogsOptions{ + options: container.LogsOptions{ // An complete invalid date will not be passed Since: "invalid value", }, expectedError: `invalid value for "since": failed to parse value as time or duration: "invalid value"`, }, { - options: types.ContainerLogsOptions{ + options: container.LogsOptions{ // An complete invalid date will not be passed Until: "invalid value", }, @@ -153,7 +153,7 @@ func ExampleClient_ContainerLogs_withTimeout() { defer cancel() client, _ := NewClientWithOpts(FromEnv) - reader, err := client.ContainerLogs(ctx, "container_id", types.ContainerLogsOptions{}) + reader, err := client.ContainerLogs(ctx, "container_id", container.LogsOptions{}) if err != nil { log.Fatal(err) } diff --git a/client/container_remove.go b/client/container_remove.go index c21de609b0..39f7b106a1 100644 --- a/client/container_remove.go +++ b/client/container_remove.go @@ -4,11 +4,11 @@ import ( "context" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" ) // ContainerRemove kills and removes a container from the docker host. -func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error { +func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error { query := url.Values{} if options.RemoveVolumes { query.Set("v", "1") diff --git a/client/container_remove_test.go b/client/container_remove_test.go index 333ad16d0d..eecbd71268 100644 --- a/client/container_remove_test.go +++ b/client/container_remove_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -19,7 +19,7 @@ func TestContainerRemoveError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - err := client.ContainerRemove(context.Background(), "container_id", types.ContainerRemoveOptions{}) + err := client.ContainerRemove(context.Background(), "container_id", container.RemoveOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } @@ -27,7 +27,7 @@ func TestContainerRemoveNotFoundError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusNotFound, "no such container: container_id")), } - err := client.ContainerRemove(context.Background(), "container_id", types.ContainerRemoveOptions{}) + err := client.ContainerRemove(context.Background(), "container_id", container.RemoveOptions{}) assert.Check(t, is.ErrorContains(err, "no such container: container_id")) assert.Check(t, is.ErrorType(err, errdefs.IsNotFound)) } @@ -59,7 +59,7 @@ func TestContainerRemove(t *testing.T) { }), } - err := client.ContainerRemove(context.Background(), "container_id", types.ContainerRemoveOptions{ + err := client.ContainerRemove(context.Background(), "container_id", container.RemoveOptions{ RemoveVolumes: true, Force: true, }) diff --git a/client/container_resize.go b/client/container_resize.go index a9d4c0c79a..5cfd01d479 100644 --- a/client/container_resize.go +++ b/client/container_resize.go @@ -5,16 +5,16 @@ import ( "net/url" "strconv" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" ) // ContainerResize changes the size of the tty for a container. -func (cli *Client) ContainerResize(ctx context.Context, containerID string, options types.ResizeOptions) error { +func (cli *Client) ContainerResize(ctx context.Context, containerID string, options container.ResizeOptions) error { return cli.resize(ctx, "/containers/"+containerID, options.Height, options.Width) } // ContainerExecResize changes the size of the tty for an exec process running inside a container. -func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error { +func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error { return cli.resize(ctx, "/exec/"+execID, options.Height, options.Width) } diff --git a/client/container_resize_test.go b/client/container_resize_test.go index b6b69b1541..76559ef928 100644 --- a/client/container_resize_test.go +++ b/client/container_resize_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -19,7 +19,7 @@ func TestContainerResizeError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - err := client.ContainerResize(context.Background(), "container_id", types.ResizeOptions{}) + err := client.ContainerResize(context.Background(), "container_id", container.ResizeOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } @@ -27,7 +27,7 @@ func TestContainerExecResizeError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - err := client.ContainerExecResize(context.Background(), "exec_id", types.ResizeOptions{}) + err := client.ContainerExecResize(context.Background(), "exec_id", container.ResizeOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } @@ -36,7 +36,7 @@ func TestContainerResize(t *testing.T) { client: newMockClient(resizeTransport("/containers/container_id/resize")), } - err := client.ContainerResize(context.Background(), "container_id", types.ResizeOptions{ + err := client.ContainerResize(context.Background(), "container_id", container.ResizeOptions{ Height: 500, Width: 600, }) @@ -50,7 +50,7 @@ func TestContainerExecResize(t *testing.T) { client: newMockClient(resizeTransport("/exec/exec_id/resize")), } - err := client.ContainerExecResize(context.Background(), "exec_id", types.ResizeOptions{ + err := client.ContainerExecResize(context.Background(), "exec_id", container.ResizeOptions{ Height: 500, Width: 600, }) diff --git a/client/container_start.go b/client/container_start.go index c2e0b15dca..33ba85f248 100644 --- a/client/container_start.go +++ b/client/container_start.go @@ -4,11 +4,11 @@ import ( "context" "net/url" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" ) // ContainerStart sends a request to the docker daemon to start a container. -func (cli *Client) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error { +func (cli *Client) ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error { query := url.Values{} if len(options.CheckpointID) != 0 { query.Set("checkpoint", options.CheckpointID) diff --git a/client/container_start_test.go b/client/container_start_test.go index 18b100ae11..d4d0fd16bc 100644 --- a/client/container_start_test.go +++ b/client/container_start_test.go @@ -10,7 +10,7 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -20,7 +20,7 @@ func TestContainerStartError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - err := client.ContainerStart(context.Background(), "nothing", types.ContainerStartOptions{}) + err := client.ContainerStart(context.Background(), "nothing", container.StartOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } @@ -51,7 +51,7 @@ func TestContainerStart(t *testing.T) { }), } - err := client.ContainerStart(context.Background(), "container_id", types.ContainerStartOptions{CheckpointID: "checkpoint_id"}) + err := client.ContainerStart(context.Background(), "container_id", container.StartOptions{CheckpointID: "checkpoint_id"}) if err != nil { t.Fatal(err) } diff --git a/client/image_list.go b/client/image_list.go index 986b961a45..f3f2280e32 100644 --- a/client/image_list.go +++ b/client/image_list.go @@ -7,11 +7,12 @@ 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/versions" ) // ImageList returns a list of images in the docker host. -func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) { +func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]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. // @@ -19,7 +20,7 @@ func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions // the API request is made. cli.checkVersion(ctx) - var images []types.ImageSummary + var images []image.Summary query := url.Values{} optionFilters := options.Filters diff --git a/client/image_list_test.go b/client/image_list_test.go index c571d5bd98..bcd6db7d98 100644 --- a/client/image_list_test.go +++ b/client/image_list_test.go @@ -13,6 +13,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/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -80,7 +81,7 @@ func TestImageList(t *testing.T) { return nil, fmt.Errorf("%s not set in URL query properly. Expected '%s', got %s", key, expected, actual) } } - content, err := json.Marshal([]types.ImageSummary{ + content, err := json.Marshal([]image.Summary{ { ID: "image_id2", }, @@ -121,7 +122,7 @@ func TestImageListApiBefore125(t *testing.T) { if actualFilters != "" { return nil, fmt.Errorf("filters should have not been present, were with value: %s", actualFilters) } - content, err := json.Marshal([]types.ImageSummary{ + content, err := json.Marshal([]image.Summary{ { ID: "image_id2", }, diff --git a/client/image_prune_test.go b/client/image_prune_test.go index f8428efb16..5abe9ea317 100644 --- a/client/image_prune_test.go +++ b/client/image_prune_test.go @@ -10,6 +10,7 @@ import ( "strings" "testing" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/errdefs" "github.com/docker/docker/api/types" @@ -84,7 +85,7 @@ func TestImagesPrune(t *testing.T) { assert.Check(t, is.Equal(expected, actual)) } content, err := json.Marshal(types.ImagesPruneReport{ - ImagesDeleted: []types.ImageDeleteResponseItem{ + ImagesDeleted: []image.DeleteResponse{ { Deleted: "image_id1", }, diff --git a/client/image_remove.go b/client/image_remove.go index 6a9fb3f41f..b936d20830 100644 --- a/client/image_remove.go +++ b/client/image_remove.go @@ -6,10 +6,11 @@ import ( "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) ([]types.ImageDeleteResponseItem, error) { +func (cli *Client) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error) { query := url.Values{} if options.Force { @@ -19,7 +20,7 @@ func (cli *Client) ImageRemove(ctx context.Context, imageID string, options type query.Set("noprune", "1") } - var dels []types.ImageDeleteResponseItem + var dels []image.DeleteResponse resp, err := cli.delete(ctx, "/images/"+imageID, query, nil) defer ensureReaderClosed(resp) if err != nil { diff --git a/client/image_remove_test.go b/client/image_remove_test.go index 24638afc42..9614f8572c 100644 --- a/client/image_remove_test.go +++ b/client/image_remove_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" @@ -74,7 +75,7 @@ func TestImageRemove(t *testing.T) { return nil, fmt.Errorf("%s not set in URL query properly. Expected '%s', got %s", key, expected, actual) } } - b, err := json.Marshal([]types.ImageDeleteResponseItem{ + b, err := json.Marshal([]image.DeleteResponse{ { Untagged: "image_id1", }, diff --git a/client/interface.go b/client/interface.go index b2e5d36486..302f5fb13e 100644 --- a/client/interface.go +++ b/client/interface.go @@ -46,30 +46,30 @@ type CommonAPIClient interface { // ContainerAPIClient defines API client methods for the containers type ContainerAPIClient interface { - ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) - ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error) + ContainerAttach(ctx context.Context, container string, options container.AttachOptions) (types.HijackedResponse, error) + ContainerCommit(ctx context.Context, container string, options container.CommitOptions) (types.IDResponse, error) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error) ContainerDiff(ctx context.Context, container string) ([]container.FilesystemChange, error) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) - ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error + ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error ContainerExport(ctx context.Context, container string) (io.ReadCloser, error) ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error) ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (types.ContainerJSON, []byte, error) ContainerKill(ctx context.Context, container, signal string) error - ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) - ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) + ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error) + ContainerLogs(ctx context.Context, container string, options container.LogsOptions) (io.ReadCloser, error) ContainerPause(ctx context.Context, container string) error - ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error + ContainerRemove(ctx context.Context, container string, options container.RemoveOptions) error ContainerRename(ctx context.Context, container, newContainerName string) error - ContainerResize(ctx context.Context, container string, options types.ResizeOptions) error + ContainerResize(ctx context.Context, container string, options container.ResizeOptions) error ContainerRestart(ctx context.Context, container string, options container.StopOptions) error ContainerStatPath(ctx context.Context, container, path string) (types.ContainerPathStat, error) ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error) ContainerStatsOneShot(ctx context.Context, container string) (types.ContainerStats, error) - ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error + ContainerStart(ctx context.Context, container string, options container.StartOptions) error ContainerStop(ctx context.Context, container string, options container.StopOptions) error ContainerTop(ctx context.Context, container string, arguments []string) (container.ContainerTopOKBody, error) ContainerUnpause(ctx context.Context, container string) error @@ -94,11 +94,11 @@ type ImageAPIClient interface { ImageHistory(ctx context.Context, image string) ([]image.HistoryResponseItem, error) ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error) - ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) + ImageList(ctx context.Context, options types.ImageListOptions) ([]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) ([]types.ImageDeleteResponseItem, error) + ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]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 @@ -141,13 +141,13 @@ type PluginAPIClient interface { // ServiceAPIClient defines API client methods for the services type ServiceAPIClient interface { - ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error) + ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) ServiceRemove(ctx context.Context, serviceID string) error - ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) - ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error) - TaskLogs(ctx context.Context, taskID string, options types.ContainerLogsOptions) (io.ReadCloser, error) + ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) + ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error) + TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (io.ReadCloser, error) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) } diff --git a/client/request_test.go b/client/request_test.go index 6bc47fef39..127c567b5f 100644 --- a/client/request_test.go +++ b/client/request_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -90,7 +90,7 @@ func TestPlainTextError(t *testing.T) { client := &Client{ client: newMockClient(plainTextErrorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.ContainerList(context.Background(), types.ContainerListOptions{}) + _, err := client.ContainerList(context.Background(), container.ListOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) } diff --git a/client/service_create.go b/client/service_create.go index 7f54e83487..2ebb5ee3a5 100644 --- a/client/service_create.go +++ b/client/service_create.go @@ -17,8 +17,8 @@ import ( ) // ServiceCreate creates a new service. -func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error) { - var response types.ServiceCreateResponse +func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) { + var response swarm.ServiceCreateResponse // 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/service_create_test.go b/client/service_create_test.go index 752604ffde..0bbd0bc283 100644 --- a/client/service_create_test.go +++ b/client/service_create_test.go @@ -38,7 +38,7 @@ func TestServiceCreate(t *testing.T) { if req.Method != http.MethodPost { return nil, fmt.Errorf("expected POST method, got %s", req.Method) } - b, err := json.Marshal(types.ServiceCreateResponse{ + b, err := json.Marshal(swarm.ServiceCreateResponse{ ID: "service_id", }) if err != nil { @@ -77,7 +77,7 @@ func TestServiceCreateCompatiblePlatforms(t *testing.T) { assert.Check(t, is.Len(serviceSpec.TaskTemplate.Placement.Platforms, 1)) p := serviceSpec.TaskTemplate.Placement.Platforms[0] - b, err := json.Marshal(types.ServiceCreateResponse{ + b, err := json.Marshal(swarm.ServiceCreateResponse{ ID: "service_" + p.OS + "_" + p.Architecture, }) if err != nil { @@ -153,7 +153,7 @@ func TestServiceCreateDigestPinning(t *testing.T) { } serviceCreateImage = service.TaskTemplate.ContainerSpec.Image - b, err := json.Marshal(types.ServiceCreateResponse{ + b, err := json.Marshal(swarm.ServiceCreateResponse{ ID: "service_id", }) if err != nil { diff --git a/client/service_logs.go b/client/service_logs.go index 906fd4059e..e9e30a2ab4 100644 --- a/client/service_logs.go +++ b/client/service_logs.go @@ -6,14 +6,14 @@ import ( "net/url" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" timetypes "github.com/docker/docker/api/types/time" "github.com/pkg/errors" ) // ServiceLogs returns the logs generated by a service in an io.ReadCloser. // It's up to the caller to close the stream. -func (cli *Client) ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error) { +func (cli *Client) ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error) { query := url.Values{} if options.ShowStdout { query.Set("stdout", "1") diff --git a/client/service_logs_test.go b/client/service_logs_test.go index 7501e23be5..0c557685be 100644 --- a/client/service_logs_test.go +++ b/client/service_logs_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -22,10 +22,10 @@ func TestServiceLogsError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.ServiceLogs(context.Background(), "service_id", types.ContainerLogsOptions{}) + _, err := client.ServiceLogs(context.Background(), "service_id", container.LogsOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) - _, err = client.ServiceLogs(context.Background(), "service_id", types.ContainerLogsOptions{ + _, err = client.ServiceLogs(context.Background(), "service_id", container.LogsOptions{ Since: "2006-01-02TZ", }) assert.Check(t, is.ErrorContains(err, `parsing time "2006-01-02TZ"`)) @@ -34,7 +34,7 @@ func TestServiceLogsError(t *testing.T) { func TestServiceLogs(t *testing.T) { expectedURL := "/services/service_id/logs" cases := []struct { - options types.ContainerLogsOptions + options container.LogsOptions expectedQueryParams map[string]string expectedError string }{ @@ -44,7 +44,7 @@ func TestServiceLogs(t *testing.T) { }, }, { - options: types.ContainerLogsOptions{ + options: container.LogsOptions{ Tail: "any", }, expectedQueryParams: map[string]string{ @@ -52,7 +52,7 @@ func TestServiceLogs(t *testing.T) { }, }, { - options: types.ContainerLogsOptions{ + options: container.LogsOptions{ ShowStdout: true, ShowStderr: true, Timestamps: true, @@ -69,7 +69,7 @@ func TestServiceLogs(t *testing.T) { }, }, { - options: types.ContainerLogsOptions{ + options: container.LogsOptions{ // timestamp will be passed as is Since: "1136073600.000000001", }, @@ -79,7 +79,7 @@ func TestServiceLogs(t *testing.T) { }, }, { - options: types.ContainerLogsOptions{ + options: container.LogsOptions{ // An complete invalid date will not be passed Since: "invalid value", }, @@ -124,7 +124,7 @@ func ExampleClient_ServiceLogs_withTimeout() { defer cancel() client, _ := NewClientWithOpts(FromEnv) - reader, err := client.ServiceLogs(ctx, "service_id", types.ContainerLogsOptions{}) + reader, err := client.ServiceLogs(ctx, "service_id", container.LogsOptions{}) if err != nil { log.Fatal(err) } diff --git a/client/service_update.go b/client/service_update.go index f8168dd5fa..e05eebf566 100644 --- a/client/service_update.go +++ b/client/service_update.go @@ -15,7 +15,7 @@ import ( // ServiceUpdate updates a Service. The version number is required to avoid conflicting writes. // It should be the value as set *before* the update. You can find this value in the Meta field // of swarm.Service, which can be found using ServiceInspectWithRaw. -func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) { +func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) { // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // @@ -25,7 +25,7 @@ func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version var ( query = url.Values{} - response = types.ServiceUpdateResponse{} + response = swarm.ServiceUpdateResponse{} ) if options.RegistryAuthFrom != "" { diff --git a/client/task_logs.go b/client/task_logs.go index 6222fab577..b8c20e71da 100644 --- a/client/task_logs.go +++ b/client/task_logs.go @@ -6,13 +6,13 @@ import ( "net/url" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" timetypes "github.com/docker/docker/api/types/time" ) // TaskLogs returns the logs generated by a task in an io.ReadCloser. // It's up to the caller to close the stream. -func (cli *Client) TaskLogs(ctx context.Context, taskID string, options types.ContainerLogsOptions) (io.ReadCloser, error) { +func (cli *Client) TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (io.ReadCloser, error) { query := url.Values{} if options.ShowStdout { query.Set("stdout", "1") diff --git a/daemon/cluster/executor/backend.go b/daemon/cluster/executor/backend.go index 9bfdc03278..3813fc1c50 100644 --- a/daemon/cluster/executor/backend.go +++ b/daemon/cluster/executor/backend.go @@ -41,7 +41,7 @@ type Backend interface { CreateManagedContainer(ctx context.Context, config types.ContainerCreateConfig) (container.CreateResponse, error) ContainerStart(ctx context.Context, name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error ContainerStop(ctx context.Context, name string, config container.StopOptions) error - ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error) + ContainerLogs(ctx context.Context, name string, config *container.LogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error) ConnectContainerToNetwork(containerName, networkName string, endpointConfig *network.EndpointSettings) error ActivateContainerServiceBinding(containerName string) error DeactivateContainerServiceBinding(containerName string) error @@ -54,7 +54,7 @@ type Backend interface { SetContainerSecretReferences(name string, refs []*swarm.SecretReference) error SetContainerConfigReferences(name string, refs []*swarm.ConfigReference) error SystemInfo() *system.Info - Containers(ctx context.Context, config *types.ContainerListOptions) ([]*types.Container, error) + Containers(ctx context.Context, config *container.ListOptions) ([]*types.Container, error) SetNetworkBootstrapKeys([]*networktypes.EncryptionKey) error DaemonJoinsCluster(provider cluster.Provider) DaemonLeavesCluster() diff --git a/daemon/cluster/executor/container/adapter.go b/daemon/cluster/executor/container/adapter.go index e59648736a..32e1d3dbd0 100644 --- a/daemon/cluster/executor/container/adapter.go +++ b/daemon/cluster/executor/container/adapter.go @@ -489,7 +489,7 @@ func (c *containerAdapter) deactivateServiceBinding() error { } func (c *containerAdapter) logs(ctx context.Context, options api.LogSubscriptionOptions) (<-chan *backend.LogMessage, error) { - apiOptions := &types.ContainerLogsOptions{ + apiOptions := &containertypes.LogsOptions{ Follow: options.Follow, // Always say yes to Timestamps and Details. we make the decision diff --git a/daemon/cluster/services.go b/daemon/cluster/services.go index 2403a2451d..5164cd0846 100644 --- a/daemon/cluster/services.go +++ b/daemon/cluster/services.go @@ -15,6 +15,7 @@ import ( "github.com/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" timetypes "github.com/docker/docker/api/types/time" @@ -180,8 +181,8 @@ func (c *Cluster) GetService(input string, insertDefaults bool) (swarm.Service, } // CreateService creates a new service in a managed swarm cluster. -func (c *Cluster) CreateService(s swarm.ServiceSpec, encodedAuth string, queryRegistry bool) (*types.ServiceCreateResponse, error) { - var resp *types.ServiceCreateResponse +func (c *Cluster) CreateService(s swarm.ServiceSpec, encodedAuth string, queryRegistry bool) (*swarm.ServiceCreateResponse, error) { + var resp *swarm.ServiceCreateResponse err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error { err := c.populateNetworkID(ctx, state.controlClient, &s) if err != nil { @@ -193,7 +194,7 @@ func (c *Cluster) CreateService(s swarm.ServiceSpec, encodedAuth string, queryRe return errdefs.InvalidParameter(err) } - resp = &types.ServiceCreateResponse{} + resp = &swarm.ServiceCreateResponse{} switch serviceSpec.Task.Runtime.(type) { case *swarmapi.TaskSpec_Attachment: @@ -280,8 +281,8 @@ func (c *Cluster) CreateService(s swarm.ServiceSpec, encodedAuth string, queryRe } // UpdateService updates existing service to match new properties. -func (c *Cluster) UpdateService(serviceIDOrName string, version uint64, spec swarm.ServiceSpec, flags types.ServiceUpdateOptions, queryRegistry bool) (*types.ServiceUpdateResponse, error) { - var resp *types.ServiceUpdateResponse +func (c *Cluster) UpdateService(serviceIDOrName string, version uint64, spec swarm.ServiceSpec, flags types.ServiceUpdateOptions, queryRegistry bool) (*swarm.ServiceUpdateResponse, error) { + var resp *swarm.ServiceUpdateResponse err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error { err := c.populateNetworkID(ctx, state.controlClient, &spec) @@ -299,7 +300,7 @@ func (c *Cluster) UpdateService(serviceIDOrName string, version uint64, spec swa return err } - resp = &types.ServiceUpdateResponse{} + resp = &swarm.ServiceUpdateResponse{} switch serviceSpec.Task.Runtime.(type) { case *swarmapi.TaskSpec_Attachment: @@ -422,7 +423,7 @@ func (c *Cluster) RemoveService(input string) error { } // ServiceLogs collects service logs and writes them back to `config.OutStream` -func (c *Cluster) ServiceLogs(ctx context.Context, selector *backend.LogSelector, config *types.ContainerLogsOptions) (<-chan *backend.LogMessage, error) { +func (c *Cluster) ServiceLogs(ctx context.Context, selector *backend.LogSelector, config *container.LogsOptions) (<-chan *backend.LogMessage, error) { c.mu.RLock() defer c.mu.RUnlock() diff --git a/daemon/cluster/swarm.go b/daemon/cluster/swarm.go index e5e51d92e7..1a820d67e6 100644 --- a/daemon/cluster/swarm.go +++ b/daemon/cluster/swarm.go @@ -9,6 +9,7 @@ import ( "github.com/containerd/log" apitypes "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" types "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/daemon/cluster/convert" @@ -606,7 +607,7 @@ func initClusterSpec(node *swarmnode.Node, spec types.Spec) error { func (c *Cluster) listContainerForNode(ctx context.Context, nodeID string) ([]string, error) { var ids []string - containers, err := c.config.Backend.Containers(ctx, &apitypes.ContainerListOptions{ + containers, err := c.config.Backend.Containers(ctx, &container.ListOptions{ Filters: filters.NewArgs(filters.Arg("label", "com.docker.swarm.node.id="+nodeID)), }) if err != nil { diff --git a/daemon/containerd/image_delete.go b/daemon/containerd/image_delete.go index 4efbaf7773..459c4c8f6c 100644 --- a/daemon/containerd/image_delete.go +++ b/daemon/containerd/image_delete.go @@ -9,8 +9,8 @@ import ( "github.com/containerd/containerd/images" "github.com/containerd/log" "github.com/distribution/reference" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/events" + imagetypes "github.com/docker/docker/api/types/image" "github.com/docker/docker/container" "github.com/docker/docker/image" "github.com/docker/docker/internal/compatcontext" @@ -52,7 +52,7 @@ import ( // conflict will not be reported. // // TODO(thaJeztah): image delete should send prometheus counters; see https://github.com/moby/moby/issues/45268 -func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error) { +func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]imagetypes.DeleteResponse, error) { parsedRef, err := reference.ParseNormalizedNamed(imageRef) if err != nil { return nil, err @@ -80,7 +80,7 @@ func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, return nil, err } i.LogImageEvent(imgID.String(), imgID.String(), events.ActionUnTag) - records := []types.ImageDeleteResponseItem{{Untagged: reference.FamiliarString(reference.TagNameOnly(parsedRef))}} + records := []imagetypes.DeleteResponse{{Untagged: reference.FamiliarString(reference.TagNameOnly(parsedRef))}} return records, nil } @@ -111,7 +111,7 @@ func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, } i.LogImageEvent(imgID.String(), imgID.String(), events.ActionUnTag) - records := []types.ImageDeleteResponseItem{{Untagged: reference.FamiliarString(reference.TagNameOnly(parsedRef))}} + records := []imagetypes.DeleteResponse{{Untagged: reference.FamiliarString(reference.TagNameOnly(parsedRef))}} return records, nil } @@ -122,8 +122,8 @@ func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, // also deletes dangling parents if there is no conflict in doing so. // Parent images are removed quietly, and if there is any issue/conflict // it is logged but does not halt execution/an error is not returned. -func (i *ImageService) deleteAll(ctx context.Context, img images.Image, force, prune bool) ([]types.ImageDeleteResponseItem, error) { - var records []types.ImageDeleteResponseItem +func (i *ImageService) deleteAll(ctx context.Context, img images.Image, force, prune bool) ([]imagetypes.DeleteResponse, error) { + var records []imagetypes.DeleteResponse // Workaround for: https://github.com/moby/buildkit/issues/3797 possiblyDeletedConfigs := map[digest.Digest]struct{}{} @@ -163,7 +163,7 @@ func (i *ImageService) deleteAll(ctx context.Context, img images.Image, force, p } } i.LogImageEvent(imgID, imgID, events.ActionDelete) - records = append(records, types.ImageDeleteResponseItem{Deleted: imgID}) + records = append(records, imagetypes.DeleteResponse{Deleted: imgID}) for _, parent := range parents { if !isDanglingImage(parent.img) { @@ -176,7 +176,7 @@ func (i *ImageService) deleteAll(ctx context.Context, img images.Image, force, p } parentID := parent.img.Target.Digest.String() i.LogImageEvent(parentID, parentID, events.ActionDelete) - records = append(records, types.ImageDeleteResponseItem{Deleted: parentID}) + records = append(records, imagetypes.DeleteResponse{Deleted: parentID}) } return records, nil @@ -238,7 +238,7 @@ const ( // images and untagged references are appended to the given records. If any // error or conflict is encountered, it will be returned immediately without // deleting the image. -func (i *ImageService) imageDeleteHelper(ctx context.Context, img images.Image, records *[]types.ImageDeleteResponseItem, force bool) error { +func (i *ImageService) imageDeleteHelper(ctx context.Context, img images.Image, records *[]imagetypes.DeleteResponse, force bool) error { // First, determine if this image has any conflicts. Ignore soft conflicts // if force is true. c := conflictHard @@ -264,7 +264,7 @@ func (i *ImageService) imageDeleteHelper(ctx context.Context, img images.Image, if !isDanglingImage(img) { i.LogImageEvent(imgID.String(), imgID.String(), events.ActionUnTag) - *records = append(*records, types.ImageDeleteResponseItem{Untagged: reference.FamiliarString(untaggedRef)}) + *records = append(*records, imagetypes.DeleteResponse{Untagged: reference.FamiliarString(untaggedRef)}) } return nil diff --git a/daemon/containerd/image_list.go b/daemon/containerd/image_list.go index 8a38b8888b..44227dbd43 100644 --- a/daemon/containerd/image_list.go +++ b/daemon/containerd/image_list.go @@ -46,7 +46,7 @@ var acceptedImageFilterTags = map[string]bool{ // byCreated is a temporary type used to sort a list of images by creation // time. -type byCreated []*types.ImageSummary +type byCreated []*imagetypes.Summary func (r byCreated) Len() int { return len(r) } func (r byCreated) Swap(i, j int) { r[i], r[j] = r[j], r[i] } @@ -57,7 +57,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) ([]*types.ImageSummary, error) { +func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) ([]*imagetypes.Summary, error) { if err := opts.Filters.Validate(acceptedImageFilterTags); err != nil { return nil, err } @@ -89,7 +89,7 @@ func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) var ( allContainers []*container.Container - summaries = make([]*types.ImageSummary, 0, len(imgs)) + summaries = make([]*imagetypes.Summary, 0, len(imgs)) root []*[]digest.Digest layers map[digest.Digest]int ) @@ -208,7 +208,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) (*types.ImageSummary, []digest.Digest, error) { +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) { diffIDs, err := imageManifest.RootFS(ctx) if err != nil { return nil, nil, errors.Wrapf(err, "failed to get rootfs of image %s", imageManifest.Name()) @@ -276,7 +276,7 @@ func (i *ImageService) singlePlatformImage(ctx context.Context, contentStore con return nil, nil, err } - summary := &types.ImageSummary{ + summary := &imagetypes.Summary{ ParentID: "", ID: target.String(), Created: rawImg.CreatedAt.Unix(), diff --git a/daemon/containerd/image_prune.go b/daemon/containerd/image_prune.go index 41ce1fcc47..1ca513ae5a 100644 --- a/daemon/containerd/image_prune.go +++ b/daemon/containerd/image_prune.go @@ -10,6 +10,7 @@ import ( "github.com/distribution/reference" "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" "github.com/docker/docker/internal/compatcontext" "github.com/hashicorp/go-multierror" @@ -182,7 +183,7 @@ func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFu } report.ImagesDeleted = append(report.ImagesDeleted, - types.ImageDeleteResponseItem{ + image.DeleteResponse{ Untagged: img.Name, }, ) @@ -193,7 +194,7 @@ func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFu if cerrdefs.IsNotFound(err) { report.ImagesDeleted = append(report.ImagesDeleted, - types.ImageDeleteResponseItem{ + image.DeleteResponse{ Deleted: blob.Digest.String(), }, ) diff --git a/daemon/daemon.go b/daemon/daemon.go index bc47ac5fec..813f1c5afb 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -27,6 +27,7 @@ import ( dist "github.com/docker/distribution" "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" + imagetypes "github.com/docker/docker/api/types/image" registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/volume" @@ -122,7 +123,7 @@ type Daemon struct { seccompProfilePath string usageContainers singleflight.Group[struct{}, []*types.Container] - usageImages singleflight.Group[struct{}, []*types.ImageSummary] + usageImages singleflight.Group[struct{}, []*imagetypes.Summary] usageVolumes singleflight.Group[struct{}, []*volume.Volume] usageLayer singleflight.Group[struct{}, int64] @@ -1265,7 +1266,7 @@ func (daemon *Daemon) Shutdown(ctx context.Context) error { cfg := &daemon.config().Config if cfg.LiveRestoreEnabled && daemon.containers != nil { // check if there are any running containers, if none we should do some cleanup - if ls, err := daemon.Containers(ctx, &types.ContainerListOptions{}); len(ls) != 0 || err != nil { + if ls, err := daemon.Containers(ctx, &containertypes.ListOptions{}); len(ls) != 0 || err != nil { // metrics plugins still need some cleanup daemon.cleanupMetricsPlugins() return err diff --git a/daemon/disk_usage.go b/daemon/disk_usage.go index b4c2b277d0..f9987e2dd1 100644 --- a/daemon/disk_usage.go +++ b/daemon/disk_usage.go @@ -6,7 +6,9 @@ import ( "github.com/docker/docker/api/server/router/system" "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/volume" "github.com/pkg/errors" "golang.org/x/sync/errgroup" @@ -17,7 +19,7 @@ import ( func (daemon *Daemon) containerDiskUsage(ctx context.Context) ([]*types.Container, error) { res, _, err := daemon.usageContainers.Do(ctx, struct{}{}, func(ctx context.Context) ([]*types.Container, error) { // Retrieve container list - containers, err := daemon.Containers(ctx, &types.ContainerListOptions{ + containers, err := daemon.Containers(ctx, &container.ListOptions{ Size: true, All: true, }) @@ -31,8 +33,8 @@ func (daemon *Daemon) containerDiskUsage(ctx context.Context) ([]*types.Containe // imageDiskUsage obtains information about image data disk usage from image service // and makes sure that only one calculation is performed at the same time. -func (daemon *Daemon) imageDiskUsage(ctx context.Context) ([]*types.ImageSummary, error) { - imgs, _, err := daemon.usageImages.Do(ctx, struct{}{}, func(ctx context.Context) ([]*types.ImageSummary, error) { +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{ Filters: filters.NewArgs(), @@ -89,7 +91,7 @@ func (daemon *Daemon) SystemDiskUsage(ctx context.Context, opts system.DiskUsage } var ( - images []*types.ImageSummary + images []*image.Summary layersSize int64 ) if opts.Images { diff --git a/daemon/image_service.go b/daemon/image_service.go index 5b28fbe8ef..50105c5304 100644 --- a/daemon/image_service.go +++ b/daemon/image_service.go @@ -30,11 +30,11 @@ type ImageService interface { PullImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error PushImage(ctx context.Context, ref reference.Named, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error CreateImage(ctx context.Context, config []byte, parent string, contentStoreDigest digest.Digest) (builder.Image, error) - ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error) + ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]imagetype.DeleteResponse, error) 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) ([]*types.ImageSummary, error) + Images(ctx context.Context, opts types.ImageListOptions) ([]*imagetype.Summary, error) LogImageEvent(imageID, refName string, action events.Action) CountImages() int ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error) diff --git a/daemon/images/image_delete.go b/daemon/images/image_delete.go index 786cc728fb..844f48852f 100644 --- a/daemon/images/image_delete.go +++ b/daemon/images/image_delete.go @@ -7,7 +7,6 @@ import ( "time" "github.com/distribution/reference" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/events" imagetypes "github.com/docker/docker/api/types/image" "github.com/docker/docker/container" @@ -61,9 +60,9 @@ const ( // If prune is true, ancestor images will each attempt to be deleted quietly, // meaning any delete conflicts will cause the image to not be deleted and the // conflict will not be reported. -func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error) { +func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]imagetypes.DeleteResponse, error) { start := time.Now() - records := []types.ImageDeleteResponseItem{} + records := []imagetypes.DeleteResponse{} img, err := i.GetImage(ctx, imageRef, imagetypes.GetImageOpts{}) if err != nil { @@ -104,7 +103,7 @@ func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, return nil, err } - untaggedRecord := types.ImageDeleteResponseItem{Untagged: reference.FamiliarString(parsedRef)} + untaggedRecord := imagetypes.DeleteResponse{Untagged: reference.FamiliarString(parsedRef)} i.LogImageEvent(imgID.String(), imgID.String(), events.ActionUnTag) records = append(records, untaggedRecord) @@ -130,9 +129,7 @@ func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, if _, err := i.removeImageRef(repoRef); err != nil { return records, err } - - untaggedRecord := types.ImageDeleteResponseItem{Untagged: reference.FamiliarString(repoRef)} - records = append(records, untaggedRecord) + records = append(records, imagetypes.DeleteResponse{Untagged: reference.FamiliarString(repoRef)}) } else { remainingRefs = append(remainingRefs, repoRef) } @@ -165,11 +162,8 @@ func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, if err != nil { return nil, err } - - untaggedRecord := types.ImageDeleteResponseItem{Untagged: reference.FamiliarString(parsedRef)} - i.LogImageEvent(imgID.String(), imgID.String(), events.ActionUnTag) - records = append(records, untaggedRecord) + records = append(records, imagetypes.DeleteResponse{Untagged: reference.FamiliarString(parsedRef)}) } } } @@ -243,14 +237,14 @@ func (i *ImageService) removeImageRef(ref reference.Named) (reference.Named, err // on the first encountered error. Removed references are logged to this // daemon's event service. An "Untagged" types.ImageDeleteResponseItem is added to the // given list of records. -func (i *ImageService) removeAllReferencesToImageID(imgID image.ID, records *[]types.ImageDeleteResponseItem) error { +func (i *ImageService) removeAllReferencesToImageID(imgID image.ID, records *[]imagetypes.DeleteResponse) error { for _, imageRef := range i.referenceStore.References(imgID.Digest()) { parsedRef, err := i.removeImageRef(imageRef) if err != nil { return err } i.LogImageEvent(imgID.String(), imgID.String(), events.ActionUnTag) - *records = append(*records, types.ImageDeleteResponseItem{ + *records = append(*records, imagetypes.DeleteResponse{ Untagged: reference.FamiliarString(parsedRef), }) } @@ -291,7 +285,7 @@ func (idc *imageDeleteConflict) Conflict() {} // conflict is encountered, it will be returned immediately without deleting // the image. If quiet is true, any encountered conflicts will be ignored and // the function will return nil immediately without deleting the image. -func (i *ImageService) imageDeleteHelper(imgID image.ID, records *[]types.ImageDeleteResponseItem, force, prune, quiet bool) error { +func (i *ImageService) imageDeleteHelper(imgID image.ID, records *[]imagetypes.DeleteResponse, force, prune, quiet bool) error { // First, determine if this image has any conflicts. Ignore soft conflicts // if force is true. c := conflictHard @@ -327,9 +321,9 @@ func (i *ImageService) imageDeleteHelper(imgID image.ID, records *[]types.ImageD } i.LogImageEvent(imgID.String(), imgID.String(), events.ActionDelete) - *records = append(*records, types.ImageDeleteResponseItem{Deleted: imgID.String()}) + *records = append(*records, imagetypes.DeleteResponse{Deleted: imgID.String()}) for _, removedLayer := range removedLayers { - *records = append(*records, types.ImageDeleteResponseItem{Deleted: removedLayer.ChainID.String()}) + *records = append(*records, imagetypes.DeleteResponse{Deleted: removedLayer.ChainID.String()}) } if !prune || parent == "" { diff --git a/daemon/images/image_list.go b/daemon/images/image_list.go index d5e4bf96ef..8da13be112 100644 --- a/daemon/images/image_list.go +++ b/daemon/images/image_list.go @@ -25,14 +25,14 @@ var acceptedImageFilterTags = map[string]bool{ // byCreated is a temporary type used to sort a list of images by creation // time. -type byCreated []*types.ImageSummary +type byCreated []*imagetypes.Summary func (r byCreated) Len() int { return len(r) } 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) ([]*types.ImageSummary, error) { +func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) ([]*imagetypes.Summary, error) { if err := opts.Filters.Validate(acceptedImageFilterTags); err != nil { return nil, err } @@ -83,8 +83,8 @@ func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) } var ( - summaries = make([]*types.ImageSummary, 0, len(selectedImages)) - summaryMap map[*image.Image]*types.ImageSummary + summaries = make([]*imagetypes.Summary, 0, len(selectedImages)) + summaryMap map[*image.Image]*imagetypes.Summary allContainers []*container.Container ) for id, img := range selectedImages { @@ -197,7 +197,7 @@ func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) if opts.ContainerCount || opts.SharedSize { // Lazily init summaryMap. if summaryMap == nil { - summaryMap = make(map[*image.Image]*types.ImageSummary, len(selectedImages)) + summaryMap = make(map[*image.Image]*imagetypes.Summary, len(selectedImages)) } summaryMap[img] = summary } @@ -252,12 +252,12 @@ func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) return summaries, nil } -func newImageSummary(image *image.Image, size int64) *types.ImageSummary { +func newImageSummary(image *image.Image, size int64) *imagetypes.Summary { var created int64 if image.Created != nil { created = image.Created.Unix() } - summary := &types.ImageSummary{ + summary := &imagetypes.Summary{ ParentID: image.Parent.String(), ID: image.ID().String(), Created: created, diff --git a/daemon/images/image_prune.go b/daemon/images/image_prune.go index 7ade3409d7..7634b837ff 100644 --- a/daemon/images/image_prune.go +++ b/daemon/images/image_prune.go @@ -12,6 +12,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" + imagetypes "github.com/docker/docker/api/types/image" timetypes "github.com/docker/docker/api/types/time" "github.com/docker/docker/errdefs" "github.com/docker/docker/image" @@ -96,7 +97,7 @@ deleteImagesLoop: default: } - deletedImages := []types.ImageDeleteResponseItem{} + deletedImages := []imagetypes.DeleteResponse{} refs := i.referenceStore.References(id.Digest()) if len(refs) > 0 { shouldDelete := !danglingOnly diff --git a/daemon/list.go b/daemon/list.go index 5949bde858..d367e19015 100644 --- a/daemon/list.go +++ b/daemon/list.go @@ -9,6 +9,7 @@ import ( "github.com/containerd/log" "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" imagetypes "github.com/docker/docker/api/types/image" "github.com/docker/docker/container" @@ -54,7 +55,7 @@ func (daemon *Daemon) List() []*container.Container { } // listContext is the daemon generated filtering to iterate over containers. -// This is created based on the user specification from types.ContainerListOptions. +// This is created based on the user specification from [containertypes.ListOptions]. type listContext struct { // idx is the container iteration index for this context idx int @@ -84,8 +85,8 @@ type listContext struct { // expose is a list of exposed ports to filter with expose map[nat.Port]bool - // ContainerListOptions is the filters set by the user - *types.ContainerListOptions + // ListOptions is the filters set by the user + *containertypes.ListOptions } // byCreatedDescending is a temporary type used to sort a list of containers by creation time. @@ -98,7 +99,7 @@ func (r byCreatedDescending) Less(i, j int) bool { } // Containers returns the list of containers to show given the user's filtering. -func (daemon *Daemon) Containers(ctx context.Context, config *types.ContainerListOptions) ([]*types.Container, error) { +func (daemon *Daemon) Containers(ctx context.Context, config *containertypes.ListOptions) ([]*types.Container, error) { if err := config.Filters.Validate(acceptedPsFilterTags); err != nil { return nil, err } @@ -224,7 +225,7 @@ func (daemon *Daemon) filterByNameIDMatches(view *container.View, filter *listCo } // foldFilter generates the container filter based on the user's filtering options. -func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, config *types.ContainerListOptions) (*listContext, error) { +func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, config *containertypes.ListOptions) (*listContext, error) { psFilters := config.Filters var filtExited []int @@ -323,18 +324,18 @@ func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, conf } return &listContext{ - filters: psFilters, - ancestorFilter: ancestorFilter, - images: imagesFilter, - exitAllowed: filtExited, - beforeFilter: beforeContFilter, - sinceFilter: sinceContFilter, - taskFilter: taskFilter, - isTask: isTask, - publish: publishFilter, - expose: exposeFilter, - ContainerListOptions: config, - names: view.GetAllNames(), + filters: psFilters, + ancestorFilter: ancestorFilter, + images: imagesFilter, + exitAllowed: filtExited, + beforeFilter: beforeContFilter, + sinceFilter: sinceContFilter, + taskFilter: taskFilter, + isTask: isTask, + publish: publishFilter, + expose: exposeFilter, + ListOptions: config, + names: view.GetAllNames(), }, nil } diff --git a/daemon/list_test.go b/daemon/list_test.go index 982575bc1e..33e54c0ded 100644 --- a/daemon/list_test.go +++ b/daemon/list_test.go @@ -87,7 +87,7 @@ func TestListInvalidFilter(t *testing.T) { containersReplica: db, } - _, err = d.Containers(context.Background(), &types.ContainerListOptions{ + _, err = d.Containers(context.Background(), &containertypes.ListOptions{ Filters: filters.NewArgs(filters.Arg("invalid", "foo")), }) assert.Assert(t, is.Error(err, "invalid filter 'invalid'")) @@ -108,7 +108,7 @@ func TestNameFilter(t *testing.T) { // moby/moby #37453 - ^ regex not working due to prefix slash // not being stripped - containerList, err := d.Containers(context.Background(), &types.ContainerListOptions{ + containerList, err := d.Containers(context.Background(), &containertypes.ListOptions{ Filters: filters.NewArgs(filters.Arg("name", "^a")), }) assert.NilError(t, err) @@ -117,7 +117,7 @@ func TestNameFilter(t *testing.T) { assert.Assert(t, containerListContainsName(containerList, two.Name)) // Same as above but with slash prefix should produce the same result - containerListWithPrefix, err := d.Containers(context.Background(), &types.ContainerListOptions{ + containerListWithPrefix, err := d.Containers(context.Background(), &containertypes.ListOptions{ Filters: filters.NewArgs(filters.Arg("name", "^/a")), }) assert.NilError(t, err) @@ -126,7 +126,7 @@ func TestNameFilter(t *testing.T) { assert.Assert(t, containerListContainsName(containerListWithPrefix, two.Name)) // Same as above but make sure it works for exact names - containerList, err = d.Containers(context.Background(), &types.ContainerListOptions{ + containerList, err = d.Containers(context.Background(), &containertypes.ListOptions{ Filters: filters.NewArgs(filters.Arg("name", "b1")), }) assert.NilError(t, err) @@ -134,7 +134,7 @@ func TestNameFilter(t *testing.T) { assert.Assert(t, containerListContainsName(containerList, three.Name)) // Same as above but with slash prefix should produce the same result - containerListWithPrefix, err = d.Containers(context.Background(), &types.ContainerListOptions{ + containerListWithPrefix, err = d.Containers(context.Background(), &containertypes.ListOptions{ Filters: filters.NewArgs(filters.Arg("name", "/b1")), }) assert.NilError(t, err) diff --git a/daemon/logs.go b/daemon/logs.go index 6e1267212b..c48a77c987 100644 --- a/daemon/logs.go +++ b/daemon/logs.go @@ -6,7 +6,6 @@ import ( "time" "github.com/containerd/log" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" containertypes "github.com/docker/docker/api/types/container" timetypes "github.com/docker/docker/api/types/time" @@ -24,7 +23,7 @@ import ( // // if it returns nil, the config channel will be active and return log // messages until it runs out or the context is canceled. -func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, config *types.ContainerLogsOptions) (messages <-chan *backend.LogMessage, isTTY bool, retErr error) { +func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, config *containertypes.LogsOptions) (messages <-chan *backend.LogMessage, isTTY bool, retErr error) { lg := log.G(ctx).WithFields(log.Fields{ "module": "daemon", "method": "(*Daemon).ContainerLogs", diff --git a/hack/generate-swagger-api.sh b/hack/generate-swagger-api.sh index d5032178e5..2868d8804e 100755 --- a/hack/generate-swagger-api.sh +++ b/hack/generate-swagger-api.sh @@ -6,15 +6,12 @@ swagger generate model -f api/swagger.yaml \ -n ErrorResponse \ -n GraphDriverData \ -n IdResponse \ - -n ImageDeleteResponseItem \ - -n ImageSummary \ -n Plugin \ -n PluginDevice \ -n PluginMount \ -n PluginEnv \ -n PluginInterfaceType \ - -n Port \ - -n ServiceUpdateResponse + -n Port swagger generate model -f api/swagger.yaml \ -t api -m types/container --skip-validator -C api/swagger-gen.yaml \ @@ -24,6 +21,11 @@ swagger generate model -f api/swagger.yaml \ -n ChangeType \ -n FilesystemChange +swagger generate model -f api/swagger.yaml \ + -t api -m types/image --skip-validator -C api/swagger-gen.yaml \ + -n ImageDeleteResponseItem \ + -n ImageSummary + swagger generate model -f api/swagger.yaml \ -t api -m types/volume --skip-validator -C api/swagger-gen.yaml \ -n Volume \ @@ -37,3 +39,8 @@ swagger generate operation -f api/swagger.yaml \ -n ContainerTop \ -n ContainerUpdate \ -n ImageHistory + +swagger generate model -f api/swagger.yaml \ + -t api -m types/swarm --skip-validator -C api/swagger-gen.yaml \ + -n ServiceCreateResponse \ + -n ServiceUpdateResponse diff --git a/integration-cli/docker_api_attach_test.go b/integration-cli/docker_api_attach_test.go index 9cf6645d60..b77292db71 100644 --- a/integration-cli/docker_api_attach_test.go +++ b/integration-cli/docker_api_attach_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" "github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/testutil" @@ -184,7 +185,7 @@ func (s *DockerAPISuite) TestPostContainersAttach(c *testing.T) { cid = strings.TrimSpace(cid) // Make sure we don't see "hello" if Logs is false - attachOpts := types.ContainerAttachOptions{ + attachOpts := container.AttachOptions{ Stream: true, Stdin: true, Stdout: true, diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index c14cf4d8ff..69bcc2fa35 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -45,7 +45,7 @@ func (s *DockerAPISuite) TestContainerAPIGetAll(c *testing.T) { assert.NilError(c, err) defer apiClient.Close() - options := types.ContainerListOptions{ + options := container.ListOptions{ All: true, } ctx := testutil.GetContext(c) @@ -65,7 +65,7 @@ func (s *DockerAPISuite) TestContainerAPIGetJSONNoFieldsOmitted(c *testing.T) { assert.NilError(c, err) defer apiClient.Close() - options := types.ContainerListOptions{ + options := container.ListOptions{ All: true, } ctx := testutil.GetContext(c) @@ -454,7 +454,7 @@ func (s *DockerAPISuite) TestContainerAPICommit(c *testing.T) { assert.NilError(c, err) defer apiClient.Close() - options := types.ContainerCommitOptions{ + options := container.CommitOptions{ Reference: "testcontainerapicommit:testtag", } @@ -480,7 +480,7 @@ func (s *DockerAPISuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) { Labels: map[string]string{"key1": "value1", "key2": "value2"}, } - options := types.ContainerCommitOptions{ + options := container.CommitOptions{ Reference: "testcontainerapicommitwithconfig", Config: &config, } @@ -924,12 +924,12 @@ func (s *DockerAPISuite) TestContainerAPIStart(c *testing.T) { _, err = apiClient.ContainerCreate(testutil.GetContext(c), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, name) assert.NilError(c, err) - err = apiClient.ContainerStart(testutil.GetContext(c), name, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(testutil.GetContext(c), name, container.StartOptions{}) assert.NilError(c, err) // second call to start should give 304 // maybe add ContainerStartWithRaw to test it - err = apiClient.ContainerStart(testutil.GetContext(c), name, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(testutil.GetContext(c), name, container.StartOptions{}) assert.NilError(c, err) // TODO(tibor): figure out why this doesn't work on windows @@ -1089,7 +1089,7 @@ func (s *DockerAPISuite) TestContainerAPIDelete(c *testing.T) { assert.NilError(c, err) defer apiClient.Close() - err = apiClient.ContainerRemove(testutil.GetContext(c), id, types.ContainerRemoveOptions{}) + err = apiClient.ContainerRemove(testutil.GetContext(c), id, container.RemoveOptions{}) assert.NilError(c, err) } @@ -1098,7 +1098,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteNotExist(c *testing.T) { assert.NilError(c, err) defer apiClient.Close() - err = apiClient.ContainerRemove(testutil.GetContext(c), "doesnotexist", types.ContainerRemoveOptions{}) + err = apiClient.ContainerRemove(testutil.GetContext(c), "doesnotexist", container.RemoveOptions{}) assert.ErrorContains(c, err, "No such container: doesnotexist") } @@ -1107,7 +1107,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteForce(c *testing.T) { id := strings.TrimSpace(out) assert.NilError(c, waitRun(id)) - removeOptions := types.ContainerRemoveOptions{ + removeOptions := container.RemoveOptions{ Force: true, } @@ -1135,7 +1135,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteRemoveLinks(c *testing.T) { links := inspectFieldJSON(c, id2, "HostConfig.Links") assert.Equal(c, links, `["/tlink1:/tlink2/tlink1"]`, "expected to have links between containers") - removeOptions := types.ContainerRemoveOptions{ + removeOptions := container.RemoveOptions{ RemoveLinks: true, } @@ -1168,7 +1168,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteRemoveVolume(c *testing.T) { _, err = os.Stat(source) assert.NilError(c, err) - removeOptions := types.ContainerRemoveOptions{ + removeOptions := container.RemoveOptions{ Force: true, RemoveVolumes: true, } @@ -1549,7 +1549,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteWithEmptyName(c *testing.T) { assert.NilError(c, err) defer apiClient.Close() - err = apiClient.ContainerRemove(testutil.GetContext(c), "", types.ContainerRemoveOptions{}) + err = apiClient.ContainerRemove(testutil.GetContext(c), "", container.RemoveOptions{}) assert.Check(c, errdefs.IsNotFound(err)) } @@ -1572,7 +1572,7 @@ func (s *DockerAPISuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) _, err = apiClient.ContainerCreate(testutil.GetContext(c), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, name) assert.NilError(c, err) - err = apiClient.ContainerStart(testutil.GetContext(c), name, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(testutil.GetContext(c), name, container.StartOptions{}) assert.NilError(c, err) assert.Assert(c, waitRun(name) == nil) @@ -2112,11 +2112,11 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsCreate(c *testing.T) { assert.Check(c, is.Equal(x.expected.Mode, mountPoint.Mode)) assert.Check(c, is.Equal(x.expected.Destination, mountPoint.Destination)) - err = apiclient.ContainerStart(ctx, ctr.ID, types.ContainerStartOptions{}) + err = apiclient.ContainerStart(ctx, ctr.ID, container.StartOptions{}) assert.NilError(c, err) poll.WaitOn(c, containerExit(ctx, apiclient, ctr.ID), poll.WithDelay(time.Second)) - err = apiclient.ContainerRemove(ctx, ctr.ID, types.ContainerRemoveOptions{ + err = apiclient.ContainerRemove(ctx, ctr.ID, container.RemoveOptions{ RemoveVolumes: true, Force: true, }) diff --git a/integration-cli/docker_api_containers_windows_test.go b/integration-cli/docker_api_containers_windows_test.go index d19865265c..4c0be31e4f 100644 --- a/integration-cli/docker_api_containers_windows_test.go +++ b/integration-cli/docker_api_containers_windows_test.go @@ -10,7 +10,6 @@ import ( "testing" winio "github.com/Microsoft/go-winio" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/testutil" @@ -66,7 +65,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsBindNamedPipe(c *testing.T nil, nil, name) assert.NilError(c, err) - err = client.ContainerStart(ctx, name, types.ContainerStartOptions{}) + err = client.ContainerStart(ctx, name, container.StartOptions{}) assert.NilError(c, err) err = <-ch diff --git a/integration-cli/docker_api_logs_test.go b/integration-cli/docker_api_logs_test.go index 69fbe73de8..dc3c60b648 100644 --- a/integration-cli/docker_api_logs_test.go +++ b/integration-cli/docker_api_logs_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" "github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/testutil" @@ -62,7 +62,7 @@ func (s *DockerAPISuite) TestLogsAPINoStdoutNorStderr(c *testing.T) { assert.NilError(c, err) defer apiClient.Close() - _, err = apiClient.ContainerLogs(testutil.GetContext(c), name, types.ContainerLogsOptions{}) + _, err = apiClient.ContainerLogs(testutil.GetContext(c), name, container.LogsOptions{}) assert.ErrorContains(c, err, "Bad parameters: you must choose at least one stream") } @@ -105,8 +105,12 @@ func (s *DockerAPISuite) TestLogsAPIUntilFutureFollow(c *testing.T) { c.Fatal(err) } - cfg := types.ContainerLogsOptions{Until: until.Format(time.RFC3339Nano), Follow: true, ShowStdout: true, Timestamps: true} - reader, err := client.ContainerLogs(testutil.GetContext(c), name, cfg) + reader, err := client.ContainerLogs(testutil.GetContext(c), name, container.LogsOptions{ + Until: until.Format(time.RFC3339Nano), + Follow: true, + ShowStdout: true, + Timestamps: true, + }) assert.NilError(c, err) type logOut struct { @@ -167,7 +171,7 @@ func (s *DockerAPISuite) TestLogsAPIUntil(c *testing.T) { c.Fatal(err) } - extractBody := func(c *testing.T, cfg types.ContainerLogsOptions) []string { + extractBody := func(c *testing.T, cfg container.LogsOptions) []string { reader, err := client.ContainerLogs(testutil.GetContext(c), name, cfg) assert.NilError(c, err) @@ -180,7 +184,7 @@ func (s *DockerAPISuite) TestLogsAPIUntil(c *testing.T) { } // Get timestamp of second log line - allLogs := extractBody(c, types.ContainerLogsOptions{Timestamps: true, ShowStdout: true}) + allLogs := extractBody(c, container.LogsOptions{Timestamps: true, ShowStdout: true}) assert.Assert(c, len(allLogs) >= 3) t, err := time.Parse(time.RFC3339Nano, strings.Split(allLogs[1], " ")[0]) @@ -188,7 +192,7 @@ func (s *DockerAPISuite) TestLogsAPIUntil(c *testing.T) { until := t.Format(time.RFC3339Nano) // Get logs until the timestamp of second line, i.e. first two lines - logs := extractBody(c, types.ContainerLogsOptions{Timestamps: true, ShowStdout: true, Until: until}) + logs := extractBody(c, container.LogsOptions{Timestamps: true, ShowStdout: true, Until: until}) // Ensure log lines after cut-off are excluded logsString := strings.Join(logs, "\n") @@ -204,7 +208,7 @@ func (s *DockerAPISuite) TestLogsAPIUntilDefaultValue(c *testing.T) { c.Fatal(err) } - extractBody := func(c *testing.T, cfg types.ContainerLogsOptions) []string { + extractBody := func(c *testing.T, cfg container.LogsOptions) []string { reader, err := client.ContainerLogs(testutil.GetContext(c), name, cfg) assert.NilError(c, err) @@ -217,9 +221,9 @@ func (s *DockerAPISuite) TestLogsAPIUntilDefaultValue(c *testing.T) { } // Get timestamp of second log line - allLogs := extractBody(c, types.ContainerLogsOptions{Timestamps: true, ShowStdout: true}) + allLogs := extractBody(c, container.LogsOptions{Timestamps: true, ShowStdout: true}) // Test with default value specified and parameter omitted - defaultLogs := extractBody(c, types.ContainerLogsOptions{Timestamps: true, ShowStdout: true, Until: "0"}) + defaultLogs := extractBody(c, container.LogsOptions{Timestamps: true, ShowStdout: true, Until: "0"}) assert.DeepEqual(c, defaultLogs, allLogs) } diff --git a/integration-cli/docker_cli_events_test.go b/integration-cli/docker_cli_events_test.go index b76f609b3d..244a71fa74 100644 --- a/integration-cli/docker_cli_events_test.go +++ b/integration-cli/docker_cli_events_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" eventtypes "github.com/docker/docker/api/types/events" "github.com/docker/docker/client" eventstestutils "github.com/docker/docker/daemon/events/testutils" @@ -459,7 +459,7 @@ func (s *DockerCLIEventSuite) TestEventsResize(c *testing.T) { assert.NilError(c, err) defer apiClient.Close() - options := types.ResizeOptions{ + options := container.ResizeOptions{ Height: 80, Width: 24, } diff --git a/integration/build/build_squash_test.go b/integration/build/build_squash_test.go index f9c830bd43..2a2d034e4d 100644 --- a/integration/build/build_squash_test.go +++ b/integration/build/build_squash_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" dclient "github.com/docker/docker/client" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/pkg/stdcopy" @@ -84,7 +85,7 @@ func TestBuildSquashParent(t *testing.T) { container.WithImage(name), container.WithCmd("/bin/sh", "-c", "cat /hello"), ) - reader, err := client.ContainerLogs(ctx, cid, types.ContainerLogsOptions{ + reader, err := client.ContainerLogs(ctx, cid, containertypes.LogsOptions{ ShowStdout: true, }) assert.NilError(t, err) diff --git a/integration/build/build_test.go b/integration/build/build_test.go index b009bdefff..4b01f21121 100644 --- a/integration/build/build_test.go +++ b/integration/build/build_test.go @@ -10,6 +10,7 @@ import ( "testing" "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/versions" "github.com/docker/docker/errdefs" @@ -109,7 +110,7 @@ func TestBuildWithRemoveAndForceRemove(t *testing.T) { defer resp.Body.Close() filter, err := buildContainerIdsFilter(resp.Body) assert.NilError(t, err) - remainingContainers, err := client.ContainerList(ctx, types.ContainerListOptions{Filters: filter, All: true}) + remainingContainers, err := client.ContainerList(ctx, container.ListOptions{Filters: filter, All: true}) assert.NilError(t, err) assert.Equal(t, c.numberOfIntermediateContainers, len(remainingContainers), "Expected %v remaining intermediate containers, got %v", c.numberOfIntermediateContainers, len(remainingContainers)) }) diff --git a/integration/build/build_userns_linux_test.go b/integration/build/build_userns_linux_test.go index d465546aa8..0186429df6 100644 --- a/integration/build/build_userns_linux_test.go +++ b/integration/build/build_userns_linux_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/pkg/stdcopy" @@ -116,7 +117,7 @@ func TestBuildUserNamespaceValidateCapabilitiesAreV2(t *testing.T) { container.WithImage(imageTag), container.WithCmd("/sbin/getcap", "-n", "/bin/sleep"), ) - logReader, err := clientNoUserRemap.ContainerLogs(ctx, cid, types.ContainerLogsOptions{ + logReader, err := clientNoUserRemap.ContainerLogs(ctx, cid, containertypes.LogsOptions{ ShowStdout: true, }) assert.NilError(t, err) diff --git a/integration/capabilities/capabilities_linux_test.go b/integration/capabilities/capabilities_linux_test.go index 876ef1af05..3a661ddc93 100644 --- a/integration/capabilities/capabilities_linux_test.go +++ b/integration/capabilities/capabilities_linux_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/testutil" @@ -83,7 +84,7 @@ func TestNoNewPrivileges(t *testing.T) { poll.WaitOn(t, container.IsInState(ctx, client, cid, "exited"), poll.WithDelay(100*time.Millisecond)) // Assert on outputs - logReader, err := client.ContainerLogs(ctx, cid, types.ContainerLogsOptions{ + logReader, err := client.ContainerLogs(ctx, cid, containertypes.LogsOptions{ ShowStdout: true, ShowStderr: true, }) diff --git a/integration/container/attach_test.go b/integration/container/attach_test.go index c2c2c4b888..b761615de5 100644 --- a/integration/container/attach_test.go +++ b/integration/container/attach_test.go @@ -13,7 +13,7 @@ import ( func TestAttach(t *testing.T) { ctx := setupTest(t) - client := testEnv.APIClient() + apiClient := testEnv.APIClient() tests := []struct { doc string @@ -36,7 +36,7 @@ func TestAttach(t *testing.T) { t.Parallel() ctx := testutil.StartSpan(ctx, t) - resp, err := client.ContainerCreate(ctx, + resp, err := apiClient.ContainerCreate(ctx, &container.Config{ Image: "busybox", Cmd: []string{"echo", "hello"}, @@ -48,7 +48,7 @@ func TestAttach(t *testing.T) { "", ) assert.NilError(t, err) - attach, err := client.ContainerAttach(ctx, resp.ID, types.ContainerAttachOptions{ + attach, err := apiClient.ContainerAttach(ctx, resp.ID, container.AttachOptions{ Stdout: true, Stderr: true, }) diff --git a/integration/container/cdi_test.go b/integration/container/cdi_test.go index 2a803488e8..95f80dc7db 100644 --- a/integration/container/cdi_test.go +++ b/integration/container/cdi_test.go @@ -9,7 +9,6 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/pkg/stdcopy" @@ -38,7 +37,7 @@ func TestCreateWithCDIDevices(t *testing.T) { container.WithCmd("/bin/sh", "-c", "env"), container.WithCDIDevices("vendor1.com/device=foo"), ) - defer apiClient.ContainerRemove(ctx, id, types.ContainerRemoveOptions{Force: true}) + defer apiClient.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true}) inspect, err := apiClient.ContainerInspect(ctx, id) assert.NilError(t, err) @@ -51,7 +50,7 @@ func TestCreateWithCDIDevices(t *testing.T) { } assert.Check(t, is.DeepEqual(inspect.HostConfig.DeviceRequests, expectedRequests)) - reader, err := apiClient.ContainerLogs(ctx, id, types.ContainerLogsOptions{ + reader, err := apiClient.ContainerLogs(ctx, id, containertypes.LogsOptions{ ShowStdout: true, }) assert.NilError(t, err) diff --git a/integration/container/checkpoint_test.go b/integration/container/checkpoint_test.go index 63795ce596..359e8c421c 100644 --- a/integration/container/checkpoint_test.go +++ b/integration/container/checkpoint_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/checkpoint" + containertypes "github.com/docker/docker/api/types/container" mounttypes "github.com/docker/docker/api/types/mount" "github.com/docker/docker/client" "github.com/docker/docker/integration/internal/container" @@ -128,7 +128,7 @@ func TestCheckpoint(t *testing.T) { // Restore the container from a second checkpoint. t.Log("Restore the container") - err = apiClient.ContainerStart(ctx, cID, types.ContainerStartOptions{ + err = apiClient.ContainerStart(ctx, cID, containertypes.StartOptions{ CheckpointID: "test2", }) assert.NilError(t, err) diff --git a/integration/container/create_test.go b/integration/container/create_test.go index d585c59a79..7dd2b4993e 100644 --- a/integration/container/create_test.go +++ b/integration/container/create_test.go @@ -8,9 +8,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" - containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/versions" "github.com/docker/docker/client" @@ -253,7 +251,7 @@ func TestCreateWithCustomMaskedPaths(t *testing.T) { checkInspect(t, ctx, name, tc.expected) // Start the container. - err = apiClient.ContainerStart(ctx, c.ID, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(ctx, c.ID, container.StartOptions{}) assert.NilError(t, err) poll.WaitOn(t, ctr.IsInState(ctx, apiClient, c.ID, "exited"), poll.WithDelay(100*time.Millisecond)) @@ -331,7 +329,7 @@ func TestCreateWithCustomReadonlyPaths(t *testing.T) { checkInspect(t, ctx, name, tc.expected) // Start the container. - err = apiClient.ContainerStart(ctx, c.ID, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(ctx, c.ID, container.StartOptions{}) assert.NilError(t, err) poll.WaitOn(t, ctr.IsInState(ctx, apiClient, c.ID, "exited"), poll.WithDelay(100*time.Millisecond)) @@ -436,7 +434,7 @@ func TestCreateTmpfsOverrideAnonymousVolume(t *testing.T) { ) defer func() { - err := apiClient.ContainerRemove(ctx, id, types.ContainerRemoveOptions{Force: true}) + err := apiClient.ContainerRemove(ctx, id, container.RemoveOptions{Force: true}) assert.NilError(t, err) }() @@ -447,7 +445,7 @@ func TestCreateTmpfsOverrideAnonymousVolume(t *testing.T) { assert.Assert(t, is.Len(inspect.Mounts, 0)) chWait, chErr := apiClient.ContainerWait(ctx, id, container.WaitConditionNextExit) - assert.NilError(t, apiClient.ContainerStart(ctx, id, types.ContainerStartOptions{})) + assert.NilError(t, apiClient.ContainerStart(ctx, id, container.StartOptions{})) timeout := time.NewTimer(30 * time.Second) defer timeout.Stop() @@ -483,7 +481,7 @@ func TestCreateDifferentPlatform(t *testing.T) { Architecture: img.Architecture, Variant: img.Variant, } - _, err := apiClient.ContainerCreate(ctx, &containertypes.Config{Image: "busybox:latest"}, &containertypes.HostConfig{}, nil, &p, "") + _, err := apiClient.ContainerCreate(ctx, &container.Config{Image: "busybox:latest"}, &container.HostConfig{}, nil, &p, "") assert.Check(t, is.ErrorType(err, errdefs.IsNotFound)) }) t.Run("different cpu arch", func(t *testing.T) { @@ -493,7 +491,7 @@ func TestCreateDifferentPlatform(t *testing.T) { Architecture: img.Architecture + "DifferentArch", Variant: img.Variant, } - _, err := apiClient.ContainerCreate(ctx, &containertypes.Config{Image: "busybox:latest"}, &containertypes.HostConfig{}, nil, &p, "") + _, err := apiClient.ContainerCreate(ctx, &container.Config{Image: "busybox:latest"}, &container.HostConfig{}, nil, &p, "") assert.Check(t, is.ErrorType(err, errdefs.IsNotFound)) }) } @@ -541,32 +539,32 @@ func TestCreateInvalidHostConfig(t *testing.T) { testCases := []struct { doc string - hc containertypes.HostConfig + hc container.HostConfig expectedErr string }{ { doc: "invalid IpcMode", - hc: containertypes.HostConfig{IpcMode: "invalid"}, + hc: container.HostConfig{IpcMode: "invalid"}, expectedErr: "Error response from daemon: invalid IPC mode: invalid", }, { doc: "invalid PidMode", - hc: containertypes.HostConfig{PidMode: "invalid"}, + hc: container.HostConfig{PidMode: "invalid"}, expectedErr: "Error response from daemon: invalid PID mode: invalid", }, { doc: "invalid PidMode without container ID", - hc: containertypes.HostConfig{PidMode: "container"}, + hc: container.HostConfig{PidMode: "container"}, expectedErr: "Error response from daemon: invalid PID mode: container", }, { doc: "invalid UTSMode", - hc: containertypes.HostConfig{UTSMode: "invalid"}, + hc: container.HostConfig{UTSMode: "invalid"}, expectedErr: "Error response from daemon: invalid UTS mode: invalid", }, { doc: "invalid Annotations", - hc: containertypes.HostConfig{Annotations: map[string]string{"": "a"}}, + hc: container.HostConfig{Annotations: map[string]string{"": "a"}}, expectedErr: "Error response from daemon: invalid Annotations: the empty string is not permitted as an annotation key", }, } diff --git a/integration/container/daemon_linux_test.go b/integration/container/daemon_linux_test.go index ef22f0706f..41bddd96f9 100644 --- a/integration/container/daemon_linux_test.go +++ b/integration/container/daemon_linux_test.go @@ -47,9 +47,9 @@ func TestContainerStartOnDaemonRestart(t *testing.T) { c := d.NewClientT(t) cID := container.Create(ctx, t, c) - defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, cID, containertypes.RemoveOptions{Force: true}) - err := c.ContainerStart(ctx, cID, types.ContainerStartOptions{}) + err := c.ContainerStart(ctx, cID, containertypes.StartOptions{}) assert.Check(t, err, "error starting test container") inspect, err := c.ContainerInspect(ctx, cID) @@ -68,7 +68,7 @@ func TestContainerStartOnDaemonRestart(t *testing.T) { d.Start(t, "--iptables=false") - err = c.ContainerStart(ctx, cID, types.ContainerStartOptions{}) + err = c.ContainerStart(ctx, cID, containertypes.StartOptions{}) assert.Check(t, err, "failed to start test container") } @@ -105,7 +105,7 @@ func TestDaemonRestartIpcMode(t *testing.T) { container.WithCmd("top"), container.WithRestartPolicy(containertypes.RestartPolicyAlways), ) - defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, cID, containertypes.RemoveOptions{Force: true}) inspect, err := c.ContainerInspect(ctx, cID) assert.NilError(t, err) @@ -121,7 +121,7 @@ func TestDaemonRestartIpcMode(t *testing.T) { // check a new container is created with shareable ipc mode as per new daemon default cID = container.Run(ctx, t, c) - defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, cID, containertypes.RemoveOptions{Force: true}) inspect, err = c.ContainerInspect(ctx, cID) assert.NilError(t, err) @@ -156,7 +156,7 @@ func TestDaemonHostGatewayIP(t *testing.T) { inspect, err := c.NetworkInspect(ctx, "bridge", types.NetworkInspectOptions{}) assert.NilError(t, err) assert.Check(t, is.Contains(res.Stdout(), inspect.IPAM.Config[0].Gateway)) - c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true}) + c.ContainerRemove(ctx, cID, containertypes.RemoveOptions{Force: true}) d.Stop(t) // Verify the IP in /etc/hosts is same as host-gateway-ip @@ -169,7 +169,7 @@ func TestDaemonHostGatewayIP(t *testing.T) { assert.Assert(t, is.Len(res.Stderr(), 0)) assert.Equal(t, 0, res.ExitCode) assert.Check(t, is.Contains(res.Stdout(), "6.7.8.9")) - c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true}) + c.ContainerRemove(ctx, cID, containertypes.RemoveOptions{Force: true}) d.Stop(t) } diff --git a/integration/container/daemon_test.go b/integration/container/daemon_test.go index 4aeb2e3fd8..0ae1b384e1 100644 --- a/integration/container/daemon_test.go +++ b/integration/container/daemon_test.go @@ -3,7 +3,7 @@ package container import ( "testing" - "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/testutil" "github.com/docker/docker/testutil/daemon" @@ -35,7 +35,7 @@ func TestContainerKillOnDaemonStart(t *testing.T) { // Sadly this means the test will take longer, but at least this test can be parallelized. id := container.Run(ctx, t, apiClient, container.WithCmd("/bin/sh", "-c", "while true; do echo hello; sleep 1; done")) defer func() { - err := apiClient.ContainerRemove(ctx, id, types.ContainerRemoveOptions{Force: true}) + err := apiClient.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true}) assert.NilError(t, err) }() diff --git a/integration/container/devices_windows_test.go b/integration/container/devices_windows_test.go index 7c3f7f959a..a1f6446f80 100644 --- a/integration/container/devices_windows_test.go +++ b/integration/container/devices_windows_test.go @@ -4,7 +4,6 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/testutil" @@ -100,7 +99,7 @@ func TestWindowsDevices(t *testing.T) { // remove this skip.If and validate the expected behaviour under Hyper-V. skip.If(t, d.isolation == containertypes.IsolationHyperV && !d.expectedStartFailure, "FIXME. HyperV isolation setup is probably incorrect in the test") - err := apiClient.ContainerStart(ctx, id, types.ContainerStartOptions{}) + err := apiClient.ContainerStart(ctx, id, containertypes.StartOptions{}) if d.expectedStartFailure { assert.ErrorContains(t, err, d.expectedStartFailureMessage) return diff --git a/integration/container/ipcmode_linux_test.go b/integration/container/ipcmode_linux_test.go index 99224a6364..9e7f28fa07 100644 --- a/integration/container/ipcmode_linux_test.go +++ b/integration/container/ipcmode_linux_test.go @@ -7,7 +7,6 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/versions" "github.com/docker/docker/client" @@ -68,7 +67,7 @@ func testIpcNonePrivateShareable(t *testing.T, mode string, mustBeMounted bool, assert.NilError(t, err) assert.Check(t, is.Equal(len(resp.Warnings), 0)) - err = apiClient.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(ctx, resp.ID, containertypes.StartOptions{}) assert.NilError(t, err) // get major:minor pair for /dev/shm from container's /proc/self/mountinfo @@ -140,7 +139,7 @@ func testIpcContainer(t *testing.T, donorMode string, mustWork bool) { assert.Check(t, is.Equal(len(resp.Warnings), 0)) name1 := resp.ID - err = apiClient.ContainerStart(ctx, name1, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(ctx, name1, containertypes.StartOptions{}) assert.NilError(t, err) // create and start the second container @@ -150,7 +149,7 @@ func testIpcContainer(t *testing.T, donorMode string, mustWork bool) { assert.Check(t, is.Equal(len(resp.Warnings), 0)) name2 := resp.ID - err = apiClient.ContainerStart(ctx, name2, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(ctx, name2, containertypes.StartOptions{}) if !mustWork { // start should fail with a specific error assert.Check(t, is.ErrorContains(err, "non-shareable IPC")) @@ -206,7 +205,7 @@ func TestAPIIpcModeHost(t *testing.T) { assert.Check(t, is.Equal(len(resp.Warnings), 0)) name := resp.ID - err = apiClient.ContainerStart(ctx, name, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(ctx, name, containertypes.StartOptions{}) assert.NilError(t, err) // check that IPC is shared @@ -241,7 +240,7 @@ func testDaemonIpcPrivateShareable(t *testing.T, mustBeShared bool, arg ...strin assert.NilError(t, err) assert.Check(t, is.Equal(len(resp.Warnings), 0)) - err = c.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}) + err = c.ContainerStart(ctx, resp.ID, containertypes.StartOptions{}) assert.NilError(t, err) // get major:minor pair for /dev/shm from container's /proc/self/mountinfo diff --git a/integration/container/links_linux_test.go b/integration/container/links_linux_test.go index 92d4cc1514..15d3dacd4a 100644 --- a/integration/container/links_linux_test.go +++ b/integration/container/links_linux_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "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/integration/internal/container" "gotest.tools/v3/assert" @@ -43,7 +43,7 @@ func TestLinksContainerNames(t *testing.T) { container.Run(ctx, t, apiClient, container.WithName(containerA)) container.Run(ctx, t, apiClient, container.WithName(containerB), container.WithLinks(containerA+":"+containerA)) - containers, err := apiClient.ContainerList(ctx, types.ContainerListOptions{ + containers, err := apiClient.ContainerList(ctx, containertypes.ListOptions{ Filters: filters.NewArgs(filters.Arg("name", containerA)), }) assert.NilError(t, err) diff --git a/integration/container/logs_test.go b/integration/container/logs_test.go index 7bf95c1567..98ddbb777c 100644 --- a/integration/container/logs_test.go +++ b/integration/container/logs_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/daemon/logger/jsonfilelog" "github.com/docker/docker/daemon/logger/local" "github.com/docker/docker/integration/internal/container" @@ -29,7 +29,7 @@ func TestLogsFollowTailEmpty(t *testing.T) { id := container.Run(ctx, t, apiClient, container.WithCmd("sleep", "100000")) - logs, err := apiClient.ContainerLogs(ctx, id, types.ContainerLogsOptions{ShowStdout: true, Tail: "2"}) + logs, err := apiClient.ContainerLogs(ctx, id, containertypes.LogsOptions{ShowStdout: true, Tail: "2"}) if logs != nil { defer logs.Close() } @@ -55,7 +55,7 @@ func testLogs(t *testing.T, logDriver string) { testCases := []struct { desc string - logOps types.ContainerLogsOptions + logOps containertypes.LogsOptions expectedOut string expectedErr string tty bool @@ -64,7 +64,7 @@ func testLogs(t *testing.T, logDriver string) { { desc: "tty/stdout and stderr", tty: true, - logOps: types.ContainerLogsOptions{ + logOps: containertypes.LogsOptions{ ShowStdout: true, ShowStderr: true, }, @@ -73,7 +73,7 @@ func testLogs(t *testing.T, logDriver string) { { desc: "tty/only stdout", tty: true, - logOps: types.ContainerLogsOptions{ + logOps: containertypes.LogsOptions{ ShowStdout: true, ShowStderr: false, }, @@ -82,7 +82,7 @@ func testLogs(t *testing.T, logDriver string) { { desc: "tty/only stderr", tty: true, - logOps: types.ContainerLogsOptions{ + logOps: containertypes.LogsOptions{ ShowStdout: false, ShowStderr: true, }, @@ -92,7 +92,7 @@ func testLogs(t *testing.T, logDriver string) { { desc: "without tty/stdout and stderr", tty: false, - logOps: types.ContainerLogsOptions{ + logOps: containertypes.LogsOptions{ ShowStdout: true, ShowStderr: true, }, @@ -102,7 +102,7 @@ func testLogs(t *testing.T, logDriver string) { { desc: "without tty/only stdout", tty: false, - logOps: types.ContainerLogsOptions{ + logOps: containertypes.LogsOptions{ ShowStdout: true, ShowStderr: false, }, @@ -112,7 +112,7 @@ func testLogs(t *testing.T, logDriver string) { { desc: "without tty/only stderr", tty: false, - logOps: types.ContainerLogsOptions{ + logOps: containertypes.LogsOptions{ ShowStdout: false, ShowStderr: true, }, @@ -136,7 +136,7 @@ func testLogs(t *testing.T, logDriver string) { container.WithTty(tty), container.WithLogDriver(logDriver), ) - defer apiClient.ContainerRemove(ctx, id, types.ContainerRemoveOptions{Force: true}) + defer apiClient.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true}) poll.WaitOn(t, container.IsStopped(ctx, apiClient, id), poll.WithDelay(time.Millisecond*100), diff --git a/integration/container/mounts_linux_test.go b/integration/container/mounts_linux_test.go index 13bf138c2a..07078ca12e 100644 --- a/integration/container/mounts_linux_test.go +++ b/integration/container/mounts_linux_test.go @@ -8,7 +8,6 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" mounttypes "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/network" @@ -67,7 +66,7 @@ func TestContainerNetworkMountsNoChown(t *testing.T) { ctrCreate, err := cli.ContainerCreate(ctx, &config, &hostConfig, &network.NetworkingConfig{}, nil, "") assert.NilError(t, err) // container will exit immediately because of no tty, but we only need the start sequence to test the condition - err = cli.ContainerStart(ctx, ctrCreate.ID, types.ContainerStartOptions{}) + err = cli.ContainerStart(ctx, ctrCreate.ID, containertypes.StartOptions{}) assert.NilError(t, err) // Check that host-located bind mount network file did not change ownership when the container was started @@ -192,7 +191,7 @@ func TestMountDaemonRoot(t *testing.T) { } defer func() { - if err := apiClient.ContainerRemove(ctx, c.ID, types.ContainerRemoveOptions{Force: true}); err != nil { + if err := apiClient.ContainerRemove(ctx, c.ID, containertypes.RemoveOptions{Force: true}); err != nil { panic(err) } }() diff --git a/integration/container/nat_test.go b/integration/container/nat_test.go index 492fe75ead..9506430dd3 100644 --- a/integration/container/nat_test.go +++ b/integration/container/nat_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/integration/internal/container" "github.com/docker/go-connections/nat" "gotest.tools/v3/assert" @@ -77,7 +77,7 @@ func TestNetworkLoopbackNat(t *testing.T) { poll.WaitOn(t, container.IsStopped(ctx, apiClient, cID), poll.WithDelay(100*time.Millisecond)) - body, err := apiClient.ContainerLogs(ctx, cID, types.ContainerLogsOptions{ + body, err := apiClient.ContainerLogs(ctx, cID, containertypes.LogsOptions{ ShowStdout: true, }) assert.NilError(t, err) diff --git a/integration/container/pidmode_linux_test.go b/integration/container/pidmode_linux_test.go index 728ac1969d..ba0182da8c 100644 --- a/integration/container/pidmode_linux_test.go +++ b/integration/container/pidmode_linux_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/errdefs" "github.com/docker/docker/integration/internal/container" "gotest.tools/v3/assert" @@ -50,7 +50,7 @@ func TestPIDModeContainer(t *testing.T) { ctr, err := container.CreateFromConfig(ctx, apiClient, container.NewTestConfig(container.WithPIDMode("container:"+pidCtrName))) assert.NilError(t, err, "should not produce an error when creating, only when starting") - err = apiClient.ContainerStart(ctx, ctr.ID, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(ctx, ctr.ID, containertypes.StartOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsSystem), "should produce a System error when starting an existing container from an invalid state") assert.Check(t, is.ErrorContains(err, "failed to join PID namespace")) assert.Check(t, is.ErrorContains(err, cPIDContainerID+" is not running")) @@ -63,7 +63,7 @@ func TestPIDModeContainer(t *testing.T) { ctr, err := container.CreateFromConfig(ctx, apiClient, container.NewTestConfig(container.WithPIDMode("container:"+pidCtrName))) assert.NilError(t, err) - err = apiClient.ContainerStart(ctx, ctr.ID, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(ctx, ctr.ID, containertypes.StartOptions{}) assert.Check(t, err) }) } diff --git a/integration/container/ps_test.go b/integration/container/ps_test.go index 048e541a2b..d452ba2665 100644 --- a/integration/container/ps_test.go +++ b/integration/container/ps_test.go @@ -4,6 +4,7 @@ import ( "testing" "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/integration/internal/container" "github.com/docker/docker/testutil" @@ -29,7 +30,7 @@ func TestPsFilter(t *testing.T) { t.Run("since", func(t *testing.T) { ctx := testutil.StartSpan(ctx, t) - results, err := apiClient.ContainerList(ctx, types.ContainerListOptions{ + results, err := apiClient.ContainerList(ctx, containertypes.ListOptions{ All: true, Filters: filters.NewArgs(filters.Arg("since", top)), }) @@ -39,7 +40,7 @@ func TestPsFilter(t *testing.T) { t.Run("before", func(t *testing.T) { ctx := testutil.StartSpan(ctx, t) - results, err := apiClient.ContainerList(ctx, types.ContainerListOptions{ + results, err := apiClient.ContainerList(ctx, containertypes.ListOptions{ All: true, Filters: filters.NewArgs(filters.Arg("before", top)), }) diff --git a/integration/container/remove_test.go b/integration/container/remove_test.go index e6bcf90c4d..519e7b5ab2 100644 --- a/integration/container/remove_test.go +++ b/integration/container/remove_test.go @@ -5,7 +5,7 @@ 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/volume" "github.com/docker/docker/errdefs" @@ -42,7 +42,7 @@ func TestRemoveContainerWithRemovedVolume(t *testing.T) { err := os.RemoveAll(tempDir.Path()) assert.NilError(t, err) - err = apiClient.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{ + err = apiClient.ContainerRemove(ctx, cID, containertypes.RemoveOptions{ RemoveVolumes: true, }) assert.NilError(t, err) @@ -67,7 +67,7 @@ func TestRemoveContainerWithVolume(t *testing.T) { assert.Check(t, is.Equal(1, len(insp.Mounts))) volName := insp.Mounts[0].Name - err = apiClient.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{ + err = apiClient.ContainerRemove(ctx, cID, containertypes.RemoveOptions{ RemoveVolumes: true, }) assert.NilError(t, err) @@ -85,7 +85,7 @@ func TestRemoveContainerRunning(t *testing.T) { cID := container.Run(ctx, t, apiClient) - err := apiClient.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{}) + err := apiClient.ContainerRemove(ctx, cID, containertypes.RemoveOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsConflict)) assert.Check(t, is.ErrorContains(err, "container is running")) } @@ -96,7 +96,7 @@ func TestRemoveContainerForceRemoveRunning(t *testing.T) { cID := container.Run(ctx, t, apiClient) - err := apiClient.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{ + err := apiClient.ContainerRemove(ctx, cID, containertypes.RemoveOptions{ Force: true, }) assert.NilError(t, err) @@ -106,7 +106,7 @@ func TestRemoveInvalidContainer(t *testing.T) { ctx := setupTest(t) apiClient := testEnv.APIClient() - err := apiClient.ContainerRemove(ctx, "unknown", types.ContainerRemoveOptions{}) + err := apiClient.ContainerRemove(ctx, "unknown", containertypes.RemoveOptions{}) assert.Check(t, is.ErrorType(err, errdefs.IsNotFound)) assert.Check(t, is.ErrorContains(err, "No such container")) } diff --git a/integration/container/rename_test.go b/integration/container/rename_test.go index 5345dc6d8e..93a1e864bc 100644 --- a/integration/container/rename_test.go +++ b/integration/container/rename_test.go @@ -36,7 +36,7 @@ func TestRenameLinkedContainer(t *testing.T) { container.Run(ctx, t, apiClient, container.WithName(aName)) - err = apiClient.ContainerRemove(ctx, bID, types.ContainerRemoveOptions{Force: true}) + err = apiClient.ContainerRemove(ctx, bID, containertypes.RemoveOptions{Force: true}) assert.NilError(t, err) bID = container.Run(ctx, t, apiClient, container.WithName(bName), container.WithLinks(aName)) @@ -135,7 +135,7 @@ func TestRenameAnonymousContainer(t *testing.T) { // FIXME(vdemeester) this is a really weird behavior as it fails otherwise err = apiClient.ContainerStop(ctx, container1Name, containertypes.StopOptions{}) assert.NilError(t, err) - err = apiClient.ContainerStart(ctx, container1Name, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(ctx, container1Name, containertypes.StartOptions{}) assert.NilError(t, err) count := "-c" diff --git a/integration/container/resize_test.go b/integration/container/resize_test.go index 6823b3dba1..7cde6e24cd 100644 --- a/integration/container/resize_test.go +++ b/integration/container/resize_test.go @@ -4,7 +4,7 @@ import ( "net/http" "testing" - "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/versions" "github.com/docker/docker/errdefs" "github.com/docker/docker/integration/internal/container" @@ -20,7 +20,7 @@ func TestResize(t *testing.T) { t.Run("success", func(t *testing.T) { cID := container.Run(ctx, t, apiClient, container.WithTty(true)) - err := apiClient.ContainerResize(ctx, cID, types.ResizeOptions{ + err := apiClient.ContainerResize(ctx, cID, containertypes.ResizeOptions{ Height: 40, Width: 40, }) @@ -46,7 +46,7 @@ func TestResize(t *testing.T) { t.Run("invalid state", func(t *testing.T) { cID := container.Create(ctx, t, apiClient, container.WithCmd("echo")) - err := apiClient.ContainerResize(ctx, cID, types.ResizeOptions{ + err := apiClient.ContainerResize(ctx, cID, containertypes.ResizeOptions{ Height: 40, Width: 40, }) diff --git a/integration/container/restart_test.go b/integration/container/restart_test.go index c3324c3f2e..56695a0e75 100644 --- a/integration/container/restart_test.go +++ b/integration/container/restart_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" testContainer "github.com/docker/docker/integration/internal/container" @@ -102,10 +101,10 @@ func TestDaemonRestartKillContainers(t *testing.T) { resp, err := apiClient.ContainerCreate(ctx, tc.config, tc.hostConfig, nil, nil, "") assert.NilError(t, err) - defer apiClient.ContainerRemove(ctx, resp.ID, types.ContainerRemoveOptions{Force: true}) + defer apiClient.ContainerRemove(ctx, resp.ID, container.RemoveOptions{Force: true}) if tc.xStart { - err = apiClient.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(ctx, resp.ID, container.StartOptions{}) assert.NilError(t, err) } @@ -192,7 +191,7 @@ func TestContainerWithAutoRemoveCanBeRestarted(t *testing.T) { testContainer.WithAutoRemove, ) defer func() { - err := apiClient.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true}) + err := apiClient.ContainerRemove(ctx, cID, container.RemoveOptions{Force: true}) if t.Failed() && err != nil { t.Logf("Cleaning up test container failed with error: %v", err) } diff --git a/integration/container/run_linux_test.go b/integration/container/run_linux_test.go index 89308d816a..aedd8ef284 100644 --- a/integration/container/run_linux_test.go +++ b/integration/container/run_linux_test.go @@ -10,7 +10,6 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration/internal/container" @@ -191,7 +190,7 @@ func TestRunConsoleSize(t *testing.T) { poll.WaitOn(t, container.IsStopped(ctx, apiClient, cID), poll.WithDelay(100*time.Millisecond)) - out, err := apiClient.ContainerLogs(ctx, cID, types.ContainerLogsOptions{ShowStdout: true}) + out, err := apiClient.ContainerLogs(ctx, cID, containertypes.LogsOptions{ShowStdout: true}) assert.NilError(t, err) defer out.Close() @@ -246,7 +245,7 @@ func TestRunWithAlternativeContainerdShim(t *testing.T) { poll.WaitOn(t, container.IsStopped(ctx, apiClient, cID), poll.WithDelay(100*time.Millisecond)) - out, err := apiClient.ContainerLogs(ctx, cID, types.ContainerLogsOptions{ShowStdout: true}) + out, err := apiClient.ContainerLogs(ctx, cID, containertypes.LogsOptions{ShowStdout: true}) assert.NilError(t, err) defer out.Close() @@ -266,7 +265,7 @@ func TestRunWithAlternativeContainerdShim(t *testing.T) { poll.WaitOn(t, container.IsStopped(ctx, apiClient, cID), poll.WithDelay(100*time.Millisecond)) - out, err = apiClient.ContainerLogs(ctx, cID, types.ContainerLogsOptions{ShowStdout: true}) + out, err = apiClient.ContainerLogs(ctx, cID, containertypes.LogsOptions{ShowStdout: true}) assert.NilError(t, err) defer out.Close() @@ -297,7 +296,7 @@ func TestMacAddressIsAppliedToMainNetworkWithShortID(t *testing.T) { container.WithStopSignal("SIGKILL"), container.WithNetworkMode(n[:10]), container.WithMacAddress("02:42:08:26:a9:55")) - defer container.Remove(ctx, t, apiClient, cid, types.ContainerRemoveOptions{Force: true}) + defer container.Remove(ctx, t, apiClient, cid, containertypes.RemoveOptions{Force: true}) c := container.Inspect(ctx, t, apiClient, cid) assert.Equal(t, c.NetworkSettings.Networks["testnet"].MacAddress, "02:42:08:26:a9:55") diff --git a/integration/container/stop_linux_test.go b/integration/container/stop_linux_test.go index e5a0a7320f..fa7338da81 100644 --- a/integration/container/stop_linux_test.go +++ b/integration/container/stop_linux_test.go @@ -9,7 +9,6 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" "github.com/docker/docker/errdefs" @@ -128,7 +127,7 @@ func TestStopContainerWithTimeoutCancel(t *testing.T) { // logsContains verifies the container contains the given text in the log's stdout. func logsContains(ctx context.Context, client client.APIClient, containerID string, logString string) func(log poll.LogT) poll.Result { return func(log poll.LogT) poll.Result { - logs, err := client.ContainerLogs(ctx, containerID, types.ContainerLogsOptions{ + logs, err := client.ContainerLogs(ctx, containerID, containertypes.LogsOptions{ ShowStdout: true, }) if err != nil { diff --git a/integration/container/wait_test.go b/integration/container/wait_test.go index faf7ea51bb..f530549e1d 100644 --- a/integration/container/wait_test.go +++ b/integration/container/wait_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/testutil" @@ -145,11 +144,11 @@ func TestWaitConditions(t *testing.T) { containerID := container.Create(ctx, t, cli, opts...) t.Logf("ContainerID = %v", containerID) - streams, err := cli.ContainerAttach(ctx, containerID, types.ContainerAttachOptions{Stream: true, Stdin: true}) + streams, err := cli.ContainerAttach(ctx, containerID, containertypes.AttachOptions{Stream: true, Stdin: true}) assert.NilError(t, err) defer streams.Close() - assert.NilError(t, cli.ContainerStart(ctx, containerID, types.ContainerStartOptions{})) + assert.NilError(t, cli.ContainerStart(ctx, containerID, containertypes.StartOptions{})) waitResC, errC := cli.ContainerWait(ctx, containerID, tc.waitCond) select { case err := <-errC: @@ -210,7 +209,7 @@ func TestWaitRestartedContainer(t *testing.T) { containerID := container.Run(ctx, t, cli, container.WithCmd("sh", "-c", "trap 'exit 5' SIGTERM; while true; do sleep 0.1; done"), ) - defer cli.ContainerRemove(ctx, containerID, types.ContainerRemoveOptions{Force: true}) + defer cli.ContainerRemove(ctx, containerID, containertypes.RemoveOptions{Force: true}) // Container is running now, wait for exit waitResC, errC := cli.ContainerWait(ctx, containerID, tc.waitCond) diff --git a/integration/daemon/daemon_test.go b/integration/daemon/daemon_test.go index 394d75c87c..0db0193bfc 100644 --- a/integration/daemon/daemon_test.go +++ b/integration/daemon/daemon_test.go @@ -410,7 +410,7 @@ func testLiveRestoreVolumeReferences(t *testing.T) { Target: "/foo", } cID := container.Run(ctx, t, c, container.WithMount(m), container.WithCmd("top"), container.WithRestartPolicy(policy)) - defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, cID, containertypes.RemoveOptions{Force: true}) // Stop the daemon d.Restart(t, "--live-restore", "--iptables=false") @@ -452,7 +452,7 @@ func testLiveRestoreVolumeReferences(t *testing.T) { const testContent = "hello" cID := container.Run(ctx, t, c, container.WithMount(m), container.WithCmd("sh", "-c", "echo "+testContent+">>/foo/test.txt; sleep infinity")) - defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, cID, containertypes.RemoveOptions{Force: true}) // Wait until container creates a file in the volume. poll.WaitOn(t, func(t poll.LogT) poll.Result { @@ -484,7 +484,7 @@ func testLiveRestoreVolumeReferences(t *testing.T) { // Check if a new container with the same volume has access to the previous content. // This fails if the volume gets unmounted at startup. cID2 := container.Run(ctx, t, c, container.WithMount(m), container.WithCmd("cat", "/foo/test.txt")) - defer c.ContainerRemove(ctx, cID2, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, cID2, containertypes.RemoveOptions{Force: true}) poll.WaitOn(t, container.IsStopped(ctx, c, cID2)) @@ -493,7 +493,7 @@ func testLiveRestoreVolumeReferences(t *testing.T) { assert.Check(t, is.Equal(inspect.State.ExitCode, 0), "volume doesn't have the same file") } - logs, err := c.ContainerLogs(ctx, cID2, types.ContainerLogsOptions{ShowStdout: true}) + logs, err := c.ContainerLogs(ctx, cID2, containertypes.LogsOptions{ShowStdout: true}) assert.NilError(t, err) defer logs.Close() @@ -505,7 +505,7 @@ func testLiveRestoreVolumeReferences(t *testing.T) { }) // Remove that container which should free the references in the volume - err = c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true}) + err = c.ContainerRemove(ctx, cID, containertypes.RemoveOptions{Force: true}) assert.NilError(t, err) // Now we should be able to remove the volume @@ -524,11 +524,11 @@ func testLiveRestoreVolumeReferences(t *testing.T) { Target: "/foo", } cID := container.Run(ctx, t, c, container.WithMount(m), container.WithCmd("top")) - defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, cID, containertypes.RemoveOptions{Force: true}) d.Restart(t, "--live-restore", "--iptables=false") - err := c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true}) + err := c.ContainerRemove(ctx, cID, containertypes.RemoveOptions{Force: true}) assert.NilError(t, err) }) } diff --git a/integration/image/commit_test.go b/integration/image/commit_test.go index 08cd1cf2f2..1852a72c30 100644 --- a/integration/image/commit_test.go +++ b/integration/image/commit_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration/internal/container" "gotest.tools/v3/assert" @@ -22,7 +22,7 @@ func TestCommitInheritsEnv(t *testing.T) { cID1 := container.Create(ctx, t, client) imgName := strings.ToLower(t.Name()) - commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{ + commitResp1, err := client.ContainerCommit(ctx, cID1, containertypes.CommitOptions{ Changes: []string{"ENV PATH=/bin"}, Reference: imgName, }) @@ -36,7 +36,7 @@ func TestCommitInheritsEnv(t *testing.T) { cID2 := container.Create(ctx, t, client, container.WithImage(image1.ID)) - commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{ + commitResp2, err := client.ContainerCommit(ctx, cID2, containertypes.CommitOptions{ Changes: []string{"ENV PATH=/usr/bin:$PATH"}, Reference: imgName, }) diff --git a/integration/image/list_test.go b/integration/image/list_test.go index caabd809bf..2d6fd4973f 100644 --- a/integration/image/list_test.go +++ b/integration/image/list_test.go @@ -7,6 +7,7 @@ import ( "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/versions" "github.com/docker/docker/integration/internal/container" @@ -70,7 +71,7 @@ func TestImagesFilterBeforeSince(t *testing.T) { // Make really really sure each image has a distinct timestamp. time.Sleep(time.Millisecond) } - id, err := client.ContainerCommit(ctx, ctr, types.ContainerCommitOptions{Reference: fmt.Sprintf("%s:v%d", name, i)}) + id, err := client.ContainerCommit(ctx, ctr, containertypes.CommitOptions{Reference: fmt.Sprintf("%s:v%d", name, i)}) assert.NilError(t, err) imgs[i] = id.ID } diff --git a/integration/image/remove_test.go b/integration/image/remove_test.go index a655e175fd..a029ff6c4c 100644 --- a/integration/image/remove_test.go +++ b/integration/image/remove_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/errdefs" "github.com/docker/docker/integration/internal/container" "gotest.tools/v3/assert" @@ -21,7 +22,7 @@ func TestRemoveImageOrphaning(t *testing.T) { // Create a container from busybox, and commit a small change so we have a new image cID1 := container.Create(ctx, t, client, container.WithCmd("")) - commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{ + commitResp1, err := client.ContainerCommit(ctx, cID1, containertypes.CommitOptions{ Changes: []string{`ENTRYPOINT ["true"]`}, Reference: imgName, }) @@ -34,7 +35,7 @@ func TestRemoveImageOrphaning(t *testing.T) { // Create a container from created image, and commit a small change with same reference name cID2 := container.Create(ctx, t, client, container.WithImage(imgName), container.WithCmd("")) - commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{ + commitResp2, err := client.ContainerCommit(ctx, cID2, containertypes.CommitOptions{ Changes: []string{`LABEL Maintainer="Integration Tests"`}, Reference: imgName, }) diff --git a/integration/image/save_test.go b/integration/image/save_test.go index 2e75f2078e..da506ee02e 100644 --- a/integration/image/save_test.go +++ b/integration/image/save_test.go @@ -16,7 +16,7 @@ import ( "github.com/cpuguy83/tar2go" "github.com/docker/docker/api/types" - containerapi "github.com/docker/docker/api/types/container" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/integration/internal/build" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/pkg/archive" @@ -91,7 +91,7 @@ func TestSaveRepoWithMultipleImages(t *testing.T) { cfg.Config.Cmd = []string{"true"} }) - chW, chErr := client.ContainerWait(ctx, id, containerapi.WaitConditionNotRunning) + chW, chErr := client.ContainerWait(ctx, id, containertypes.WaitConditionNotRunning) ctx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() @@ -104,10 +104,10 @@ func TestSaveRepoWithMultipleImages(t *testing.T) { t.Fatal("timeout waiting for container to exit") } - res, err := client.ContainerCommit(ctx, id, types.ContainerCommitOptions{Reference: tag}) + res, err := client.ContainerCommit(ctx, id, containertypes.CommitOptions{Reference: tag}) assert.NilError(t, err) - err = client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{Force: true}) + err = client.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true}) assert.NilError(t, err) return res.ID diff --git a/integration/internal/container/container.go b/integration/internal/container/container.go index 2eb04ef0ae..0974ce6bf1 100644 --- a/integration/internal/container/container.go +++ b/integration/internal/container/container.go @@ -77,7 +77,7 @@ func Run(ctx context.Context, t *testing.T, apiClient client.APIClient, ops ...f t.Helper() id := Create(ctx, t, apiClient, ops...) - err := apiClient.ContainerStart(ctx, id, types.ContainerStartOptions{}) + err := apiClient.ContainerStart(ctx, id, container.StartOptions{}) assert.NilError(t, err) return id @@ -99,14 +99,14 @@ func RunAttach(ctx context.Context, t *testing.T, apiClient client.APIClient, op }) id := Create(ctx, t, apiClient, ops...) - aresp, err := apiClient.ContainerAttach(ctx, id, types.ContainerAttachOptions{ + aresp, err := apiClient.ContainerAttach(ctx, id, container.AttachOptions{ Stream: true, Stdout: true, Stderr: true, }) assert.NilError(t, err) - err = apiClient.ContainerStart(ctx, id, types.ContainerStartOptions{}) + err = apiClient.ContainerStart(ctx, id, container.StartOptions{}) assert.NilError(t, err) s, err := demultiplexStreams(ctx, aresp) @@ -155,7 +155,7 @@ func demultiplexStreams(ctx context.Context, resp types.HijackedResponse) (strea return s, err } -func Remove(ctx context.Context, t *testing.T, apiClient client.APIClient, container string, options types.ContainerRemoveOptions) { +func Remove(ctx context.Context, t *testing.T, apiClient client.APIClient, container string, options container.RemoveOptions) { t.Helper() err := apiClient.ContainerRemove(ctx, container, options) diff --git a/integration/network/dns_test.go b/integration/network/dns_test.go index ac3b13b493..1231051e7b 100644 --- a/integration/network/dns_test.go +++ b/integration/network/dns_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/network" "github.com/docker/docker/testutil" @@ -29,7 +29,7 @@ func TestDaemonDNSFallback(t *testing.T) { defer c.NetworkRemove(ctx, "test") cid := container.Run(ctx, t, c, container.WithNetworkMode("test"), container.WithCmd("nslookup", "docker.com")) - defer c.ContainerRemove(ctx, cid, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, cid, containertypes.RemoveOptions{Force: true}) poll.WaitOn(t, container.IsSuccessful(ctx, c, cid), poll.WithDelay(100*time.Millisecond), poll.WithTimeout(10*time.Second)) } diff --git a/integration/network/network_test.go b/integration/network/network_test.go index 4e6687d4df..154c08d931 100644 --- a/integration/network/network_test.go +++ b/integration/network/network_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" ntypes "github.com/docker/docker/api/types/network" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/network" @@ -37,14 +38,14 @@ func TestRunContainerWithBridgeNone(t *testing.T) { c := d.NewClientT(t) id1 := container.Run(ctx, t, c) - defer c.ContainerRemove(ctx, id1, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, id1, containertypes.RemoveOptions{Force: true}) result, err := container.Exec(ctx, c, id1, []string{"ip", "l"}) assert.NilError(t, err) assert.Check(t, is.Equal(false, strings.Contains(result.Combined(), "eth0")), "There shouldn't be eth0 in container in default(bridge) mode when bridge network is disabled") id2 := container.Run(ctx, t, c, container.WithNetworkMode("bridge")) - defer c.ContainerRemove(ctx, id2, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, id2, containertypes.RemoveOptions{Force: true}) result, err = container.Exec(ctx, c, id2, []string{"ip", "l"}) assert.NilError(t, err) @@ -58,7 +59,7 @@ func TestRunContainerWithBridgeNone(t *testing.T) { assert.NilError(t, err, "Failed to get current process network namespace: %+v", err) id3 := container.Run(ctx, t, c, container.WithNetworkMode("host")) - defer c.ContainerRemove(ctx, id3, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, id3, containertypes.RemoveOptions{Force: true}) result, err = container.Exec(ctx, c, id3, []string{"sh", "-c", nsCommand}) assert.NilError(t, err) @@ -250,7 +251,7 @@ func TestDefaultNetworkOpts(t *testing.T) { // Start a container to inspect the MTU of its network interface id1 := container.Run(ctx, t, c, container.WithNetworkMode(networkName)) - defer c.ContainerRemove(ctx, id1, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, id1, containertypes.RemoveOptions{Force: true}) result, err := container.Exec(ctx, c, id1, []string{"ip", "l", "show", "eth0"}) assert.NilError(t, err) diff --git a/integration/plugin/authz/authz_plugin_test.go b/integration/plugin/authz/authz_plugin_test.go index 6bf5135199..bfedc0606a 100644 --- a/integration/plugin/authz/authz_plugin_test.go +++ b/integration/plugin/authz/authz_plugin_test.go @@ -18,6 +18,7 @@ import ( "time" "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/client" "github.com/docker/docker/integration/internal/container" @@ -387,7 +388,7 @@ func TestAuthzPluginEnsureContainerCopyToFrom(t *testing.T) { c := d.NewClientT(t) cID := container.Run(ctx, t, c) - defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, cID, containertypes.RemoveOptions{Force: true}) _, err = f.Seek(0, io.SeekStart) assert.NilError(t, err) diff --git a/integration/plugin/graphdriver/external_test.go b/integration/plugin/graphdriver/external_test.go index 5d56555510..1c74f123de 100644 --- a/integration/plugin/graphdriver/external_test.go +++ b/integration/plugin/graphdriver/external_test.go @@ -461,7 +461,7 @@ func testGraphDriver(ctx context.Context, t *testing.T, c client.APIClient, driv Path: "/hello", }), "diffs: %v", diffs) - err = c.ContainerRemove(ctx, id, types.ContainerRemoveOptions{ + err = c.ContainerRemove(ctx, id, containertypes.RemoveOptions{ Force: true, }) assert.NilError(t, err) diff --git a/integration/plugin/logging/logging_linux_test.go b/integration/plugin/logging/logging_linux_test.go index c0b2995db4..49a27c51c2 100644 --- a/integration/plugin/logging/logging_linux_test.go +++ b/integration/plugin/logging/logging_linux_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/testutil" "github.com/docker/docker/testutil/daemon" @@ -46,10 +47,10 @@ func TestContinueAfterPluginCrash(t *testing.T) { ), ) cancel() - defer client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{Force: true}) + defer client.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true}) // Attach to the container to make sure it's written a few times to stdout - attach, err := client.ContainerAttach(ctx, id, types.ContainerAttachOptions{Stream: true, Stdout: true}) + attach, err := client.ContainerAttach(ctx, id, containertypes.AttachOptions{Stream: true, Stdout: true}) assert.NilError(t, err) chErr := make(chan error, 1) diff --git a/integration/plugin/logging/read_test.go b/integration/plugin/logging/read_test.go index a80c4634de..cb88e6c056 100644 --- a/integration/plugin/logging/read_test.go +++ b/integration/plugin/logging/read_test.go @@ -60,12 +60,12 @@ func TestReadPluginNoRead(t *testing.T) { "", ) assert.Assert(t, err) - defer client.ContainerRemove(ctx, c.ID, types.ContainerRemoveOptions{Force: true}) + defer client.ContainerRemove(ctx, c.ID, container.RemoveOptions{Force: true}) - err = client.ContainerStart(ctx, c.ID, types.ContainerStartOptions{}) + err = client.ContainerStart(ctx, c.ID, container.StartOptions{}) assert.Assert(t, err) - logs, err := client.ContainerLogs(ctx, c.ID, types.ContainerLogsOptions{ShowStdout: true}) + logs, err := client.ContainerLogs(ctx, c.ID, container.LogsOptions{ShowStdout: true}) if !test.logsSupported { assert.Assert(t, err != nil) return diff --git a/integration/service/create_test.go b/integration/service/create_test.go index 877dbb0284..caeecf3f85 100644 --- a/integration/service/create_test.go +++ b/integration/service/create_test.go @@ -8,6 +8,7 @@ import ( "time" "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/strslice" swarmtypes "github.com/docker/docker/api/types/swarm" @@ -66,7 +67,7 @@ func testServiceCreateInit(ctx context.Context, daemonEnabled bool) func(t *test func inspectServiceContainer(ctx context.Context, t *testing.T, client client.APIClient, serviceID string) types.ContainerJSON { t.Helper() - containers, err := client.ContainerList(ctx, types.ContainerListOptions{ + containers, err := client.ContainerList(ctx, container.ListOptions{ Filters: filters.NewArgs(filters.Arg("label", "com.docker.swarm.service.id="+serviceID)), }) assert.NilError(t, err) @@ -230,7 +231,7 @@ func TestCreateServiceSecretFileMode(t *testing.T) { poll.WaitOn(t, swarm.RunningTasksCount(ctx, client, serviceID, instances), swarm.ServicePoll) - body, err := client.ServiceLogs(ctx, serviceID, types.ContainerLogsOptions{ + body, err := client.ServiceLogs(ctx, serviceID, container.LogsOptions{ Tail: "1", ShowStdout: true, }) @@ -287,7 +288,7 @@ func TestCreateServiceConfigFileMode(t *testing.T) { poll.WaitOn(t, swarm.RunningTasksCount(ctx, client, serviceID, instances)) - body, err := client.ServiceLogs(ctx, serviceID, types.ContainerLogsOptions{ + body, err := client.ServiceLogs(ctx, serviceID, container.LogsOptions{ Tail: "1", ShowStdout: true, }) diff --git a/integration/service/network_test.go b/integration/service/network_test.go index c3e407967c..d1fb6372f0 100644 --- a/integration/service/network_test.go +++ b/integration/service/network_test.go @@ -3,7 +3,7 @@ package service // import "github.com/docker/docker/integration/service" import ( "testing" - "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" "github.com/docker/docker/integration/internal/container" net "github.com/docker/docker/integration/internal/network" @@ -43,7 +43,7 @@ func TestDockerNetworkConnectAlias(t *testing.T) { }) assert.NilError(t, err) - err = client.ContainerStart(ctx, cID1, types.ContainerStartOptions{}) + err = client.ContainerStart(ctx, cID1, containertypes.StartOptions{}) assert.NilError(t, err) ng1, err := client.ContainerInspect(ctx, cID1) @@ -66,7 +66,7 @@ func TestDockerNetworkConnectAlias(t *testing.T) { }) assert.NilError(t, err) - err = client.ContainerStart(ctx, cID2, types.ContainerStartOptions{}) + err = client.ContainerStart(ctx, cID2, containertypes.StartOptions{}) assert.NilError(t, err) ng2, err := client.ContainerInspect(ctx, cID2) @@ -101,7 +101,7 @@ func TestDockerNetworkReConnect(t *testing.T) { err := client.NetworkConnect(ctx, name, c1, &network.EndpointSettings{}) assert.NilError(t, err) - err = client.ContainerStart(ctx, c1, types.ContainerStartOptions{}) + err = client.ContainerStart(ctx, c1, containertypes.StartOptions{}) assert.NilError(t, err) n1, err := client.ContainerInspect(ctx, c1) diff --git a/integration/system/cgroupdriver_systemd_test.go b/integration/system/cgroupdriver_systemd_test.go index c011e9f1d6..98eef0dbc0 100644 --- a/integration/system/cgroupdriver_systemd_test.go +++ b/integration/system/cgroupdriver_systemd_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/testutil" "github.com/docker/docker/testutil/daemon" @@ -45,9 +45,9 @@ func TestCgroupDriverSystemdMemoryLimit(t *testing.T) { ctrID := container.Create(ctx, t, c, func(ctr *container.TestContainerConfig) { ctr.HostConfig.Resources.Memory = mem }) - defer c.ContainerRemove(ctx, ctrID, types.ContainerRemoveOptions{Force: true}) + defer c.ContainerRemove(ctx, ctrID, containertypes.RemoveOptions{Force: true}) - err := c.ContainerStart(ctx, ctrID, types.ContainerStartOptions{}) + err := c.ContainerStart(ctx, ctrID, containertypes.StartOptions{}) assert.NilError(t, err) s, err := c.ContainerInspect(ctx, ctrID) diff --git a/integration/system/disk_usage_test.go b/integration/system/disk_usage_test.go index 8a4f9a460b..9aafe167fa 100644 --- a/integration/system/disk_usage_test.go +++ b/integration/system/disk_usage_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/volume" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/testutil" @@ -36,7 +37,7 @@ func TestDiskUsage(t *testing.T) { du, err := client.DiskUsage(ctx, types.DiskUsageOptions{}) assert.NilError(t, err) assert.DeepEqual(t, du, types.DiskUsage{ - Images: []*types.ImageSummary{}, + Images: []*image.Summary{}, Containers: []*types.Container{}, Volumes: []*volume.Volume{}, BuildCache: []*types.BuildCache{}, @@ -55,7 +56,7 @@ func TestDiskUsage(t *testing.T) { assert.Equal(t, len(du.Images), 1) assert.DeepEqual(t, du, types.DiskUsage{ LayersSize: du.LayersSize, - Images: []*types.ImageSummary{ + Images: []*image.Summary{ { Created: du.Images[0].Created, ID: du.Images[0].ID, @@ -83,8 +84,8 @@ func TestDiskUsage(t *testing.T) { assert.Assert(t, du.Containers[0].Created >= prev.Images[0].Created) assert.DeepEqual(t, du, types.DiskUsage{ LayersSize: prev.LayersSize, - Images: []*types.ImageSummary{ - func() *types.ImageSummary { + Images: []*image.Summary{ + func() *image.Summary { sum := *prev.Images[0] sum.Containers++ return &sum diff --git a/integration/volume/volume_test.go b/integration/volume/volume_test.go index 6de70e3f26..da0b065178 100644 --- a/integration/volume/volume_test.go +++ b/integration/volume/volume_test.go @@ -8,7 +8,7 @@ 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/volume" clientpkg "github.com/docker/docker/client" @@ -84,7 +84,7 @@ func TestVolumesRemove(t *testing.T) { }) t.Run("volume not in use", func(t *testing.T) { - err = client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{ + err = client.ContainerRemove(ctx, id, containertypes.RemoveOptions{ Force: true, }) assert.NilError(t, err) @@ -135,7 +135,7 @@ func TestVolumesRemoveSwarmEnabled(t *testing.T) { }) t.Run("volume not in use", func(t *testing.T) { - err = client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{ + err = client.ContainerRemove(ctx, id, containertypes.RemoveOptions{ Force: true, }) assert.NilError(t, err) @@ -321,7 +321,7 @@ VOLUME ` + volDest img := build.Do(ctx, t, client, fakecontext.New(t, "", fakecontext.WithDockerfile(dockerfile))) id := container.Create(ctx, t, client, container.WithImage(img)) - defer client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{}) + defer client.ContainerRemove(ctx, id, containertypes.RemoveOptions{}) inspect, err := client.ContainerInspect(ctx, id) assert.NilError(t, err) @@ -331,7 +331,7 @@ VOLUME ` + volDest volumeName := inspect.Mounts[0].Name assert.Assert(t, volumeName != "") - err = client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{}) + err = client.ContainerRemove(ctx, id, containertypes.RemoveOptions{}) assert.NilError(t, err) pruneReport, err := client.VolumesPrune(ctx, filters.Args{}) diff --git a/testutil/daemon/container.go b/testutil/daemon/container.go index 42dafe7f5c..3dccfc5898 100644 --- a/testutil/daemon/container.go +++ b/testutil/daemon/container.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "gotest.tools/v3/assert" ) @@ -14,7 +14,7 @@ func (d *Daemon) ActiveContainers(ctx context.Context, t testing.TB) []string { cli := d.NewClientT(t) defer cli.Close() - containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{}) + containers, err := cli.ContainerList(context.Background(), container.ListOptions{}) assert.NilError(t, err) ids := make([]string, len(containers)) diff --git a/testutil/environment/clean.go b/testutil/environment/clean.go index 8e591ba05e..a545d31400 100644 --- a/testutil/environment/clean.go +++ b/testutil/environment/clean.go @@ -7,6 +7,7 @@ import ( "testing" "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/volume" "github.com/docker/docker/client" @@ -43,16 +44,16 @@ func unpauseAllContainers(ctx context.Context, t testing.TB, client client.Conta t.Helper() containers := getPausedContainers(ctx, t, client) if len(containers) > 0 { - for _, container := range containers { - err := client.ContainerUnpause(ctx, container.ID) - assert.Check(t, err, "failed to unpause container %s", container.ID) + for _, ctr := range containers { + err := client.ContainerUnpause(ctx, ctr.ID) + assert.Check(t, err, "failed to unpause container %s", ctr.ID) } } } func getPausedContainers(ctx context.Context, t testing.TB, client client.ContainerAPIClient) []types.Container { t.Helper() - containers, err := client.ContainerList(ctx, types.ContainerListOptions{ + containers, err := client.ContainerList(ctx, container.ListOptions{ Filters: filters.NewArgs(filters.Arg("status", "paused")), All: true, }) @@ -69,24 +70,24 @@ func deleteAllContainers(ctx context.Context, t testing.TB, apiclient client.Con return } - for _, container := range containers { - if _, ok := protectedContainers[container.ID]; ok { + for _, ctr := range containers { + if _, ok := protectedContainers[ctr.ID]; ok { continue } - err := apiclient.ContainerRemove(ctx, container.ID, types.ContainerRemoveOptions{ + err := apiclient.ContainerRemove(ctx, ctr.ID, container.RemoveOptions{ Force: true, RemoveVolumes: true, }) if err == nil || errdefs.IsNotFound(err) || alreadyExists.MatchString(err.Error()) || isErrNotFoundSwarmClassic(err) { continue } - assert.Check(t, err, "failed to remove %s", container.ID) + assert.Check(t, err, "failed to remove %s", ctr.ID) } } func getAllContainers(ctx context.Context, t testing.TB, client client.ContainerAPIClient) []types.Container { t.Helper() - containers, err := client.ContainerList(ctx, types.ContainerListOptions{ + containers, err := client.ContainerList(ctx, container.ListOptions{ All: true, }) assert.Check(t, err, "failed to list containers") diff --git a/testutil/environment/protect.go b/testutil/environment/protect.go index 4ea745ceec..aa60361fd9 100644 --- a/testutil/environment/protect.go +++ b/testutil/environment/protect.go @@ -5,7 +5,9 @@ import ( "testing" "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/volume" "github.com/docker/docker/errdefs" "go.opentelemetry.io/otel" @@ -69,7 +71,7 @@ func ProtectContainers(ctx context.Context, t testing.TB, testEnv *Execution) { func getExistingContainers(ctx context.Context, t testing.TB, testEnv *Execution) []string { t.Helper() client := testEnv.APIClient() - containerList, err := client.ContainerList(ctx, types.ContainerListOptions{ + containerList, err := client.ContainerList(ctx, container.ListOptions{ All: true, }) assert.NilError(t, err, "failed to list containers") @@ -112,13 +114,13 @@ func getExistingImages(ctx context.Context, t testing.TB, testEnv *Execution) [] assert.NilError(t, err, "failed to list images") var images []string - for _, image := range imageList { - images = append(images, tagsFromImageSummary(image)...) + for _, img := range imageList { + images = append(images, tagsFromImageSummary(img)...) } return images } -func tagsFromImageSummary(image types.ImageSummary) []string { +func tagsFromImageSummary(image image.Summary) []string { var result []string for _, tag := range image.RepoTags { // Starting from API 1.43 no longer outputs the hardcoded diff --git a/testutil/fakestorage/storage.go b/testutil/fakestorage/storage.go index ae7c2a862a..0a67b9c50a 100644 --- a/testutil/fakestorage/storage.go +++ b/testutil/fakestorage/storage.go @@ -125,7 +125,7 @@ func (f *remoteFileServer) Close() error { if f.container == "" { return nil } - return f.client.ContainerRemove(context.Background(), f.container, types.ContainerRemoveOptions{ + return f.client.ContainerRemove(context.Background(), f.container, containertypes.RemoveOptions{ Force: true, RemoveVolumes: true, }) @@ -157,7 +157,7 @@ COPY . /static`); err != nil { Image: image, }, &containertypes.HostConfig{}, nil, nil, container) assert.NilError(t, err) - err = c.ContainerStart(context.Background(), b.ID, types.ContainerStartOptions{}) + err = c.ContainerStart(context.Background(), b.ID, containertypes.StartOptions{}) assert.NilError(t, err) // Find out the system assigned port