From a9232a80060037f138f62f96ad9b1c3667c85c06 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 21 Jul 2025 20:26:07 +0200 Subject: [PATCH 1/3] migrate to moby/moby/api v1.52.0-alpha.1, moby/moby/client v0.1.0-alpha.0 Signed-off-by: Sebastiaan van Stijn --- cmd/compose/bridge.go | 4 +- cmd/compose/images.go | 2 +- cmd/compose/stats.go | 2 +- cmd/formatter/container.go | 4 +- cmd/formatter/logs.go | 2 +- cmd/main.go | 2 +- go.mod | 13 ++- go.sum | 23 ++-- internal/sync/tar.go | 2 +- internal/tracing/attributes.go | 2 +- pkg/api/api.go | 2 +- pkg/api/dryrunclient.go | 72 +++++++------ pkg/bridge/convert.go | 11 +- pkg/bridge/transformers.go | 8 +- pkg/compose/attach.go | 4 +- pkg/compose/build.go | 2 +- pkg/compose/build_bake.go | 4 +- pkg/compose/build_classic.go | 17 +-- pkg/compose/commit.go | 2 +- pkg/compose/compose.go | 12 +-- pkg/compose/container.go | 28 ++--- pkg/compose/containers.go | 6 +- pkg/compose/convergence.go | 18 ++-- pkg/compose/convergence_test.go | 10 +- pkg/compose/convert.go | 4 +- pkg/compose/cp.go | 2 +- pkg/compose/create.go | 14 +-- pkg/compose/create_test.go | 8 +- pkg/compose/down.go | 8 +- pkg/compose/down_test.go | 10 +- pkg/compose/events.go | 4 +- pkg/compose/exec.go | 2 +- pkg/compose/filters.go | 2 +- pkg/compose/generate.go | 8 +- pkg/compose/hook.go | 4 +- pkg/compose/image_pruner.go | 6 +- pkg/compose/images.go | 8 +- pkg/compose/images_test.go | 8 +- pkg/compose/internal/urlutil/urlutil.go | 105 +++++++++++++++++++ pkg/compose/internal/urlutil/urlutil_test.go | 58 ++++++++++ pkg/compose/kill.go | 2 +- pkg/compose/kill_test.go | 10 +- pkg/compose/logs.go | 4 +- pkg/compose/logs_test.go | 6 +- pkg/compose/ls.go | 4 +- pkg/compose/ls_test.go | 2 +- pkg/compose/monitor.go | 8 +- pkg/compose/pause.go | 2 +- pkg/compose/port.go | 2 +- pkg/compose/ps_test.go | 4 +- pkg/compose/pull.go | 6 +- pkg/compose/push.go | 4 +- pkg/compose/remove.go | 2 +- pkg/compose/restart.go | 2 +- pkg/compose/run.go | 2 +- pkg/compose/secrets.go | 2 +- pkg/compose/start.go | 4 +- pkg/compose/stop_test.go | 8 +- pkg/compose/volumes.go | 6 +- pkg/compose/volumes_test.go | 6 +- pkg/compose/watch.go | 6 +- pkg/compose/watch_test.go | 6 +- pkg/mocks/mock_docker_api.go | 69 ++++++------ pkg/mocks/mock_docker_cli.go | 2 +- 64 files changed, 418 insertions(+), 254 deletions(-) create mode 100644 pkg/compose/internal/urlutil/urlutil.go create mode 100644 pkg/compose/internal/urlutil/urlutil_test.go diff --git a/cmd/compose/bridge.go b/cmd/compose/bridge.go index 22f78b68998..6c8533d387d 100644 --- a/cmd/compose/bridge.go +++ b/cmd/compose/bridge.go @@ -23,9 +23,9 @@ import ( "github.com/distribution/reference" "github.com/docker/cli/cli/command" - "github.com/docker/docker/api/types/image" - "github.com/docker/docker/pkg/stringid" "github.com/docker/go-units" + "github.com/moby/moby/api/types/image" + "github.com/moby/moby/client/pkg/stringid" "github.com/spf13/cobra" "github.com/docker/compose/v2/cmd/formatter" diff --git a/cmd/compose/images.go b/cmd/compose/images.go index 5544204c893..a9886c6bc44 100644 --- a/cmd/compose/images.go +++ b/cmd/compose/images.go @@ -27,8 +27,8 @@ import ( "github.com/containerd/platforms" "github.com/docker/cli/cli/command" - "github.com/docker/docker/pkg/stringid" "github.com/docker/go-units" + "github.com/moby/moby/client/pkg/stringid" "github.com/spf13/cobra" "github.com/docker/compose/v2/cmd/formatter" diff --git a/cmd/compose/stats.go b/cmd/compose/stats.go index 98d5aa63af8..24d2d2d1186 100644 --- a/cmd/compose/stats.go +++ b/cmd/compose/stats.go @@ -22,7 +22,7 @@ import ( "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/container" - "github.com/docker/docker/api/types/filters" + "github.com/moby/moby/api/types/filters" "github.com/spf13/cobra" "github.com/docker/compose/v2/pkg/api" diff --git a/cmd/formatter/container.go b/cmd/formatter/container.go index e8e331b805a..5d0644b6d60 100644 --- a/cmd/formatter/container.go +++ b/cmd/formatter/container.go @@ -24,9 +24,9 @@ import ( "github.com/docker/cli/cli/command/formatter" "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/pkg/stringid" "github.com/docker/go-units" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/client/pkg/stringid" ) const ( diff --git a/cmd/formatter/logs.go b/cmd/formatter/logs.go index 430cf1b0392..b3bf49d1547 100644 --- a/cmd/formatter/logs.go +++ b/cmd/formatter/logs.go @@ -27,7 +27,7 @@ import ( "github.com/buger/goterm" "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/pkg/jsonmessage" + "github.com/moby/moby/client/pkg/jsonmessage" ) // LogConsumer consume logs from services and format them diff --git a/cmd/main.go b/cmd/main.go index 3c3e2290eb6..e835dceaaa9 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -24,7 +24,7 @@ import ( "github.com/docker/cli/cli-plugins/plugin" "github.com/docker/cli/cli/command" "github.com/docker/compose/v2/cmd/cmdtrace" - "github.com/docker/docker/client" + "github.com/moby/moby/client" "github.com/sirupsen/logrus" "github.com/spf13/cobra" diff --git a/go.mod b/go.mod index be83d5941e4..92280eb19c7 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,11 @@ module github.com/docker/compose/v2 go 1.23.10 +replace ( + github.com/docker/buildx => github.com/thaJeztah/buildx v0.2.1-0.20250805215749-af0516f267b1 + github.com/moby/buildkit => github.com/moby/buildkit v0.23.0-rc1.0.20250618182037-9b91d20367db // master +) + require ( github.com/AlecAivazis/survey/v2 v2.3.7 github.com/DefangLabs/secret-detector v0.0.0-20250403165618-22662109213e @@ -15,7 +20,7 @@ require ( github.com/davecgh/go-spew v1.1.1 github.com/distribution/reference v0.6.0 github.com/docker/buildx v0.26.1 - github.com/docker/cli v28.3.3+incompatible + github.com/docker/cli v28.3.4-0.20250805212551-f1ceb8c55dfa+incompatible github.com/docker/cli-docs-tool v0.10.0 github.com/docker/docker v28.3.3+incompatible github.com/docker/go-connections v0.5.0 @@ -31,6 +36,8 @@ require ( github.com/mitchellh/mapstructure v1.5.0 github.com/moby/buildkit v0.23.0-rc1.0.20250618182037-9b91d20367db // master github.com/moby/go-archive v0.1.0 + github.com/moby/moby/api v1.52.0-alpha.1 + github.com/moby/moby/client v0.1.0-alpha.0 github.com/moby/patternmatcher v0.6.0 github.com/moby/sys/atomicwriter v0.1.0 github.com/moby/term v0.5.2 @@ -62,7 +69,6 @@ require ( ) require ( - dario.cat/mergo v1.0.1 // indirect github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect github.com/Masterminds/semver/v3 v3.4.0 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect @@ -168,9 +174,6 @@ require ( github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea // indirect github.com/tonistiigi/vt100 v0.0.0-20240514184818-90bafcd6abab // indirect github.com/x448/float16 v0.8.4 // indirect - github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect - github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect - github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xhit/go-str2duration/v2 v2.1.0 // indirect github.com/zclconf/go-cty v1.16.2 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect diff --git a/go.sum b/go.sum index cdb9a1ca076..f8ed072adbf 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= -dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8afgbRMd7mFxO99hRNu+6tazq8nFF9lIwo9JFroBk= github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= @@ -127,10 +125,8 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/docker/buildx v0.26.1 h1:nlj3bVhHK9fV7g6floRvGhPcR0u2hxCPMmObCS1ZKL4= -github.com/docker/buildx v0.26.1/go.mod h1:oxMC30cSHPaCCkY2j+EqN7uxFikjSzVC0c44lo9b4Fo= -github.com/docker/cli v28.3.3+incompatible h1:fp9ZHAr1WWPGdIWBM1b3zLtgCF+83gRdVMTJsUeiyAo= -github.com/docker/cli v28.3.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v28.3.4-0.20250805212551-f1ceb8c55dfa+incompatible h1:tslOU6Gf6aYIY8PwLUADRa5Qqn3/o+4OBcQgWgfmh0Y= +github.com/docker/cli v28.3.4-0.20250805212551-f1ceb8c55dfa+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli-docs-tool v0.10.0 h1:bOD6mKynPQgojQi3s2jgcUWGp/Ebqy1SeCr9VfKQLLU= github.com/docker/cli-docs-tool v0.10.0/go.mod h1:5EM5zPnT2E7yCLERZmrDA234Vwn09fzRHP4aX1qwp1U= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= @@ -325,6 +321,10 @@ github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ github.com/moby/go-archive v0.1.0/go.mod h1:G9B+YoujNohJmrIYFBpSd54GTUB4lt9S+xVQvsJyFuo= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= +github.com/moby/moby/api v1.52.0-alpha.1 h1:fzxPD0h6l4LmvPd/rySW7T3G45G8eFTo9qEAEp5UZX0= +github.com/moby/moby/api v1.52.0-alpha.1/go.mod h1:MuA35dxT3DVZpImg0ORGCoZtT2dC1jgPjwH9/CQ/afQ= +github.com/moby/moby/client v0.1.0-alpha.0 h1:1Q393KgwO8L3SznKE+xGZJVDdApgcSM0vIhAEff+acc= +github.com/moby/moby/client v0.1.0-alpha.0/go.mod h1:pVMvmGeD4P9tbgBtEHZKW993Qkj4d1Nu6qhiW3GGJ6k= github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= github.com/moby/spdystream v0.5.0 h1:7r0J1Si3QO/kjRitvSLVVFUjxMEb/YLj6S9FF62JBCU= @@ -471,6 +471,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/thaJeztah/buildx v0.2.1-0.20250805215749-af0516f267b1 h1:wcsRtpMCqR2oM5CZ00+LqGLEjzxzNCXuezFWpffUaZI= +github.com/thaJeztah/buildx v0.2.1-0.20250805215749-af0516f267b1/go.mod h1:TMmjqOeF1s3daSEOnOJw6yMBtgRpie45QjWEFIRKVO0= github.com/theupdateframework/notary v0.7.0 h1:QyagRZ7wlSpjT5N2qQAh/pN+DVqgekv4DzbAiAiEL3c= github.com/theupdateframework/notary v0.7.0/go.mod h1:c9DRxcmhHmVLDay4/2fUYdISnHqbFDGRSlXPO0AhYWw= github.com/tilt-dev/fsnotify v1.4.8-0.20220602155310-fff9c274a375 h1:QB54BJwA6x8QU9nHY3xJSZR2kX9bgpZekRKGkLTmEXA= @@ -489,13 +491,6 @@ github.com/vbatts/tar-split v0.12.1 h1:CqKoORW7BUWBe7UL/iqTVvkTBOF8UvOMKOIZykxnn github.com/vbatts/tar-split v0.12.1/go.mod h1:eF6B6i6ftWQcDqEn3/iGFRFRo8cBIMSJVOpnNdfTMFA= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= -github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc= github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -676,6 +671,8 @@ k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJ k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk= +pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= diff --git a/internal/sync/tar.go b/internal/sync/tar.go index 1abec82dbb7..94d1056941a 100644 --- a/internal/sync/tar.go +++ b/internal/sync/tar.go @@ -32,8 +32,8 @@ import ( "github.com/hashicorp/go-multierror" - "github.com/docker/docker/api/types/container" "github.com/moby/go-archive" + "github.com/moby/moby/api/types/container" ) type archiveEntry struct { diff --git a/internal/tracing/attributes.go b/internal/tracing/attributes.go index 2c8779bc86c..89570091505 100644 --- a/internal/tracing/attributes.go +++ b/internal/tracing/attributes.go @@ -25,7 +25,7 @@ import ( "time" "github.com/compose-spec/compose-go/v2/types" - "github.com/docker/docker/api/types/container" + "github.com/moby/moby/api/types/container" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" ) diff --git a/pkg/api/api.go b/pkg/api/api.go index a48b5ab5fa4..57f023b0c43 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -27,7 +27,7 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/containerd/platforms" "github.com/docker/cli/opts" - "github.com/docker/docker/api/types/volume" + "github.com/moby/moby/api/types/volume" ) // Service manages a compose project diff --git a/pkg/api/dryrunclient.go b/pkg/api/dryrunclient.go index b5ffc8ae6d3..576135504d8 100644 --- a/pkg/api/dryrunclient.go +++ b/pkg/api/dryrunclient.go @@ -33,20 +33,22 @@ import ( "github.com/docker/buildx/builder" "github.com/docker/buildx/util/imagetools" "github.com/docker/cli/cli/command" - moby "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/build" - "github.com/docker/docker/api/types/checkpoint" - containerType "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/image" - "github.com/docker/docker/api/types/network" - "github.com/docker/docker/api/types/registry" - "github.com/docker/docker/api/types/swarm" - "github.com/docker/docker/api/types/system" - "github.com/docker/docker/api/types/volume" - "github.com/docker/docker/client" - "github.com/docker/docker/pkg/jsonmessage" + moby "github.com/moby/moby/api/types" + "github.com/moby/moby/api/types/build" + "github.com/moby/moby/api/types/checkpoint" + containerType "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/events" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/image" + "github.com/moby/moby/api/types/jsonstream" + "github.com/moby/moby/api/types/network" + "github.com/moby/moby/api/types/plugin" + "github.com/moby/moby/api/types/registry" + "github.com/moby/moby/api/types/swarm" + "github.com/moby/moby/api/types/system" + "github.com/moby/moby/api/types/volume" + "github.com/moby/moby/client" + "github.com/moby/moby/client/pkg/jsonmessage" specs "github.com/opencontainers/image-spec/specs-go/v1" ) @@ -97,8 +99,8 @@ func getCallingFunction() string { // All methods and functions which need to be overridden for dry run. -func (d *DryRunClient) ContainerAttach(ctx context.Context, container string, options containerType.AttachOptions) (moby.HijackedResponse, error) { - return moby.HijackedResponse{}, errors.New("interactive run is not supported in dry-run mode") +func (d *DryRunClient) ContainerAttach(ctx context.Context, container string, options containerType.AttachOptions) (client.HijackedResponse, error) { + return client.HijackedResponse{}, errors.New("interactive run is not supported in dry-run mode") } func (d *DryRunClient) ContainerCreate(ctx context.Context, config *containerType.Config, hostConfig *containerType.HostConfig, @@ -258,11 +260,13 @@ func (d *DryRunClient) ImagePush(ctx context.Context, ref string, options image. jsonMessage, err := json.Marshal(&jsonmessage.JSONMessage{ Status: "Pushed", Progress: &jsonmessage.JSONProgress{ - Current: 100, - Total: 100, - Start: 0, - HideCounts: false, - Units: "Mb", + Progress: jsonstream.Progress{ + Current: 100, + Total: 100, + Start: 0, + HideCounts: false, + Units: "Mb", + }, }, ID: ref, }) @@ -363,8 +367,8 @@ func (d *DryRunClient) ContainerDiff(ctx context.Context, container string) ([]c return d.apiClient.ContainerDiff(ctx, container) } -func (d *DryRunClient) ContainerExecAttach(ctx context.Context, execID string, config containerType.ExecStartOptions) (moby.HijackedResponse, error) { - return moby.HijackedResponse{}, errors.New("interactive exec is not supported in dry-run mode") +func (d *DryRunClient) ContainerExecAttach(ctx context.Context, execID string, config containerType.ExecStartOptions) (client.HijackedResponse, error) { + return client.HijackedResponse{}, errors.New("interactive exec is not supported in dry-run mode") } func (d *DryRunClient) ContainerExecInspect(ctx context.Context, execID string) (containerType.ExecInspect, error) { @@ -395,11 +399,11 @@ func (d *DryRunClient) ContainerStatPath(ctx context.Context, container, path st return d.apiClient.ContainerStatPath(ctx, container, path) } -func (d *DryRunClient) ContainerStats(ctx context.Context, container string, stream bool) (containerType.StatsResponseReader, error) { +func (d *DryRunClient) ContainerStats(ctx context.Context, container string, stream bool) (client.StatsResponseReader, error) { return d.apiClient.ContainerStats(ctx, container, stream) } -func (d *DryRunClient) ContainerStatsOneShot(ctx context.Context, container string) (containerType.StatsResponseReader, error) { +func (d *DryRunClient) ContainerStatsOneShot(ctx context.Context, container string) (client.StatsResponseReader, error) { return d.apiClient.ContainerStatsOneShot(ctx, container) } @@ -499,27 +503,27 @@ func (d *DryRunClient) NetworksPrune(ctx context.Context, pruneFilter filters.Ar return d.apiClient.NetworksPrune(ctx, pruneFilter) } -func (d *DryRunClient) PluginList(ctx context.Context, filter filters.Args) (moby.PluginsListResponse, error) { +func (d *DryRunClient) PluginList(ctx context.Context, filter filters.Args) (plugin.ListResponse, error) { return d.apiClient.PluginList(ctx, filter) } -func (d *DryRunClient) PluginRemove(ctx context.Context, name string, options moby.PluginRemoveOptions) error { +func (d *DryRunClient) PluginRemove(ctx context.Context, name string, options client.PluginRemoveOptions) error { return d.apiClient.PluginRemove(ctx, name, options) } -func (d *DryRunClient) PluginEnable(ctx context.Context, name string, options moby.PluginEnableOptions) error { +func (d *DryRunClient) PluginEnable(ctx context.Context, name string, options client.PluginEnableOptions) error { return d.apiClient.PluginEnable(ctx, name, options) } -func (d *DryRunClient) PluginDisable(ctx context.Context, name string, options moby.PluginDisableOptions) error { +func (d *DryRunClient) PluginDisable(ctx context.Context, name string, options client.PluginDisableOptions) error { return d.apiClient.PluginDisable(ctx, name, options) } -func (d *DryRunClient) PluginInstall(ctx context.Context, name string, options moby.PluginInstallOptions) (io.ReadCloser, error) { +func (d *DryRunClient) PluginInstall(ctx context.Context, name string, options client.PluginInstallOptions) (io.ReadCloser, error) { return d.apiClient.PluginInstall(ctx, name, options) } -func (d *DryRunClient) PluginUpgrade(ctx context.Context, name string, options moby.PluginInstallOptions) (io.ReadCloser, error) { +func (d *DryRunClient) PluginUpgrade(ctx context.Context, name string, options client.PluginInstallOptions) (io.ReadCloser, error) { return d.apiClient.PluginUpgrade(ctx, name, options) } @@ -531,11 +535,11 @@ func (d *DryRunClient) PluginSet(ctx context.Context, name string, args []string return d.apiClient.PluginSet(ctx, name, args) } -func (d *DryRunClient) PluginInspectWithRaw(ctx context.Context, name string) (*moby.Plugin, []byte, error) { +func (d *DryRunClient) PluginInspectWithRaw(ctx context.Context, name string) (*plugin.Plugin, []byte, error) { return d.apiClient.PluginInspectWithRaw(ctx, name) } -func (d *DryRunClient) PluginCreate(ctx context.Context, createContext io.Reader, options moby.PluginCreateOptions) error { +func (d *DryRunClient) PluginCreate(ctx context.Context, createContext io.Reader, options client.PluginCreateOptions) error { return d.apiClient.PluginCreate(ctx, createContext, options) } @@ -635,7 +639,7 @@ func (d *DryRunClient) RegistryLogin(ctx context.Context, auth registry.AuthConf return d.apiClient.RegistryLogin(ctx, auth) } -func (d *DryRunClient) DiskUsage(ctx context.Context, options moby.DiskUsageOptions) (moby.DiskUsage, error) { +func (d *DryRunClient) DiskUsage(ctx context.Context, options system.DiskUsageOptions) (system.DiskUsage, error) { return d.apiClient.DiskUsage(ctx, options) } diff --git a/pkg/bridge/convert.go b/pkg/bridge/convert.go index 8e9995b824f..02905394847 100644 --- a/pkg/bridge/convert.go +++ b/pkg/bridge/convert.go @@ -32,11 +32,11 @@ import ( cli "github.com/docker/cli/cli/command/container" "github.com/docker/compose/v2/pkg/api" "github.com/docker/compose/v2/pkg/utils" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/image" - "github.com/docker/docker/api/types/network" - "github.com/docker/docker/pkg/jsonmessage" "github.com/docker/go-connections/nat" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/image" + "github.com/moby/moby/api/types/network" + "github.com/moby/moby/client/pkg/jsonmessage" "gopkg.in/yaml.v3" ) @@ -212,7 +212,8 @@ func inspectWithPull(ctx context.Context, dockerCli command.Cli, imageName strin } defer func() { _ = stream.Close() }() - err = jsonmessage.DisplayJSONMessagesToStream(stream, dockerCli.Out(), nil) + out := dockerCli.Out() + err = jsonmessage.DisplayJSONMessagesStream(stream, out, out.FD(), out.IsTerminal(), nil) if err != nil { return image.InspectResponse{}, err } diff --git a/pkg/bridge/transformers.go b/pkg/bridge/transformers.go index dbf4fc6d9dc..5497cdec1c6 100644 --- a/pkg/bridge/transformers.go +++ b/pkg/bridge/transformers.go @@ -23,11 +23,11 @@ import ( "path/filepath" "github.com/docker/cli/cli/command" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/image" - "github.com/docker/docker/api/types/network" "github.com/moby/go-archive" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/image" + "github.com/moby/moby/api/types/network" ) const ( diff --git a/pkg/compose/attach.go b/pkg/compose/attach.go index 897c4733170..5dfb684ddc6 100644 --- a/pkg/compose/attach.go +++ b/pkg/compose/attach.go @@ -25,8 +25,8 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/docker/cli/cli/streams" - containerType "github.com/docker/docker/api/types/container" - "github.com/docker/docker/pkg/stdcopy" + "github.com/moby/moby/api/pkg/stdcopy" + containerType "github.com/moby/moby/api/types/container" "github.com/moby/term" "github.com/docker/compose/v2/pkg/api" diff --git a/pkg/compose/build.go b/pkg/compose/build.go index c2fadee41be..365482a2b40 100644 --- a/pkg/compose/build.go +++ b/pkg/compose/build.go @@ -38,7 +38,6 @@ import ( "github.com/docker/compose/v2/pkg/api" "github.com/docker/compose/v2/pkg/progress" "github.com/docker/compose/v2/pkg/utils" - "github.com/docker/docker/api/types/container" bclient "github.com/moby/buildkit/client" "github.com/moby/buildkit/session" "github.com/moby/buildkit/session/auth/authprovider" @@ -46,6 +45,7 @@ import ( "github.com/moby/buildkit/session/sshforward/sshprovider" "github.com/moby/buildkit/util/entitlements" "github.com/moby/buildkit/util/progress/progressui" + "github.com/moby/moby/api/types/container" specs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/sirupsen/logrus" "go.opentelemetry.io/otel/attribute" diff --git a/pkg/compose/build_bake.go b/pkg/compose/build_bake.go index 730169045ab..6003aaa1361 100644 --- a/pkg/compose/build_bake.go +++ b/pkg/compose/build_bake.go @@ -38,12 +38,12 @@ import ( "github.com/docker/cli/cli-plugins/manager" "github.com/docker/cli/cli/command" "github.com/docker/compose/v2/pkg/api" + "github.com/docker/compose/v2/pkg/compose/internal/urlutil" "github.com/docker/compose/v2/pkg/progress" - "github.com/docker/docker/api/types/versions" - "github.com/docker/docker/builder/remotecontext/urlutil" "github.com/moby/buildkit/client" "github.com/moby/buildkit/util/gitutil" "github.com/moby/buildkit/util/progress/progressui" + "github.com/moby/moby/api/types/versions" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "golang.org/x/sync/errgroup" diff --git a/pkg/compose/build_classic.go b/pkg/compose/build_classic.go index 2de2c9c43e5..bb162e1be30 100644 --- a/pkg/compose/build_classic.go +++ b/pkg/compose/build_classic.go @@ -32,14 +32,15 @@ import ( "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/image/build" "github.com/docker/compose/v2/pkg/api" - buildtypes "github.com/docker/docker/api/types/build" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/registry" - "github.com/docker/docker/builder/remotecontext/urlutil" - "github.com/docker/docker/pkg/jsonmessage" - "github.com/docker/docker/pkg/progress" - "github.com/docker/docker/pkg/streamformatter" + "github.com/docker/compose/v2/pkg/compose/internal/urlutil" "github.com/moby/go-archive" + "github.com/moby/moby/api/pkg/progress" + "github.com/moby/moby/api/pkg/streamformatter" + buildtypes "github.com/moby/moby/api/types/build" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/jsonstream" + "github.com/moby/moby/api/types/registry" + "github.com/moby/moby/client/pkg/jsonmessage" "github.com/sirupsen/logrus" ) @@ -185,7 +186,7 @@ func (s *composeService) doBuildClassic(ctx context.Context, project *types.Proj err = jsonmessage.DisplayJSONMessagesStream(response.Body, buildBuff, progBuff.FD(), true, aux) if err != nil { - var jerr *jsonmessage.JSONError + var jerr *jsonstream.Error if errors.As(err, &jerr) { // If no error code is set, default to 1 if jerr.Code == 0 { diff --git a/pkg/compose/commit.go b/pkg/compose/commit.go index 85d19df7c7d..50fadf3f50a 100644 --- a/pkg/compose/commit.go +++ b/pkg/compose/commit.go @@ -23,7 +23,7 @@ import ( "github.com/docker/compose/v2/pkg/api" "github.com/docker/compose/v2/pkg/progress" - "github.com/docker/docker/api/types/container" + "github.com/moby/moby/api/types/container" ) func (s *composeService) Commit(ctx context.Context, projectName string, options api.CommitOptions) error { diff --git a/pkg/compose/compose.go b/pkg/compose/compose.go index 10c32255493..d3597363d89 100644 --- a/pkg/compose/compose.go +++ b/pkg/compose/compose.go @@ -30,13 +30,13 @@ import ( "github.com/docker/cli/cli/config/configfile" "github.com/docker/cli/cli/flags" "github.com/docker/cli/cli/streams" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/network" - "github.com/docker/docker/api/types/swarm" - "github.com/docker/docker/api/types/volume" - "github.com/docker/docker/client" "github.com/jonboulle/clockwork" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/network" + "github.com/moby/moby/api/types/swarm" + "github.com/moby/moby/api/types/volume" + "github.com/moby/moby/client" "github.com/docker/compose/v2/internal/desktop" "github.com/docker/compose/v2/internal/experimental" diff --git a/pkg/compose/container.go b/pkg/compose/container.go index 004ac41677d..acbdc5193a7 100644 --- a/pkg/compose/container.go +++ b/pkg/compose/container.go @@ -19,31 +19,25 @@ package compose import ( "io" - moby "github.com/docker/docker/api/types" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/client" ) const ( - // ContainerCreated created status - ContainerCreated = "created" - // ContainerRestarting restarting status - ContainerRestarting = "restarting" - // ContainerRunning running status - ContainerRunning = "running" - // ContainerRemoving removing status - ContainerRemoving = "removing" - // ContainerPaused paused status - ContainerPaused = "paused" - // ContainerExited exited status - ContainerExited = "exited" - // ContainerDead dead status - ContainerDead = "dead" + ContainerCreated = container.StateCreated // StateCreated indicates the container is created, but not (yet) started. + ContainerRunning = container.StateRunning // StateRunning indicates that the container is running. + ContainerPaused = container.StatePaused // StatePaused indicates that the container's current state is paused. + ContainerRestarting = container.StateRestarting // StateRestarting indicates that the container is currently restarting. + ContainerRemoving = container.StateRemoving // StateRemoving indicates that the container is being removed. + ContainerExited = container.StateExited // StateExited indicates that the container exited. + ContainerDead = container.StateDead // StateDead indicates that the container failed to be deleted. Containers in this state are attempted to be cleaned up when the daemon restarts. ) var _ io.ReadCloser = ContainerStdout{} // ContainerStdout implement ReadCloser for moby.HijackedResponse type ContainerStdout struct { - moby.HijackedResponse + client.HijackedResponse } // Read implement io.ReadCloser @@ -61,7 +55,7 @@ var _ io.WriteCloser = ContainerStdin{} // ContainerStdin implement WriteCloser for moby.HijackedResponse type ContainerStdin struct { - moby.HijackedResponse + client.HijackedResponse } // Write implement io.WriteCloser diff --git a/pkg/compose/containers.go b/pkg/compose/containers.go index 598cc2a234e..a943e927cf7 100644 --- a/pkg/compose/containers.go +++ b/pkg/compose/containers.go @@ -25,8 +25,8 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" ) // Containers is a set of moby Container @@ -135,7 +135,7 @@ func isOrphaned(project *types.Project) containerPredicate { // One-off container v, ok := c.Labels[api.OneoffLabel] if ok && v == "True" { - return c.State == ContainerExited || c.State == ContainerDead + return c.State == container.StateExited || c.State == container.StateDead } // Service that is not defined in the compose model service := c.Labels[api.ServiceLabel] diff --git a/pkg/compose/convergence.go b/pkg/compose/convergence.go index c43f6cc76fb..94f07249ba4 100644 --- a/pkg/compose/convergence.go +++ b/pkg/compose/convergence.go @@ -29,9 +29,9 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/containerd/platforms" - containerType "github.com/docker/docker/api/types/container" - mmount "github.com/docker/docker/api/types/mount" - "github.com/docker/docker/api/types/versions" + containerType "github.com/moby/moby/api/types/container" + mmount "github.com/moby/moby/api/types/mount" + "github.com/moby/moby/api/types/versions" specs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/sirupsen/logrus" "go.opentelemetry.io/otel/attribute" @@ -186,11 +186,11 @@ func (c *convergence) ensureService(ctx context.Context, project *types.Project, w := progress.ContextWriter(ctx) name := getContainerProgressName(container) switch container.State { - case ContainerRunning: + case containerType.StateRunning: w.Event(progress.RunningEvent(name)) - case ContainerCreated: - case ContainerRestarting: - case ContainerExited: + case containerType.StateCreated: + case containerType.StateRestarting: + case containerType.StateExited: default: container := container eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "service/start", tracing.ContainerOptions(container), func(ctx context.Context) error { @@ -244,7 +244,7 @@ func (c *convergence) stopDependentContainers(ctx context.Context, project *type for _, name := range dependents { dependentStates := c.getObservedState(name) for i, dependent := range dependentStates { - dependent.State = ContainerExited + dependent.State = containerType.StateExited dependentStates[i] = dependent } c.setObservedState(name, dependentStates) @@ -895,7 +895,7 @@ func (s *composeService) startService(ctx context.Context, w := progress.ContextWriter(ctx) for _, ctr := range containers.filter(isService(service.Name)) { - if ctr.State == ContainerRunning { + if ctr.State == containerType.StateRunning { continue } diff --git a/pkg/compose/convergence_test.go b/pkg/compose/convergence_test.go index 319c811e765..a8db5d3fb8c 100644 --- a/pkg/compose/convergence_test.go +++ b/pkg/compose/convergence_test.go @@ -24,12 +24,12 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/docker/cli/cli/config/configfile" - moby "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/image" - "github.com/docker/docker/api/types/network" "github.com/docker/go-connections/nat" + moby "github.com/moby/moby/api/types" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/image" + "github.com/moby/moby/api/types/network" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" diff --git a/pkg/compose/convert.go b/pkg/compose/convert.go index 17d5a901869..44b8d2b2861 100644 --- a/pkg/compose/convert.go +++ b/pkg/compose/convert.go @@ -23,8 +23,8 @@ import ( "time" compose "github.com/compose-spec/compose-go/v2/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/versions" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/versions" ) // ToMobyEnv convert into []string diff --git a/pkg/compose/cp.go b/pkg/compose/cp.go index b7db3296989..050534503a6 100644 --- a/pkg/compose/cp.go +++ b/pkg/compose/cp.go @@ -30,8 +30,8 @@ import ( "github.com/docker/cli/cli/command" "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/api/types/container" "github.com/moby/go-archive" + "github.com/moby/moby/api/types/container" ) type copyDirection int diff --git a/pkg/compose/create.go b/pkg/compose/create.go index 04c887a7ebd..c568a915598 100644 --- a/pkg/compose/create.go +++ b/pkg/compose/create.go @@ -31,14 +31,14 @@ import ( "github.com/compose-spec/compose-go/v2/paths" "github.com/compose-spec/compose-go/v2/types" "github.com/containerd/errdefs" - "github.com/docker/docker/api/types/blkiodev" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/mount" - "github.com/docker/docker/api/types/network" - "github.com/docker/docker/api/types/versions" - volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/go-connections/nat" + "github.com/moby/moby/api/types/blkiodev" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/mount" + "github.com/moby/moby/api/types/network" + "github.com/moby/moby/api/types/versions" + volumetypes "github.com/moby/moby/api/types/volume" "github.com/sirupsen/logrus" cdi "tags.cncf.io/container-device-interface/pkg/parser" diff --git a/pkg/compose/create_test.go b/pkg/compose/create_test.go index 3394bf3c936..399d3b24a5d 100644 --- a/pkg/compose/create_test.go +++ b/pkg/compose/create_test.go @@ -24,16 +24,16 @@ import ( "testing" composeloader "github.com/compose-spec/compose-go/v2/loader" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/image" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/image" "go.uber.org/mock/gomock" "gotest.tools/v3/assert/cmp" "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/api/types/network" + "github.com/moby/moby/api/types/network" composetypes "github.com/compose-spec/compose-go/v2/types" - mountTypes "github.com/docker/docker/api/types/mount" + mountTypes "github.com/moby/moby/api/types/mount" "gotest.tools/v3/assert" ) diff --git a/pkg/compose/down.go b/pkg/compose/down.go index e9619fbe652..f77abdf2f1d 100644 --- a/pkg/compose/down.go +++ b/pkg/compose/down.go @@ -27,10 +27,10 @@ import ( "github.com/docker/compose/v2/pkg/api" "github.com/docker/compose/v2/pkg/progress" "github.com/docker/compose/v2/pkg/utils" - containerType "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - imageapi "github.com/docker/docker/api/types/image" - "github.com/docker/docker/api/types/network" + containerType "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + imageapi "github.com/moby/moby/api/types/image" + "github.com/moby/moby/api/types/network" "github.com/sirupsen/logrus" "golang.org/x/sync/errgroup" ) diff --git a/pkg/compose/down_test.go b/pkg/compose/down_test.go index 58c1ec0b14c..36a37fb0b30 100644 --- a/pkg/compose/down_test.go +++ b/pkg/compose/down_test.go @@ -26,11 +26,11 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/containerd/errdefs" "github.com/docker/cli/cli/streams" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/image" - "github.com/docker/docker/api/types/network" - "github.com/docker/docker/api/types/volume" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/image" + "github.com/moby/moby/api/types/network" + "github.com/moby/moby/api/types/volume" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" diff --git a/pkg/compose/events.go b/pkg/compose/events.go index 7ea8dc32651..8f778aeaa11 100644 --- a/pkg/compose/events.go +++ b/pkg/compose/events.go @@ -22,8 +22,8 @@ import ( "strings" "time" - "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/filters" + "github.com/moby/moby/api/types/events" + "github.com/moby/moby/api/types/filters" "github.com/docker/compose/v2/pkg/api" ) diff --git a/pkg/compose/exec.go b/pkg/compose/exec.go index a57e29e4ec7..7fb7691246c 100644 --- a/pkg/compose/exec.go +++ b/pkg/compose/exec.go @@ -24,7 +24,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command/container" "github.com/docker/compose/v2/pkg/api" - containerType "github.com/docker/docker/api/types/container" + containerType "github.com/moby/moby/api/types/container" ) func (s *composeService) Exec(ctx context.Context, projectName string, options api.RunOptions) (int, error) { diff --git a/pkg/compose/filters.go b/pkg/compose/filters.go index d6c814977ec..fa8d7e5c9c8 100644 --- a/pkg/compose/filters.go +++ b/pkg/compose/filters.go @@ -20,7 +20,7 @@ import ( "fmt" "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/api/types/filters" + "github.com/moby/moby/api/types/filters" ) func projectFilter(projectName string) filters.KeyValuePair { diff --git a/pkg/compose/generate.go b/pkg/compose/generate.go index 025d5093d55..eb85b041c7e 100644 --- a/pkg/compose/generate.go +++ b/pkg/compose/generate.go @@ -25,10 +25,10 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/mount" - "github.com/docker/docker/api/types/network" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/mount" + "github.com/moby/moby/api/types/network" ) func (s *composeService) Generate(ctx context.Context, options api.GenerateOptions) (*types.Project, error) { diff --git a/pkg/compose/hook.go b/pkg/compose/hook.go index dd02de640a3..5e1ba5dd90e 100644 --- a/pkg/compose/hook.go +++ b/pkg/compose/hook.go @@ -25,8 +25,8 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/docker/compose/v2/pkg/api" "github.com/docker/compose/v2/pkg/utils" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/pkg/stdcopy" + "github.com/moby/moby/api/pkg/stdcopy" + "github.com/moby/moby/api/types/container" ) func (s composeService) runHook(ctx context.Context, ctr container.Summary, service types.ServiceConfig, hook types.ServiceHook, listener api.ContainerEventListener) error { diff --git a/pkg/compose/image_pruner.go b/pkg/compose/image_pruner.go index bb4d0bc47d6..cdc0c665edd 100644 --- a/pkg/compose/image_pruner.go +++ b/pkg/compose/image_pruner.go @@ -25,9 +25,9 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/containerd/errdefs" "github.com/distribution/reference" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/image" - "github.com/docker/docker/client" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/image" + "github.com/moby/moby/client" "golang.org/x/sync/errgroup" "github.com/docker/compose/v2/pkg/api" diff --git a/pkg/compose/images.go b/pkg/compose/images.go index a91d6159f4b..84e025f0d71 100644 --- a/pkg/compose/images.go +++ b/pkg/compose/images.go @@ -26,10 +26,10 @@ import ( "github.com/containerd/errdefs" "github.com/containerd/platforms" "github.com/distribution/reference" - "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/client" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/versions" + "github.com/moby/moby/client" "golang.org/x/sync/errgroup" "github.com/docker/compose/v2/pkg/api" diff --git a/pkg/compose/images_test.go b/pkg/compose/images_test.go index a7a1d5e9a36..05178275f71 100644 --- a/pkg/compose/images_test.go +++ b/pkg/compose/images_test.go @@ -21,10 +21,10 @@ import ( "strings" "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/moby/moby/api/types" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/image" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" diff --git a/pkg/compose/internal/urlutil/urlutil.go b/pkg/compose/internal/urlutil/urlutil.go new file mode 100644 index 00000000000..ee464cd7a8b --- /dev/null +++ b/pkg/compose/internal/urlutil/urlutil.go @@ -0,0 +1,105 @@ +/* + Copyright 2020 Docker Compose CLI authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Package urlutil provides helper function to check if a given build-context +// location should be considered a URL or a remote Git repository. +// +// This package is specifically written for use with docker build contexts, and +// should not be used as a general-purpose utility. +package urlutil + +import ( + "regexp" + "strings" + "sync" +) + +// urlPathWithFragmentSuffix matches fragments to use as Git reference and build +// context from the Git repository. See IsGitURL for details. +var urlPathWithFragmentSuffix = sync.OnceValue(func() *regexp.Regexp { + return regexp.MustCompile(`\.git(?:#.+)?$`) +}) + +// IsURL returns true if the provided str is an HTTP(S) URL by checking if it +// has a http:// or https:// scheme. No validation is performed to verify if the +// URL is well-formed. +func IsURL(str string) bool { + return strings.HasPrefix(str, "https://") || strings.HasPrefix(str, "http://") +} + +// IsGitURL returns true if the provided str is a remote git repository "URL". +// +// This function only performs a rudimentary check (no validation is performed +// to ensure the URL is well-formed), and is written specifically for use with +// docker build, with some logic for backward compatibility with older versions +// of docker: do not use this function as a general-purpose utility. +// +// The following patterns are considered to be a Git URL: +// +// - https://(.*).git(?:#.+)?$ git repository URL with optional fragment, as known to be used by GitHub and GitLab. +// - http://(.*).git(?:#.+)?$ same, but non-TLS +// - git://(.*) URLs using git:// scheme +// - git@(.*) +// - github.com/ see description below +// +// The github.com/ prefix is a special case used to treat context-paths +// starting with "github.com/" as a git URL if the given path does not +// exist locally. The "github.com/" prefix is kept for backward compatibility, +// and is a legacy feature. +// +// Going forward, no additional prefixes should be added, and users should +// be encouraged to use explicit URLs (https://github.com/user/repo.git) instead. +// +// Note that IsGitURL does not check if "github.com/" prefixes exist as a local +// path. Code using this function should check if the path exists locally before +// using it as a URL. +// +// # Fragments +// +// Git URLs accept context configuration in their fragment section, separated by +// a colon (`:`). The first part represents the reference to check out, and can +// be either a branch, a tag, or a remote reference. The second part represents +// a subdirectory inside the repository to use as the build context. +// +// For example,the following URL uses a directory named "docker" in the branch +// "container" in the https://github.com/myorg/my-repo.git repository: +// +// https://github.com/myorg/my-repo.git#container:docker +// +// The following table represents all the valid suffixes with their build +// contexts: +// +// | Build Syntax Suffix | Git reference used | Build Context Used | +// |--------------------------------|----------------------|--------------------| +// | my-repo.git | refs/heads/master | / | +// | my-repo.git#mytag | refs/tags/my-tag | / | +// | my-repo.git#mybranch | refs/heads/my-branch | / | +// | my-repo.git#pull/42/head | refs/pull/42/head | / | +// | my-repo.git#:directory | refs/heads/master | /directory | +// | my-repo.git#master:directory | refs/heads/master | /directory | +// | my-repo.git#mytag:directory | refs/tags/my-tag | /directory | +// | my-repo.git#mybranch:directory | refs/heads/my-branch | /directory | +func IsGitURL(str string) bool { + if IsURL(str) && urlPathWithFragmentSuffix().MatchString(str) { + return true + } + for _, prefix := range []string{"git://", "github.com/", "git@"} { + if strings.HasPrefix(str, prefix) { + return true + } + } + return false +} diff --git a/pkg/compose/internal/urlutil/urlutil_test.go b/pkg/compose/internal/urlutil/urlutil_test.go new file mode 100644 index 00000000000..42acf2ecc72 --- /dev/null +++ b/pkg/compose/internal/urlutil/urlutil_test.go @@ -0,0 +1,58 @@ +/* + Copyright 2020 Docker Compose CLI authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package urlutil + +import "testing" + +var ( + gitUrls = []string{ + "git://github.com/docker/docker", + "git@github.com:docker/docker.git", + "git@bitbucket.org:atlassianlabs/atlassian-docker.git", + "https://github.com/docker/docker.git", + "http://github.com/docker/docker.git", + "http://github.com/docker/docker.git#branch", + "http://github.com/docker/docker.git#:dir", + } + incompleteGitUrls = []string{ + "github.com/docker/docker", + } + invalidGitUrls = []string{ + "http://github.com/docker/docker.git:#branch", + "https://github.com/docker/dgit", + } +) + +func TestIsGIT(t *testing.T) { + for _, url := range gitUrls { + if !IsGitURL(url) { + t.Fatalf("%q should be detected as valid Git url", url) + } + } + + for _, url := range incompleteGitUrls { + if !IsGitURL(url) { + t.Fatalf("%q should be detected as valid Git url", url) + } + } + + for _, url := range invalidGitUrls { + if IsGitURL(url) { + t.Fatalf("%q should not be detected as valid Git prefix", url) + } + } +} diff --git a/pkg/compose/kill.go b/pkg/compose/kill.go index badf90e03e4..9ddc5c65066 100644 --- a/pkg/compose/kill.go +++ b/pkg/compose/kill.go @@ -21,7 +21,7 @@ import ( "fmt" "strings" - "github.com/docker/docker/api/types/container" + "github.com/moby/moby/api/types/container" "golang.org/x/sync/errgroup" "github.com/docker/compose/v2/pkg/api" diff --git a/pkg/compose/kill_test.go b/pkg/compose/kill_test.go index 32a8f773019..c195ba7c2db 100644 --- a/pkg/compose/kill_test.go +++ b/pkg/compose/kill_test.go @@ -23,10 +23,10 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/network" - "github.com/docker/docker/api/types/volume" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/network" + "github.com/moby/moby/api/types/volume" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" @@ -111,7 +111,7 @@ func testContainer(service string, id string, oneOff bool) container.Summary { ID: id, Names: []string{name}, Labels: containerLabels(service, oneOff), - State: ContainerExited, + State: container.StateExited, } } diff --git a/pkg/compose/logs.go b/pkg/compose/logs.go index b3b44d53e11..2feb33bb854 100644 --- a/pkg/compose/logs.go +++ b/pkg/compose/logs.go @@ -21,8 +21,8 @@ import ( "io" "github.com/containerd/errdefs" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/pkg/stdcopy" + "github.com/moby/moby/api/pkg/stdcopy" + "github.com/moby/moby/api/types/container" "github.com/sirupsen/logrus" "golang.org/x/sync/errgroup" diff --git a/pkg/compose/logs_test.go b/pkg/compose/logs_test.go index 955b5e770d5..907e9478a96 100644 --- a/pkg/compose/logs_test.go +++ b/pkg/compose/logs_test.go @@ -24,9 +24,9 @@ import ( "testing" "github.com/compose-spec/compose-go/v2/types" - containerType "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/pkg/stdcopy" + "github.com/moby/moby/api/pkg/stdcopy" + containerType "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/pkg/compose/ls.go b/pkg/compose/ls.go index 403b061a8ae..f298d4a3f74 100644 --- a/pkg/compose/ls.go +++ b/pkg/compose/ls.go @@ -24,8 +24,8 @@ import ( "strings" "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" "github.com/sirupsen/logrus" ) diff --git a/pkg/compose/ls_test.go b/pkg/compose/ls_test.go index 847814c6f67..e30d0841bcd 100644 --- a/pkg/compose/ls_test.go +++ b/pkg/compose/ls_test.go @@ -21,7 +21,7 @@ import ( "testing" "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/api/types/container" + "github.com/moby/moby/api/types/container" "gotest.tools/v3/assert" ) diff --git a/pkg/compose/monitor.go b/pkg/compose/monitor.go index 6952b4e6816..a3098bcd79e 100644 --- a/pkg/compose/monitor.go +++ b/pkg/compose/monitor.go @@ -21,10 +21,10 @@ import ( "strconv" "github.com/containerd/errdefs" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/client" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/events" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/client" "github.com/sirupsen/logrus" "github.com/docker/compose/v2/pkg/api" diff --git a/pkg/compose/pause.go b/pkg/compose/pause.go index 4f86d0e0920..2de227c36df 100644 --- a/pkg/compose/pause.go +++ b/pkg/compose/pause.go @@ -20,7 +20,7 @@ import ( "context" "strings" - "github.com/docker/docker/api/types/container" + "github.com/moby/moby/api/types/container" "golang.org/x/sync/errgroup" "github.com/docker/compose/v2/pkg/api" diff --git a/pkg/compose/port.go b/pkg/compose/port.go index 35c2832ac2c..ab00607b691 100644 --- a/pkg/compose/port.go +++ b/pkg/compose/port.go @@ -22,7 +22,7 @@ import ( "strings" "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/api/types/container" + "github.com/moby/moby/api/types/container" ) func (s *composeService) Port(ctx context.Context, projectName string, service string, port uint16, options api.PortOptions) (string, int, error) { diff --git a/pkg/compose/ps_test.go b/pkg/compose/ps_test.go index 41cd807e32f..c3bdd85b926 100644 --- a/pkg/compose/ps_test.go +++ b/pkg/compose/ps_test.go @@ -21,12 +21,12 @@ import ( "strings" "testing" - containerType "github.com/docker/docker/api/types/container" + containerType "github.com/moby/moby/api/types/container" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" compose "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/api/types/filters" + "github.com/moby/moby/api/types/filters" ) func TestPs(t *testing.T) { diff --git a/pkg/compose/pull.go b/pkg/compose/pull.go index 7b6389fce02..169676f5eb0 100644 --- a/pkg/compose/pull.go +++ b/pkg/compose/pull.go @@ -31,10 +31,10 @@ import ( "github.com/distribution/reference" "github.com/docker/buildx/driver" "github.com/docker/cli/cli/config/configfile" - "github.com/docker/docker/api/types/image" - "github.com/docker/docker/client" - "github.com/docker/docker/pkg/jsonmessage" "github.com/hashicorp/go-multierror" + "github.com/moby/moby/api/types/image" + "github.com/moby/moby/client" + "github.com/moby/moby/client/pkg/jsonmessage" "github.com/opencontainers/go-digest" "golang.org/x/sync/errgroup" diff --git a/pkg/compose/push.go b/pkg/compose/push.go index 97477eed866..eb11f9a319c 100644 --- a/pkg/compose/push.go +++ b/pkg/compose/push.go @@ -28,8 +28,8 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/distribution/reference" "github.com/docker/buildx/driver" - "github.com/docker/docker/api/types/image" - "github.com/docker/docker/pkg/jsonmessage" + "github.com/moby/moby/api/types/image" + "github.com/moby/moby/client/pkg/jsonmessage" "golang.org/x/sync/errgroup" "github.com/docker/compose/v2/internal/registry" diff --git a/pkg/compose/remove.go b/pkg/compose/remove.go index e8515a79a77..bd6b64c070c 100644 --- a/pkg/compose/remove.go +++ b/pkg/compose/remove.go @@ -22,7 +22,7 @@ import ( "strings" "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/api/types/container" + "github.com/moby/moby/api/types/container" "golang.org/x/sync/errgroup" "github.com/docker/compose/v2/pkg/progress" diff --git a/pkg/compose/restart.go b/pkg/compose/restart.go index 4de9622310f..a56565de32e 100644 --- a/pkg/compose/restart.go +++ b/pkg/compose/restart.go @@ -24,7 +24,7 @@ import ( "github.com/docker/compose/v2/pkg/api" "github.com/docker/compose/v2/pkg/progress" "github.com/docker/compose/v2/pkg/utils" - "github.com/docker/docker/api/types/container" + "github.com/moby/moby/api/types/container" "golang.org/x/sync/errgroup" ) diff --git a/pkg/compose/run.go b/pkg/compose/run.go index 242f2fc1cce..7ed8b5a1742 100644 --- a/pkg/compose/run.go +++ b/pkg/compose/run.go @@ -29,7 +29,7 @@ import ( cmd "github.com/docker/cli/cli/command/container" "github.com/docker/compose/v2/pkg/api" "github.com/docker/compose/v2/pkg/progress" - "github.com/docker/docker/pkg/stringid" + "github.com/moby/moby/client/pkg/stringid" ) func (s *composeService) RunOneOffContainer(ctx context.Context, project *types.Project, opts api.RunOptions) (int, error) { diff --git a/pkg/compose/secrets.go b/pkg/compose/secrets.go index e8064cca8b2..871713d1922 100644 --- a/pkg/compose/secrets.go +++ b/pkg/compose/secrets.go @@ -25,7 +25,7 @@ import ( "time" "github.com/compose-spec/compose-go/v2/types" - "github.com/docker/docker/api/types/container" + "github.com/moby/moby/api/types/container" ) func (s *composeService) injectSecrets(ctx context.Context, project *types.Project, service types.ServiceConfig, id string) error { diff --git a/pkg/compose/start.go b/pkg/compose/start.go index b0bde1f688b..f8b79537e19 100644 --- a/pkg/compose/start.go +++ b/pkg/compose/start.go @@ -24,10 +24,10 @@ import ( "github.com/docker/compose/v2/pkg/api" "github.com/docker/compose/v2/pkg/progress" - containerType "github.com/docker/docker/api/types/container" + containerType "github.com/moby/moby/api/types/container" "github.com/compose-spec/compose-go/v2/types" - "github.com/docker/docker/api/types/filters" + "github.com/moby/moby/api/types/filters" ) func (s *composeService) Start(ctx context.Context, projectName string, options api.StartOptions) error { diff --git a/pkg/compose/stop_test.go b/pkg/compose/stop_test.go index 9c5d79ef7e7..4b4d50a2739 100644 --- a/pkg/compose/stop_test.go +++ b/pkg/compose/stop_test.go @@ -22,10 +22,10 @@ import ( "testing" "time" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/network" - "github.com/docker/docker/api/types/volume" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/network" + "github.com/moby/moby/api/types/volume" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" diff --git a/pkg/compose/volumes.go b/pkg/compose/volumes.go index 8c7bbed2f6f..a206adba52c 100644 --- a/pkg/compose/volumes.go +++ b/pkg/compose/volumes.go @@ -22,9 +22,9 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/volume" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/volume" ) func (s *composeService) Volumes(ctx context.Context, project *types.Project, options api.VolumesOptions) ([]api.VolumesSummary, error) { diff --git a/pkg/compose/volumes_test.go b/pkg/compose/volumes_test.go index 8e149159b23..e2fc96f9f2f 100644 --- a/pkg/compose/volumes_test.go +++ b/pkg/compose/volumes_test.go @@ -22,9 +22,9 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/docker/compose/v2/pkg/api" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/volume" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/volume" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" ) diff --git a/pkg/compose/watch.go b/pkg/compose/watch.go index 60281dd0ed9..6ee4489e863 100644 --- a/pkg/compose/watch.go +++ b/pkg/compose/watch.go @@ -40,10 +40,10 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/compose-spec/compose-go/v2/utils" ccli "github.com/docker/cli/cli/command/container" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/image" "github.com/mitchellh/mapstructure" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/image" "github.com/sirupsen/logrus" "golang.org/x/sync/errgroup" ) diff --git a/pkg/compose/watch_test.go b/pkg/compose/watch_test.go index c009fdfc04e..64ed2c0974a 100644 --- a/pkg/compose/watch_test.go +++ b/pkg/compose/watch_test.go @@ -27,10 +27,10 @@ import ( "github.com/docker/compose/v2/pkg/api" "github.com/docker/compose/v2/pkg/mocks" "github.com/docker/compose/v2/pkg/watch" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/image" "github.com/jonboulle/clockwork" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/image" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" diff --git a/pkg/mocks/mock_docker_api.go b/pkg/mocks/mock_docker_api.go index 4a6ebaaccf4..82e2a2c01f7 100644 --- a/pkg/mocks/mock_docker_api.go +++ b/pkg/mocks/mock_docker_api.go @@ -16,20 +16,21 @@ import ( http "net/http" reflect "reflect" - types "github.com/docker/docker/api/types" - build "github.com/docker/docker/api/types/build" - checkpoint "github.com/docker/docker/api/types/checkpoint" - common "github.com/docker/docker/api/types/common" - container "github.com/docker/docker/api/types/container" - events "github.com/docker/docker/api/types/events" - filters "github.com/docker/docker/api/types/filters" - image "github.com/docker/docker/api/types/image" - network "github.com/docker/docker/api/types/network" - registry "github.com/docker/docker/api/types/registry" - swarm "github.com/docker/docker/api/types/swarm" - system "github.com/docker/docker/api/types/system" - volume "github.com/docker/docker/api/types/volume" - client "github.com/docker/docker/client" + types "github.com/moby/moby/api/types" + build "github.com/moby/moby/api/types/build" + checkpoint "github.com/moby/moby/api/types/checkpoint" + common "github.com/moby/moby/api/types/common" + container "github.com/moby/moby/api/types/container" + events "github.com/moby/moby/api/types/events" + filters "github.com/moby/moby/api/types/filters" + image "github.com/moby/moby/api/types/image" + network "github.com/moby/moby/api/types/network" + "github.com/moby/moby/api/types/plugin" + registry "github.com/moby/moby/api/types/registry" + swarm "github.com/moby/moby/api/types/swarm" + system "github.com/moby/moby/api/types/system" + volume "github.com/moby/moby/api/types/volume" + client "github.com/moby/moby/client" v1 "github.com/opencontainers/image-spec/specs-go/v1" gomock "go.uber.org/mock/gomock" ) @@ -232,10 +233,10 @@ func (mr *MockAPIClientMockRecorder) ConfigUpdate(arg0, arg1, arg2, arg3 any) *g } // ContainerAttach mocks base method. -func (m *MockAPIClient) ContainerAttach(arg0 context.Context, arg1 string, arg2 container.AttachOptions) (types.HijackedResponse, error) { +func (m *MockAPIClient) ContainerAttach(arg0 context.Context, arg1 string, arg2 container.AttachOptions) (client.HijackedResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ContainerAttach", arg0, arg1, arg2) - ret0, _ := ret[0].(types.HijackedResponse) + ret0, _ := ret[0].(client.HijackedResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -292,10 +293,10 @@ func (mr *MockAPIClientMockRecorder) ContainerDiff(arg0, arg1 any) *gomock.Call } // ContainerExecAttach mocks base method. -func (m *MockAPIClient) ContainerExecAttach(arg0 context.Context, arg1 string, arg2 container.ExecStartOptions) (types.HijackedResponse, error) { +func (m *MockAPIClient) ContainerExecAttach(arg0 context.Context, arg1 string, arg2 container.ExecStartOptions) (client.HijackedResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ContainerExecAttach", arg0, arg1, arg2) - ret0, _ := ret[0].(types.HijackedResponse) + ret0, _ := ret[0].(client.HijackedResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -554,10 +555,10 @@ func (mr *MockAPIClientMockRecorder) ContainerStatPath(arg0, arg1, arg2 any) *go } // ContainerStats mocks base method. -func (m *MockAPIClient) ContainerStats(arg0 context.Context, arg1 string, arg2 bool) (container.StatsResponseReader, error) { +func (m *MockAPIClient) ContainerStats(arg0 context.Context, arg1 string, arg2 bool) (client.StatsResponseReader, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ContainerStats", arg0, arg1, arg2) - ret0, _ := ret[0].(container.StatsResponseReader) + ret0, _ := ret[0].(client.StatsResponseReader) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -569,10 +570,10 @@ func (mr *MockAPIClientMockRecorder) ContainerStats(arg0, arg1, arg2 any) *gomoc } // ContainerStatsOneShot mocks base method. -func (m *MockAPIClient) ContainerStatsOneShot(arg0 context.Context, arg1 string) (container.StatsResponseReader, error) { +func (m *MockAPIClient) ContainerStatsOneShot(arg0 context.Context, arg1 string) (client.StatsResponseReader, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ContainerStatsOneShot", arg0, arg1) - ret0, _ := ret[0].(container.StatsResponseReader) + ret0, _ := ret[0].(client.StatsResponseReader) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -745,10 +746,10 @@ func (mr *MockAPIClientMockRecorder) Dialer() *gomock.Call { } // DiskUsage mocks base method. -func (m *MockAPIClient) DiskUsage(arg0 context.Context, arg1 types.DiskUsageOptions) (types.DiskUsage, error) { +func (m *MockAPIClient) DiskUsage(arg0 context.Context, arg1 system.DiskUsageOptions) (system.DiskUsage, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DiskUsage", arg0, arg1) - ret0, _ := ret[0].(types.DiskUsage) + ret0, _ := ret[0].(system.DiskUsage) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -1280,7 +1281,7 @@ func (mr *MockAPIClientMockRecorder) Ping(arg0 any) *gomock.Call { } // PluginCreate mocks base method. -func (m *MockAPIClient) PluginCreate(arg0 context.Context, arg1 io.Reader, arg2 types.PluginCreateOptions) error { +func (m *MockAPIClient) PluginCreate(arg0 context.Context, arg1 io.Reader, arg2 client.PluginCreateOptions) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PluginCreate", arg0, arg1, arg2) ret0, _ := ret[0].(error) @@ -1294,7 +1295,7 @@ func (mr *MockAPIClientMockRecorder) PluginCreate(arg0, arg1, arg2 any) *gomock. } // PluginDisable mocks base method. -func (m *MockAPIClient) PluginDisable(arg0 context.Context, arg1 string, arg2 types.PluginDisableOptions) error { +func (m *MockAPIClient) PluginDisable(arg0 context.Context, arg1 string, arg2 client.PluginDisableOptions) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PluginDisable", arg0, arg1, arg2) ret0, _ := ret[0].(error) @@ -1308,7 +1309,7 @@ func (mr *MockAPIClientMockRecorder) PluginDisable(arg0, arg1, arg2 any) *gomock } // PluginEnable mocks base method. -func (m *MockAPIClient) PluginEnable(arg0 context.Context, arg1 string, arg2 types.PluginEnableOptions) error { +func (m *MockAPIClient) PluginEnable(arg0 context.Context, arg1 string, arg2 client.PluginEnableOptions) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PluginEnable", arg0, arg1, arg2) ret0, _ := ret[0].(error) @@ -1322,10 +1323,10 @@ func (mr *MockAPIClientMockRecorder) PluginEnable(arg0, arg1, arg2 any) *gomock. } // PluginInspectWithRaw mocks base method. -func (m *MockAPIClient) PluginInspectWithRaw(arg0 context.Context, arg1 string) (*types.Plugin, []byte, error) { +func (m *MockAPIClient) PluginInspectWithRaw(arg0 context.Context, arg1 string) (*plugin.Plugin, []byte, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PluginInspectWithRaw", arg0, arg1) - ret0, _ := ret[0].(*types.Plugin) + ret0, _ := ret[0].(*plugin.Plugin) ret1, _ := ret[1].([]byte) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -1338,7 +1339,7 @@ func (mr *MockAPIClientMockRecorder) PluginInspectWithRaw(arg0, arg1 any) *gomoc } // PluginInstall mocks base method. -func (m *MockAPIClient) PluginInstall(arg0 context.Context, arg1 string, arg2 types.PluginInstallOptions) (io.ReadCloser, error) { +func (m *MockAPIClient) PluginInstall(arg0 context.Context, arg1 string, arg2 client.PluginInstallOptions) (io.ReadCloser, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PluginInstall", arg0, arg1, arg2) ret0, _ := ret[0].(io.ReadCloser) @@ -1353,10 +1354,10 @@ func (mr *MockAPIClientMockRecorder) PluginInstall(arg0, arg1, arg2 any) *gomock } // PluginList mocks base method. -func (m *MockAPIClient) PluginList(arg0 context.Context, arg1 filters.Args) (types.PluginsListResponse, error) { +func (m *MockAPIClient) PluginList(arg0 context.Context, arg1 filters.Args) (plugin.ListResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PluginList", arg0, arg1) - ret0, _ := ret[0].(types.PluginsListResponse) + ret0, _ := ret[0].(plugin.ListResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -1383,7 +1384,7 @@ func (mr *MockAPIClientMockRecorder) PluginPush(arg0, arg1, arg2 any) *gomock.Ca } // PluginRemove mocks base method. -func (m *MockAPIClient) PluginRemove(arg0 context.Context, arg1 string, arg2 types.PluginRemoveOptions) error { +func (m *MockAPIClient) PluginRemove(arg0 context.Context, arg1 string, arg2 client.PluginRemoveOptions) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PluginRemove", arg0, arg1, arg2) ret0, _ := ret[0].(error) @@ -1411,7 +1412,7 @@ func (mr *MockAPIClientMockRecorder) PluginSet(arg0, arg1, arg2 any) *gomock.Cal } // PluginUpgrade mocks base method. -func (m *MockAPIClient) PluginUpgrade(arg0 context.Context, arg1 string, arg2 types.PluginInstallOptions) (io.ReadCloser, error) { +func (m *MockAPIClient) PluginUpgrade(arg0 context.Context, arg1 string, arg2 client.PluginInstallOptions) (io.ReadCloser, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PluginUpgrade", arg0, arg1, arg2) ret0, _ := ret[0].(io.ReadCloser) diff --git a/pkg/mocks/mock_docker_cli.go b/pkg/mocks/mock_docker_cli.go index a540662d765..708521e1c97 100644 --- a/pkg/mocks/mock_docker_cli.go +++ b/pkg/mocks/mock_docker_cli.go @@ -17,7 +17,7 @@ import ( docker "github.com/docker/cli/cli/context/docker" store "github.com/docker/cli/cli/context/store" streams "github.com/docker/cli/cli/streams" - client "github.com/docker/docker/client" + client "github.com/moby/moby/client" metric "go.opentelemetry.io/otel/metric" resource "go.opentelemetry.io/otel/sdk/resource" trace "go.opentelemetry.io/otel/trace" From ddcba90b670d8ac92db60e55a63312463de88cd0 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 6 Aug 2025 00:50:38 +0200 Subject: [PATCH 2/3] TODO: can we remove the "JSONMessage" wrapping? Signed-off-by: Sebastiaan van Stijn --- pkg/api/dryrunclient.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/api/dryrunclient.go b/pkg/api/dryrunclient.go index 576135504d8..a746b57a5f8 100644 --- a/pkg/api/dryrunclient.go +++ b/pkg/api/dryrunclient.go @@ -209,6 +209,7 @@ func (d *DryRunClient) CopyToContainer(ctx context.Context, container, path stri } func (d *DryRunClient) ImageBuild(ctx context.Context, reader io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error) { + // TODO(thaJeztah): can we use api/types/jsonstream (or api/pkg/xxxxx) for this? jsonMessage, err := json.Marshal(&jsonmessage.JSONMessage{ Status: fmt.Sprintf("%[1]sSuccessfully built: dryRunID\n%[1]sSuccessfully tagged: %[2]s\n", DRYRUN_PREFIX, options.Tags[0]), Progress: &jsonmessage.JSONProgress{}, @@ -257,6 +258,8 @@ func (d *DryRunClient) ImagePush(ctx context.Context, ref string, options image. if _, _, err := d.resolver.Resolve(ctx, ref); err != nil { return nil, err } + + // TODO(thaJeztah): can we use api/types/jsonstream (or api/pkg/xxxxx) for this? jsonMessage, err := json.Marshal(&jsonmessage.JSONMessage{ Status: "Pushed", Progress: &jsonmessage.JSONProgress{ From 8925b9ce3c8e97b0016fd2695974fa51517c713a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 6 Aug 2025 00:09:07 +0200 Subject: [PATCH 3/3] bump buildkit Signed-off-by: Sebastiaan van Stijn --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 92280eb19c7..b86b6e32215 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23.10 replace ( github.com/docker/buildx => github.com/thaJeztah/buildx v0.2.1-0.20250805215749-af0516f267b1 - github.com/moby/buildkit => github.com/moby/buildkit v0.23.0-rc1.0.20250618182037-9b91d20367db // master + github.com/moby/buildkit => github.com/moby/buildkit v0.23.0-rc1.0.20250801041656-ee216b9a126b // master ) require ( diff --git a/go.sum b/go.sum index f8ed072adbf..c076c579d3e 100644 --- a/go.sum +++ b/go.sum @@ -313,8 +313,8 @@ github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/z github.com/mitchellh/mapstructure v0.0.0-20150613213606-2caf8efc9366/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/moby/buildkit v0.23.0-rc1.0.20250618182037-9b91d20367db h1:ZzrDuG9G1A/RwJvuogNplxCEKsIUQh1CqEnqbOGFgKE= -github.com/moby/buildkit v0.23.0-rc1.0.20250618182037-9b91d20367db/go.mod h1:v5jMDvQgUyidk3wu3NvVAAd5JJo83nfet9Gf/o0+EAQ= +github.com/moby/buildkit v0.23.0-rc1.0.20250801041656-ee216b9a126b h1:Ak5OR3pc4U3Goqz/1mmruYtj8APCG7WmOJm3RAK9reE= +github.com/moby/buildkit v0.23.0-rc1.0.20250801041656-ee216b9a126b/go.mod h1:0gAxVTOAdJJjxg26p/KON0KwGngS9kNHDG7Xg1BsJ5s= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ=