Commit Graph

1171 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
20d65620f9 client: Client.buildRequest: don't set content-header if not set
This function was setting `text/plain` as default content-type for any
request that had a non-nil body.

However, this would also set the content-type if (e.g.) `http.NoBody` was set,
or if an empty reader was used, which would result in the daemon potentialy
rejecting the request, as it validates request to be using `application/json`;
d9ee22d1ab/daemon/server/httputils/httputils.go (L47-L58)

    === RUN   TestCommitInheritsEnv
        commit_test.go:30: assertion failed: error is not nil: Error response from daemon: unsupported Content-Type header (text/plain): must be 'application/json'
    --- FAIL: TestCommitInheritsEnv (0.02s)

This patch removes setting the default content-type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-15 00:39:59 +01:00
Sebastiaan van Stijn
d9ee22d1ab Merge pull request #51530 from thaJeztah/allow_renegotiate
client: client.Ping: allow ForceNegotiate with manual override
2025-11-14 20:07:27 +01:00
Sebastiaan van Stijn
6857132911 client: client.Ping: allow ForceNegotiate with manual override
While a manual overridden version shouldn't perform automatic version
negotiation, the "ForceNegotiate" option could still be used to (re)
negotiate a version. This allows a client to be configured with an
initial API version, then triggered to perform API-version negotiation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-14 17:41:56 +01:00
Sebastiaan van Stijn
53764de815 client: make WithAPIVersion, WithAPIVersionFromEnv order-independent
Environment-variables are expected to override config / defaults, so
make sure that the DOCKER_API_VERSION env-var always takes priority.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-14 13:54:32 +01:00
Sebastiaan van Stijn
a5c7f3f9c8 client: don't negotiate malformed responses
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-14 13:54:31 +01:00
Sebastiaan van Stijn
bcc1db1ce5 client: WithAPIVersion, WithAPIVersionFromEnv: validate well-formedness
Make these options more strict to not allow arbitrary values. Historically,
the `DOCKER_API_VERSION` env-var did not perform any validation as it was
intended for testing-purposes, but given the wider use of this env-var,
we should perform some amount of validation.

Both `WithAPIVersion` and `WithAPIVersionFromEnv` still allow specifying
API versions that are not supported by the client for testing purposes
(e.g. to use API versions beyond `MinAPIVersion` and `MaxAPIVersion`),
but must be well-formed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-14 13:54:31 +01:00
Sebastiaan van Stijn
83ad5c92f7 client: Client.ping() fix duplicate ping
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-14 13:54:27 +01:00
Sebastiaan van Stijn
611c7dce43 client: export fallbackAPIVersion as MinAPIVersion
Export the const and rename it to better reflect its intent.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-14 10:26:37 +01:00
Sebastiaan van Stijn
94e83af71a client: TestImageListWithSharedSize: merge with TestImageList
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-13 15:57:24 +01:00
Sebastiaan van Stijn
62589a6961 client: TestTLSCloseWriter: cancel context after test
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-13 15:46:54 +01:00
Sebastiaan van Stijn
a5dec0a779 client: make sure context is canceled for ContainerWait tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-13 15:44:09 +01:00
Sebastiaan van Stijn
76a4381d45 client: TestImageListWithSharedSize slight reformat
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-13 15:43:13 +01:00
Sebastiaan van Stijn
9af7fbff2a client: TestImageList: use subtests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-13 15:43:13 +01:00
Sebastiaan van Stijn
dae3650dcc client: rename/deprecate WithVersion, WithVersionFromEnv
Add WithAPIVersion and WithAPIVersionFromEnv to be more clear on
the intent, and to align with other related options and fields.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-12 22:39:05 +01:00
Sebastiaan van Stijn
e5db2380f5 client: rename options.go to client_options.go
Make sure the options are next to the client.go file, which use the
consumer of these options.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-12 22:39:02 +01:00
Sebastiaan van Stijn
2729703967 client: fix example in README (align with ExampleNew())
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-12 20:31:04 +01:00
Sebastiaan van Stijn
b29990916d client: fix unused imports
this was introduced in c950796596, but
likely due to the "replace" rules not being present, CI tested the
current version of the module instead of the code in the repository.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-12 17:53:36 +01:00
Sebastiaan van Stijn
16b95ba758 go.mod: add back replace rules
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-12 15:43:16 +01:00
Sebastiaan van Stijn
c950796596 client: use t.Context in tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-10 23:23:23 +01:00
Paweł Gronowski
e0a877b487 vendor: github.com/moby/moby/api v1.52.0
full diff: https://github.com/moby/moby/api/compare/da8fb63a73c0...v1.52.0

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-10 21:46:26 +01:00
Paweł Gronowski
854ccbfcf5 Drop replace rules
Prepare v29.0.0

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-10 19:38:57 +01:00
Sebastiaan van Stijn
15241265dc client, api: update go.mod to go1.24
While go1.23 still works, it's already EOL, so it may be a better
starting point to use that as minimum version for these modules, as
they're brand new.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-10 18:42:11 +01:00
Paweł Gronowski
f57da07056 Merge pull request #51454 from thaJeztah/api_volumes_no_pointer
api/types/volume: change ListResponse.Volumes to a non-pointer slice
2025-11-10 16:20:16 +01:00
Rob Murray
69c4524355 Merge pull request #51437 from thaJeztah/diskusage_move_legacy
api: remove / internalize LegacyDiskUsage
2025-11-10 15:03:37 +00:00
Paweł Gronowski
75cf7c2544 Merge pull request #51450 from thaJeztah/checkpoint_client
client: checkpoint: add output structs and fix naming
2025-11-10 13:49:45 +01:00
Sebastiaan van Stijn
18000fe371 api/types/volume: change ListResponse.Volumes to a non-pointer slice
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-10 13:13:22 +01:00
Sebastiaan van Stijn
7aa036ef2e client: rename CheckpointDelete to CheckpointRemove, and add output struct
Align with other "delete" options, which are all named "remove".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-10 11:42:27 +01:00
Sebastiaan van Stijn
e2bdc51508 client: CheckpointCreate: add output struct
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-10 11:42:23 +01:00
Sebastiaan van Stijn
da25838fc3 client: CheckpointListResult: rename Checkpoints to Items
Align with other ListResult structs

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-10 11:23:34 +01:00
Sebastiaan van Stijn
fda54735c9 client: move CheckpointAPIClient together with other interfaces
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-10 11:19:12 +01:00
Sebastiaan van Stijn
15a048c396 api, client: don't use a pointer-slice for plugins
The backend and router don't use a pointer-slice (the server actually
doesn't use the `plugin.ListResponse` type and a straight slice);
778e5bfad3/daemon/server/router/plugin/backend.go (L20)
6baf274fa3/daemon/server/router/plugin/plugin_routes.go (L276-L280)

