Commit Graph

365 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
c5aedacb4f client: Client.ContainerExport: close reader on context cancellation
Use a cancelReadCloser to automatically close the reader when the context
is cancelled. Consumers are still recommended to manually close the reader,
but the cancelReadCloser makes the Close idempotent.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-06 00:07:57 +01:00
Sebastiaan van Stijn
d1f70d4f54 client: deprecate NewClientWithOpts in favor of New
Use a more idiomatic name so that it can be used as `client.New()`.

We should look if we want `New()` to have different / updated defaults
i.e., enable `WithEnv` as default, and have an opt-out and have API-
version negotiation enabled by default (with an opt-out option).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-30 18:09:44 +01:00
Austin Vazquez
c5e318dbde Merge pull request #51328 from vvoland/client-containercopy-structs
client/container_copy: Wrap options and result struct
2025-10-29 10:44:59 -05:00
Paweł Gronowski
1cc2ab16ce client/container_copy: Wrap options and result struct
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-10-29 14:34:19 +01:00
Sebastiaan van Stijn
e9631b507e Merge pull request #51323 from thaJeztah/container_wait_nits
client: ContainerWait: touch-up GoDoc, and remove legacy code, and use singular for channels (ContainerWaitResult)
2025-10-29 13:41:02 +01:00
Sebastiaan van Stijn
29ad05b130 client: ContainerWaitResult: use singular for channels
These channels should ever only return a single result, so rename
them to match that expectation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-29 12:37:46 +01:00
Paweł Gronowski
fc97a2ff0d client: Rename ContainerUnPause* to ContainerUnpause*
To better match the method name itself

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-10-29 11:32:32 +01:00
Sebastiaan van Stijn
d3eb04fe59 Merge pull request #51312 from austinvazquez/refactor-client-container-wait
client: refactor ContainerWait to use client defined options/results structs
2025-10-29 11:12:52 +01:00
Sebastiaan van Stijn
a0f877d1b3 Merge pull request #51316 from austinvazquez/refactor-client-container-export
client: refactor `ContainerExport` to wrap options/result structs
2025-10-29 10:01:07 +01:00
Sebastiaan van Stijn
c438b3fbbf Merge pull request #51314 from austinvazquez/refactor-client-container-list
client: refactor `ContainerList` to wrap result
2025-10-29 08:31:22 +01:00
Austin Vazquez
749c980d4e client: refactor ContainerExport to wrap options/result structs
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-28 19:39:13 -05:00
Austin Vazquez
ec22a1e5b2 client: refactor ContainerTop to wrap options and results
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-28 18:54:43 -05:00
Austin Vazquez
c5ddef1122 client: refactor ContainerList to wrap result
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-28 18:52:52 -05:00
Austin Vazquez
cf173bc941 client: refactor ContainerWait to use client defined options/results structs
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-28 18:15:01 -05:00
Sebastiaan van Stijn
1f5c82b9fa client: add option and output structs for various container methods
Add option- and output structs for;

- Client.ContainerKill
- Client.ContainerPause
- Client.ContainerRemove
- Client.ContainerResize
- Client.ContainerRestart
- Client.ContainerStart
- Client.ContainerStop
- Client.ContainerUnpause

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 23:46:28 +01:00
Sebastiaan van Stijn
8118385ba8 client: ContainerStats: add option, output-structs, remove ContainerStatsOneShot
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 14:03:55 +01:00
Sebastiaan van Stijn
f7003ef7de integration-cli: minor cleanups in stats tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 12:45:12 +01:00
Sebastiaan van Stijn
5742b40c87 integration-cli: simplify, improve some stats tests
Remove the go-routines and just fetch the result for non-streaming stats.
Also check for the result to be valid for some tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 12:45:05 +01:00
Sebastiaan van Stijn
e410daf8f7 integration-cli: TestContainerAPIStatsWithNetworkDisabled: check result
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 10:55:01 +01:00
Sebastiaan van Stijn
425975313a client: merge ContainerInspectWithRaw with ContainerInspect
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-24 22:01:23 +02:00
Paweł Gronowski
8fb561ca9a client/container_create: Add Image outside of Config
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-10-23 21:11:30 +02:00
Paweł Gronowski
3340c86db9 client/container_create: Rename ContainerName to Name
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-10-23 21:11:30 +02:00
Paweł Gronowski
bd31b8b1c7 client_(attach,commit,create,diff): Wrap result and options
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-10-23 21:11:30 +02:00
Sebastiaan van Stijn
e3c6dc2a91 client: VolumeInspect: add options struct
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-21 23:36:20 +02:00
Sebastiaan van Stijn
9fe856a5f3 integration-cli: move some tests to integration
Migrates:

- TestAPIErrorJSON
- TestContainerAPIInvalidPortSyntax
- TestContainerAPIRestartPolicyInvalidPolicyName
- TestContainerAPIRestartPolicyRetryMismatch
- TestContainerAPIRestartPolicyNegativeRetryCount
- TestContainerAPIRestartPolicyDefaultRetryCount
- TestCreateWithTooLowMemoryLimit

