Paweł Gronowski
1489cb3ae0
Merge pull request #51722 from vvoland/modernize
...
Modernize Go code
2025-12-16 12:38:36 +00:00
Paweł Gronowski
3df05205f4
modernize: Use range int
...
Added in Go 1.22
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com >
2025-12-15 18:56:34 +01:00
Aditya Mishra
29d5098ffd
migrate TestAPINetworkInspectWithScope to integration test
...
Signed-off-by: Aditya Mishra <mishraaditya675@gmail.com >
2025-12-13 23:24:31 +05:30
Sebastiaan van Stijn
d299e5be83
api/types/swarm: define type for UpdateOrder
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2025-11-05 12:50:51 +01:00
Sebastiaan van Stijn
b552b8b729
api/types/swarm: define type for FailureAction
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2025-11-05 12:50:48 +01:00
Austin Vazquez
a087d03e0c
client: refactor create network api implementation to wrap options/results
...
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com >
2025-10-30 23:45:18 -05:00
Austin Vazquez
e46058cbae
client: refactor Events, Info, RegistryLogin
...
Co-authored-by: Claude <noreply@anthropic.com >
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com >
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2025-10-29 09:36:23 +01:00
Sebastiaan van Stijn
3a43b5b559
client: refactor ServiceCreate, ServiceUpdate, SwarmUpdate
...
Put the version and spec in the options-struct, as we did for other
swarm-related methods.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2025-10-23 15:40:18 +02:00
Sebastiaan van Stijn
26d57f42a8
Merge pull request #51245 from thaJeztah/network_opts
...
client: NetworkInspect, NetworkList: wrap output structs, and remove NetworkInspectWithRaw
2025-10-21 18:50:33 +02:00
Sebastiaan van Stijn
3fbf5a3bd1
client: NetworkInspect: wrap result and remove NetworkInspectWithRaw
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2025-10-21 17:26:24 +02:00
Austin Vazquez
612342198c
client: refactor swarm api functions to wrap params/responses
...
Co-authored-by: Claude <noreply@anthropic.com >
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com >
2025-10-21 10:17:04 -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
Austin Vazquez
1b4fcb8da7
api/types/network: move CreateOptions type to client module
...
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com >
2025-08-27 08:10:20 -05:00
Austin Vazquez
3b1e16594b
api/types/swarm: move ServiceUpdateOptions type to client
...
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com >
2025-08-26 07:21:33 -05:00
Austin Vazquez
bb4125e89f
api/types/swarm: move ServiceCreateOptions type to client
...
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com >
2025-08-26 07:21:33 -05:00
Austin Vazquez
fe8516cf4b
client: refactor InspectOptions to NetworkInspectOptions
...
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com >
2025-08-22 09:38:53 -05:00
Austin Vazquez
5eaed0366c
api/types/network: move InspectOptions to client mod
...
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com >
2025-08-22 09:38:53 -05: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
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
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
Matthieu MOREL
9b5d8cd186
fix thelper linter
...
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com >
2025-06-05 21:42:05 +00:00
Matthieu MOREL
528f2284ee
integration-cli: replace uses of errdefs package
...
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com >
2025-05-28 05:40:06 +00:00
Sebastiaan van Stijn
0b1c7a8306
api/types: move ServiceUpdateOptions to api/types/swarm
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2025-05-19 16:30:33 +02:00
Sebastiaan van Stijn
31d62930f7
api/types: move ServiceCreateOptions to api/types/swarm
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2025-05-19 16:30:31 +02:00
Aleksa Sarai
5e4e34a966
tests: migrate strings.Contains -> is.Contains in assertions
...
Migrated using
find . -type f -name "*_test.go" |
xargs gofmt -w \
-r "assert.Check(t, strings.Contains(a, b)) -> assert.Check(t, is.Contains(a, b))"
find . -type f -name "*_test.go" |
xargs gofmt -w \
-r "assert.Assert(t, strings.Contains(a, b)) -> assert.Assert(t, is.Contains(a, b))"
Using a boolean in assert.Assert or assert.Check results in error
messages that don't contain the actual problematic string, and when
running the integration suite on an actual machine (where the source
code parsing doesn't work) this makes it almost impossible to figure out
what the actual error is.
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com >
2024-11-22 23:59:20 +11:00
Albin Kerouanton
07053a0991
testutil/daemon: Wait() until the daemon is Kill()'ed
...
`Daemon.Kill()` was sending a SIGKILL to the daemon process but wasn't
waiting until the process was really killed. While the race window is
really small, better safe than sorry.
Signed-off-by: Albin Kerouanton <albinker@gmail.com >
2024-06-14 18:35:31 +02:00
Sebastiaan van Stijn
ad6edc139f
api/types: move NetworkCreate, NetworkCreateRequest to api/types/network
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2024-06-07 11:11:15 +02:00
Sebastiaan van Stijn
5bea0c38bc
api/types: migrate NetworkInspectOptions to api/types/network
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2024-05-29 19:22:37 +02:00
Rob Murray
9a8ffe38fc
Disable ip6tables in tests that disable iptables
...
Tests that start a daemon disable iptables, to avoid conflicts with
other tests running in parallel and also creating iptables chains.
Do the same for ip6tables, in prep for them being enabled by-default.
Signed-off-by: Rob Murray <rob.murray@docker.com >
2024-05-10 09:21:21 +01:00
Albin Kerouanton
78479b1915
libnet: Make sure network names are unique
...
Fixes #18864 , #20648 , #33561 , #40901 .
[This GH comment][1] makes clear network name uniqueness has never been
enforced due to the eventually consistent nature of Classic Swarm
datastores:
> there is no guaranteed way to check for duplicates across a cluster of
> docker hosts.
And this is further confirmed by other comments made by @mrjana in that
same issue, eg. [this one][2]:
> we want to adopt a schema which can pave the way in the future for a
> completely decentralized cluster of docker hosts (if scalability is
> needed).
This decentralized model is what Classic Swarm was trying to be. It's
been superseded since then by Docker Swarm, which has a centralized
control plane.
To circumvent this drawback, the `NetworkCreate` endpoint accepts a
`CheckDuplicate` flag. However it's not perfectly reliable as it won't
catch concurrent requests.
Due to this design decision, API clients like Compose have to implement
workarounds to make sure names are really unique (eg.
docker/compose#9585 ). And the daemon itself has seen a string of issues
due to that decision, including some that aren't fixed to this day (for
instance moby/moby#40901 ):
> The problem is, that if you specify a network for a container using
> the ID, it will add that network to the container but it will then
> change it to reference the network by using the name.
To summarize, this "feature" is broken, has no practical use and is a
source of pain for Docker users and API consumers. So let's just remove
it for _all_ API versions.
[1]: https://github.com/moby/moby/issues/18864#issuecomment-167201414
[2]: https://github.com/moby/moby/issues/18864#issuecomment-167202589
Signed-off-by: Albin Kerouanton <albinker@gmail.com >
2023-09-12 10:40:13 +02:00
Brian Goff
e8dc902781
Wire up tests to support otel tracing
...
Integration tests will now configure clients to propagate traces as well
as create spans for all tests.
Some extra changes were needed (or desired for trace propagation) in the
test helpers to pass through tracing spans via context.
Signed-off-by: Brian Goff <cpuguy83@gmail.com >
2023-09-07 18:38:22 +00:00
Sebastiaan van Stijn
b9d9504df5
vendor: github.com/moby/swarmkit/v2 v2.0.0-20230808164555-1983e41a9fff
...
notable changes:
- Free unused volumes in more cases
- Convert BasicKeyRequest to KeyRequest to use cloudflare/cfssl 1.x.x
- reduce direct imports of logrus
diffs:
- github.com/cloudflare/cfssl v1.6.4; full diff: https://github.com/cloudflare/cfssl/compare/5d63dbd981b5...v1.6.4
- github.com/moby/swarmkit/v2; full diff: https://github.com/moby/swarmkit/compare/bc71908479e5...60421a63a7f148ba1ec7d35c55e4cf9ac03d6b78
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2023-08-14 18:39:57 +02:00
Sebastiaan van Stijn
225e2562c9
integration-cli: format code with gofumpt
...
Formatting the code with https://github.com/mvdan/gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2023-06-29 00:08:27 +02:00
Sebastiaan van Stijn
ab35df454d
remove pre-go1.17 build-tags
...
Removed pre-go1.17 build-tags with go fix;
go mod init
go fix -mod=readonly ./...
rm go.mod
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2023-05-19 20:38:51 +02:00
Sebastiaan van Stijn
0538cdd226
integration-cli: update error-assertions in tests
...
- use is.ErrorType
- replace uses of client.IsErrNotFound for errdefs.IsNotFound, as
the client no longer returns the old error-type.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2023-05-10 22:13:50 +02:00
Cory Snider
1c129103b4
Bump swarmkit to v2
...
Signed-off-by: Cory Snider <csnider@mirantis.com >
2022-04-21 17:33:07 -04:00
Eng Zer Jun
c55a4ac779
refactor: move from io/ioutil to io and os package
...
The io/ioutil package has been deprecated in Go 1.16. This commit
replaces the existing io/ioutil functions with their new definitions in
io and os packages.
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com >
2021-08-27 14:56:57 +08:00
Sebastiaan van Stijn
686be57d0a
Update to Go 1.17.0, and gofmt with Go 1.17
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2021-08-24 23:33:27 +02:00
Sebastiaan van Stijn
07d60bc257
Replace errors.Cause() with errors.Is() / errors.As()
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2020-04-29 00:28:41 +02:00
Sebastiaan van Stijn
9f0b3f5609
bump gotest.tools v3.0.1 for compatibility with Go 1.14
...
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2020-02-11 00:06:42 +01:00
Sebastiaan van Stijn
7c40c0a922
integration-cli: remove unnescessary conversions (unconvert)
...
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com >
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2019-09-18 12:57:01 +02:00
Sebastiaan van Stijn
a44d90cdd4
integration-cli: update comments referencing waitAndAssert()
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
2019-09-12 08:27:03 +02:00
Sam Whited
b37c214e3c
testutil: make testing packages public
...
This was done with something along the lines of:
```
mv internal/test testutil
pushd testutil/; grep -IRl "package test" | xargs -I '{}' sed -i -e 's|package test|package testutil|g' {}; popd
mv internal/testutil/*.go testutil/ && rm -rf internal/
grep -IRl "github.com\/docker\/docker\/internal\/test" | xargs -I '{}' sed -i -e 's|github.com/docker/docker/internal/test|github.com/docker/docker/test|g' {}
goimports .
```
I also modified the basic plugin path in testutil/fixtures/plugin.
Signed-off-by: Sam Whited <sam@samwhited.com >
2019-09-11 07:47:23 -05:00
Tibor Vass
649201dc44
remove waitAndAssert and type casts
...
Signed-off-by: Tibor Vass <tibor@docker.com >
2019-09-09 21:09:57 +00:00
Tibor Vass
ac2f24e72a
waitAndAssert -> poll.WaitOn
...
go get -d golang.org/x/tools/cmd/eg && \
dir=$(go env GOPATH)/src/golang.org/x/tools && \
git -C "$dir" fetch https://github.com/tiborvass/tools handle-variadic && \
git -C "$dir" checkout 61a94b82347c29b3289e83190aa3dda74d47abbb && \
go install golang.org/x/tools/cmd/eg
eg -w -t template.waitAndAssert.go ./integration-cli 2>&1 \
| awk '{print $2}' | while read file; do
# removing vendor/ in import paths
# not sure why eg adds them
sed -E -i 's#^([\t]+").*/vendor/([^"]+)#\1\2#g' "$file"
sed -E -i 's#\.\(eg_compareFunc\)##g' "$file"
goimports -w "$file"
done
Signed-off-by: Tibor Vass <tibor@docker.com >
2019-09-09 21:09:57 +00:00
Tibor Vass
42599f1cad
prepare for eg on waitAndAssert
...
Signed-off-by: Tibor Vass <tibor@docker.com >
2019-09-09 21:09:57 +00:00
Tibor Vass
64de5e8228
rm-gocheck: fix compile errors from converting check.CommentInterface to string
...
while :; do \
out=$(go test -c ./integration-cli 2>&1 | grep 'cannot use nil as type string in return argument') || break
echo "$out" | while read line; do
file=$(echo "$line" | cut -d: -f1)
n=$(echo "$line" | cut -d: -f2)
sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file"
done
done \
&& \
while :; do \
out=$(go test -c ./integration-cli/daemon 2>&1 | grep 'cannot use nil as type string in return argument') || break
echo "$out" | while read line; do
file=$(echo "$line" | cut -d: -f1)
n=$(echo "$line" | cut -d: -f2)
sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file"
done
done \
&& \
while :; do \
out=$(go test -c ./pkg/discovery 2>&1 | grep 'cannot use nil as type string in return argument') || break
echo "$out" | while read line; do
file=$(echo "$line" | cut -d: -f1)
n=$(echo "$line" | cut -d: -f2)
sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file"
done
done \
&& \
while :; do \
out=$(go test -c ./pkg/discovery/file 2>&1 | grep 'cannot use nil as type string in return argument') || break
echo "$out" | while read line; do
file=$(echo "$line" | cut -d: -f1)
n=$(echo "$line" | cut -d: -f2)
sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file"
done
done \
&& \
while :; do \
out=$(go test -c ./pkg/discovery/kv 2>&1 | grep 'cannot use nil as type string in return argument') || break
echo "$out" | while read line; do
file=$(echo "$line" | cut -d: -f1)
n=$(echo "$line" | cut -d: -f2)
sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file"
done
done \
&& \
while :; do \
out=$(go test -c ./pkg/discovery/memory 2>&1 | grep 'cannot use nil as type string in return argument') || break
echo "$out" | while read line; do
file=$(echo "$line" | cut -d: -f1)
n=$(echo "$line" | cut -d: -f2)
sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file"
done
done \
&& \
while :; do \
out=$(go test -c ./pkg/discovery/nodes 2>&1 | grep 'cannot use nil as type string in return argument') || break
echo "$out" | while read line; do
file=$(echo "$line" | cut -d: -f1)
n=$(echo "$line" | cut -d: -f2)
sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file"
done
done
Signed-off-by: Tibor Vass <tibor@docker.com >
2019-09-09 21:09:27 +00:00
Tibor Vass
7813dfe9d7
rm-gocheck: goimports
...
goimports -w \
-- "./pkg/discovery/file" "./pkg/discovery/kv" "./pkg/discovery/memory" "./pkg/discovery/nodes" "./integration-cli" "./integration-cli/daemon" "./pkg/discovery" \
&& \
gofmt -w -s \
-- "./pkg/discovery/file" "./pkg/discovery/kv" "./pkg/discovery/memory" "./pkg/discovery/nodes" "./integration-cli" "./integration-cli/daemon" "./pkg/discovery"
Signed-off-by: Tibor Vass <tibor@docker.com >
2019-09-09 21:08:38 +00:00
Tibor Vass
3a24472c8e
rm-gocheck: check.CommentInterface -> string
...
sed -E -i 's#(\*testing\.T\b.*)check\.CommentInterface\b#\1string#g' \
-- "integration-cli/daemon/daemon.go" "integration-cli/daemon/daemon_swarm.go" "integration-cli/docker_api_exec_test.go" "integration-cli/docker_api_swarm_service_test.go" "integration-cli/docker_api_swarm_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_prune_unix_test.go" "integration-cli/docker_cli_restart_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_service_health_test.go" "integration-cli/docker_cli_service_logs_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_utils_test.go"
Signed-off-by: Tibor Vass <tibor@docker.com >
2019-09-09 21:08:22 +00:00
Tibor Vass
6135eec30a
rm-gocheck: convert check.Commentf to string - with just one string
...
sed -E -i 's#\bcheck.Commentf\(("[^"]+")\)#\1#g' \
-- "integration-cli/daemon/daemon_swarm.go" "integration-cli/docker_api_containers_test.go" "integration-cli/docker_api_swarm_test.go" "integration-cli/docker_cli_build_unix_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_import_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_pull_local_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_save_load_test.go" "integration-cli/docker_cli_service_logs_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_userns_test.go" "integration-cli/docker_cli_volume_test.go" "integration-cli/docker_utils_test.go"
Signed-off-by: Tibor Vass <tibor@docker.com >
2019-09-09 21:08:22 +00:00