Align the type in the API to match, and update the type defined in the
client accordingly.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-07 21:02:26 +01:00
Sebastiaan van Stijn
ed428234bd api: remove / internalize LegacyDiskUsage
These fields have been removed from the API specification, and the struct
was only needed to produce legacy responses (server), or to unmarshal
legacy responses in the client.

As the API module only provides API definitions for the current API version,
we should remove these legacy structs, and keep them internal to the daemon
and client.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-07 20:16:03 +01:00
Sebastiaan van Stijn
bd5e6bab1d go.mod: add back replace
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-07 17:22:05 +01:00
Paweł Gronowski
f66f1b451c vendor: github.com/moby/moby/api v1.52.0-rc.1
full diff: https://github.com/moby/moby/api/compare/v1.52.0-beta.4...v1.52.0-rc.1

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-07 01:11:18 +01:00
Paweł Gronowski
e8745c2157 Drop replace rules
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-07 00:56:57 +01:00
Sebastiaan van Stijn
52e19b6e6d Merge pull request #51402 from thaJeztah/cleanup_interfaces
client: cleanup and re-group interfaces
2025-11-07 00:53:54 +01:00
Paweł Gronowski
16b865e7ce Merge pull request #51431 from thaJeztah/client_rm_deprecated
client: remove uses of deprecated NewClientWithOpts
2025-11-07 00:52:56 +01:00
Paweł Gronowski
7fd468cebf Merge pull request #51428 from austinvazquez/rename-api-fields
Rename disk usage API fields
2025-11-07 00:52:46 +01:00
Sebastiaan van Stijn
8db3118ac9 client: remove uses of deprecated NewClientWithOpts
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-07 00:07:11 +01:00
Sebastiaan van Stijn
1745075b24 client: DiskUsage: rename fields to match API
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-06 17:06:53 -06:00
Paweł Gronowski
56463970c0 Merge pull request #51429 from thaJeztah/unexport_streamformatter
client: pkg/streamformatter: un-export unused utilities
2025-11-07 00:05:33 +01:00
Sebastiaan van Stijn
dcfcfd33e9 client: cleanup and re-group interfaces
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-06 23:48:47 +01:00
Austin Vazquez
931c347b36 api/types: rename disk usage fields
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-11-06 16:21:32 -06:00
Paweł Gronowski
217fd78905 Merge pull request #51412 from austinvazquez/use-regular-slice-for-disk-usage
api/types: use regular slices for disk usage types
2025-11-06 23:13:47 +01:00
Sebastiaan van Stijn
745c483e42 client: pkg/streamformatter: un-export unused utilities
Un-export or remove utilities that have no (external) users;

- AuxFormatter (not used)
- FormatError (only used internally)
- FormatStatus (only used internally)
- NewJSONProgressOutput (used by CLI)
- NewProgressOutput (used by compose, cli for classic builder)
- NewStderrWriter (not used)
- NewStdoutWriter (not used)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-06 23:12:11 +01:00
Austin Vazquez
4c6d0ebc40 Fix disk usage result from legacy response logic
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-11-06 15:12:30 -06:00
Sebastiaan van Stijn
f7fd9c315a Merge pull request #51381 from thaJeztah/simplify_pkg_security
client/pkg/security: simplify
2025-11-06 22:06:08 +01:00
Sebastiaan van Stijn
0029924181 api/types/system: change legacyDiskUsage to a non-pointer slice
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-06 12:31:05 +01:00
Austin Vazquez
6881ae72c7 api/types: use regular slices for disk usage types
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-11-05 22:05:47 -06:00
Sebastiaan van Stijn
f76f1fc013 client: Client.ImageSave: 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:10:59 +01:00