Co-authored-by: Sameer Gupta <sameergupta4873@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-21 12:01:55 +02:00
Sebastiaan van Stijn
b0c5090275 Merge pull request #51106 from thaJeztah/rm_deprecated_utils
integration-cli: remove deprecated buildImageSuccessfully, buildImage utilities
2025-10-06 12:45:40 +02:00
Sebastiaan van Stijn
288b9f033b integration-cli: remove deprecated buildImageSuccessfully utility
This was deprecated in 50c4475df6, which
introduced the cli test-utils package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-05 17:27:26 +02:00
Austin Vazquez
c646091d57 api: move container port type to network package
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-03 17:30:42 -05:00
Cory Snider
fd4329a620 api/types/container: use netip types as appropriate
Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-10-03 21:39:14 +02:00
Austin Vazquez
cb3abacc52 api/types/container: add network port and port range types
Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Co-authored-by: Cory Snider <csnider@mirantis.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-02 13:59:34 -05:00
Sebastiaan van Stijn
d3e45f8743 testutil: move back to internal
This package was originally internal, but was moved out when BuildKit
used it for its integration tests. That's no longer the case, so we
can make it internal again.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 10:08:30 +02:00
Sebastiaan van Stijn
4d20b6fe56 api/types/container: move container options to client
Move the option-types to the client and in some cases create a
copy for the backend. These types are used to construct query-
args, and not marshaled to JSON, and can be replaced with functional
options in the client.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-04 20:09:55 +02:00
Matthieu MOREL
96f8c6395e chore: enable use-any rule from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-08-08 17:07:07 +02:00
Sebastiaan van Stijn
c55d02be07 Merge pull request #50507 from carsontham/migrate-test-container-api-rename
integration-cli: migrated test TestContainerAPIRename to docker/cli
2025-08-01 19:57:17 +02:00
carsontham
bbec7a5150 migrated test container API rename to docker/cli
Signed-off-by: carsontham <carsontham@outlook.com>
2025-08-01 13:27:07 +08:00
Sebastiaan van Stijn
c98e5cb60b update github links to moby/moby
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-01 01:48:55 +02:00
Derek McGowan
f74e5d48b3 Create github.com/moby/moby/v2 module
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-31 10:13:29 -07:00
Sebastiaan van Stijn
d58dc493fe replace direct uses of nat types for api/types/container aliases
Follow-up to 494677f93f, which added
the aliases, but did not yet replace our own use of the nat types.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-31 02:57:39 +02:00
Sebastiaan van Stijn
bc6851e5a1 Merge pull request #50521 from thaJeztah/move_StatsResponseReader
api/types/container.StatsResponseReader: move to client
2025-07-28 12:31:33 +02:00
Sebastiaan van Stijn
dbfe7649e0 Merge pull request #50525 from thaJeztah/migrate_defaultshmsize_test
integration-cli: migrate TestPostContainersCreateShmSizeXXX to integration
2025-07-28 12:17:17 +02:00
Sebastiaan van Stijn
6b4dfb0135 integration-cli: migrate TestPostContainersCreateShmSizeXXX to integration
Some of these tests were making assumptions about the daemon's internals
by using `config.DefaultShmSize` from the daemon config package.

Rewrite them to start a daemon with a custom default, and verify the
tests to use that default.

This migrates the following tests from integration-cli to integration;

- `DockerAPISuite.TestPostContainersCreateShmSizeNegative`
- `DockerAPISuite.TestPostContainersCreateShmSizeHostConfigOmitted`
- `DockerAPISuite.TestPostContainersCreateShmSizeOmitted`
- `DockerAPISuite.TestPostContainersCreateWithShmSize`

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-26 20:52:00 +02:00
Sebastiaan van Stijn
281a3f6c41 integration-cli: remove deprecaed inspectMountSourceField
The replacement is also deprecated, but at least returns a strong type,
which may help transitioning to using an api-client for these, and
removing one abstraction at a time.

Also rewriting the TestContainerAPIDeleteRemoveVolume to use the API
client (as it's part of the API suite), and touched-up the
TestRunMountShmMqueueFromHost test a bit.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-26 16:34:24 +02:00
Sebastiaan van Stijn
29a7d4039e integration-cli: remove deprecated inspectFieldMap utility
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-26 12:32:30 +02:00
Sebastiaan van Stijn
97827e1a58 integration-cli: TestContainerAPIGetExport: fix minor linting issues
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-26 11:22:42 +02:00
Sebastiaan van Stijn
f67e6555bf api/types/container.StatsResponseReader: move to client
This type was only used in the client, and needs a rewrite; let's
move it to the client first.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-26 11:22:36 +02:00
Sebastiaan van Stijn
ca1c5ee08f pkg/stringid: move to daemon, and provide copy in client
The stringid package is used in many places; while it's trivial
to implement a similar utility, let's just provide it as a utility
package in the client, removing the daemon-specific logic.

For integration tests, I opted to use the implementation in the
client, as those should not ideally not make assumptions about
the daemon implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-25 13:39:32 +02:00
Sebastiaan van Stijn
1378604cc3 integration-cli: remove tests for pre-docker 1.7 clients
The strslice.StrSlice type is a string-slice with a custom JSON Unmarshal
function to provide backward-compatibility with older API requests from
before docker 1.7 (see [moby@17d6f00] and [moby@ea4a067]), which used a
string instead of an array of strings for some fields (Cmd, Entrypoint).

We no longer support those API versions, and we no longer support pulling
v1 images that may contain such a config, so we can remove these tests that
validate the behavior as they're invalid API requests.

This;

- removes DockerAPISuite.TestPostContainerAPICreateWithStringOrSliceEntrypoint
- removes DockerAPISuite.TestPostContainersCreateWithStringOrSliceCmd
- removes DockerAPISuite.TestPostContainersCreateWithStringOrSliceCapAddDrop
- updates DockerAPISuite.TestContainerAPIPostCreateNull, which used an invalid example

[moby@17d6f00]: 17d6f00ec2
[moby@ea4a067]: ea4a06740b

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-23 14:48:21 +02:00
Derek McGowan
c47afd41c8 Create github.com/moby/moby/client module
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-21 09:30:26 -07:00
Derek McGowan
afd6487b2e Create github.com/moby/moby/api module
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-21 09:30:05 -07:00
Derek McGowan
04f5276267 Move volume to daemon/volume
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-15 10:44:44 -07:00