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 4f305e49195..d1d381f7065 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..7e6407fc865 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 ( @@ -212,9 +212,9 @@ func (c *ContainerContext) Publishers() api.PortPublishers { } func (c *ContainerContext) Ports() string { - var ports []container.Port + var ports []container.PortSummary for _, publisher := range c.c.Publishers { - ports = append(ports, container.Port{ + ports = append(ports, container.PortSummary{ IP: publisher.URL, PrivatePort: uint16(publisher.TargetPort), PublicPort: uint16(publisher.PublishedPort), 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 5722b9858ff..6b2d391d5da 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/docker/compose/v2 go 1.23.12 +replace github.com/docker/buildx => github.com/thaJeztah/buildx v0.2.1-0.20250828153321-62592fbd151b // https://github.com/docker/buildx/pull/3326 + require ( github.com/AlecAivazis/survey/v2 v2.3.7 github.com/DefangLabs/secret-detector v0.0.0-20250403165618-22662109213e @@ -15,9 +17,9 @@ require ( github.com/davecgh/go-spew v1.1.1 github.com/distribution/reference v0.6.0 github.com/docker/buildx v0.28.0-rc1 - github.com/docker/cli v28.3.3+incompatible + github.com/docker/cli v28.3.4-0.20250828115546-8f25f4fb24b8+incompatible // master github.com/docker/cli-docs-tool v0.10.0 - github.com/docker/docker v28.3.3+incompatible + github.com/docker/docker v28.3.4-0.20250828134822-02b4a1a3decc+incompatible // 28.x branch (v28.4.0-dev) github.com/docker/go-connections v0.6.0 github.com/docker/go-units v0.5.0 github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203 @@ -30,6 +32,8 @@ require ( github.com/mitchellh/mapstructure v1.5.0 github.com/moby/buildkit v0.24.0-rc1 github.com/moby/go-archive v0.1.0 + github.com/moby/moby/api v1.52.0-alpha.1.0.20250828160303-620b93135e44 // master + github.com/moby/moby/client v0.1.0-alpha.0.0.20250828160303-620b93135e44 // master github.com/moby/patternmatcher v0.6.0 github.com/moby/sys/atomicwriter v0.1.0 github.com/moby/term v0.5.2 @@ -61,7 +65,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 +171,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 537f7dbb7d1..a99a70ff932 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= @@ -128,17 +126,15 @@ 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.28.0-rc1 h1:XQ0hwhIB+Jf211iBdts30WtsqIQ8/xY7/QcYDzfDFEY= -github.com/docker/buildx v0.28.0-rc1/go.mod h1:LGGGhqW6EbnC96hK9XSVh4h7kI+G/bwTgJJh/uAuQWo= -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.20250828115546-8f25f4fb24b8+incompatible h1:6try12Z9p9Xy4E2PPGwOMW8cWNXKiYDQbwRqRn1/0Ts= +github.com/docker/cli v28.3.4-0.20250828115546-8f25f4fb24b8+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= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v28.3.3+incompatible h1:Dypm25kh4rmk49v1eiVbsAtpAsYURjYkaKubwuBdxEI= -github.com/docker/docker v28.3.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v28.3.4-0.20250828134822-02b4a1a3decc+incompatible h1:a4+xSvQFFYl8eRsVWyL3lwz1JubDEO77m1ovj3lFiXo= +github.com/docker/docker v28.3.4-0.20250828134822-02b4a1a3decc+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.9.3 h1:gAm/VtF9wgqJMoxzT3Gj5p4AqIjCBS4wrsOh9yRqcz8= github.com/docker/docker-credential-helpers v0.9.3/go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0= @@ -326,6 +322,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.0.20250828160303-620b93135e44 h1:IRrLHRXRytJYqYWMpPj8wnoLDJxO5g1M/XPwILPhAt0= +github.com/moby/moby/api v1.52.0-alpha.1.0.20250828160303-620b93135e44/go.mod h1:8sBV0soUREiudtow4vqJGOxa4GyHI5vLQmvgKdHq5Ok= +github.com/moby/moby/client v0.1.0-alpha.0.0.20250828160303-620b93135e44 h1:m7Rbw9nK324SJWvYc9ywPb+3X8tVd7NZB1kUs3t10UM= +github.com/moby/moby/client v0.1.0-alpha.0.0.20250828160303-620b93135e44/go.mod h1:7pOYrEHdG7I0dNZEC+yqk/p8ZOxGMR1KgoexzCEDe0w= 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= @@ -472,6 +472,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.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/thaJeztah/buildx v0.2.1-0.20250828153321-62592fbd151b h1:kMabyuMEe4eOSwFLgumIFhSCCZbHneqr0DSgUyKvqAQ= +github.com/thaJeztah/buildx v0.2.1-0.20250828153321-62592fbd151b/go.mod h1:WLAZEqg1R+IoMSfislOz90UVuD8H7/bBTweIm5vKpkM= 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= @@ -490,13 +492,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= @@ -677,6 +672,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 4250b6afc4a..216155e44c0 100644 --- a/internal/sync/tar.go +++ b/internal/sync/tar.go @@ -31,8 +31,8 @@ import ( "strings" "sync" - "github.com/docker/docker/api/types/container" "github.com/moby/go-archive" + "github.com/moby/moby/api/types/container" "golang.org/x/sync/errgroup" ) 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 51140757a68..34e818a23c4 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 83d214b5b53..026ddcd6a44 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, @@ -126,14 +128,12 @@ func (d *DryRunClient) ContainerInspect(ctx context.Context, container string) ( } } return containerType.InspectResponse{ - ContainerJSONBase: &containerType.ContainerJSONBase{ - ID: id, - Name: container, - State: &containerType.State{ - Status: containerType.StateRunning, // needed for --wait option - Health: &containerType.Health{ - Status: containerType.Healthy, // needed for healthcheck control - }, + ID: id, + Name: container, + State: &containerType.State{ + Status: containerType.StateRunning, // needed for --wait option + Health: &containerType.Health{ + Status: containerType.Healthy, // needed for healthcheck control }, }, Mounts: nil, @@ -207,6 +207,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{}, @@ -243,7 +244,7 @@ func (d *DryRunClient) ImageInspectWithRaw(ctx context.Context, imageName string return resp, buf.Bytes(), err } -func (d *DryRunClient) ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error) { +func (d *DryRunClient) ImagePull(ctx context.Context, ref string, options client.ImagePullOptions) (io.ReadCloser, error) { if _, _, err := d.resolver.Resolve(ctx, ref); err != nil { return nil, err } @@ -251,18 +252,22 @@ func (d *DryRunClient) ImagePull(ctx context.Context, ref string, options image. return rc, nil } -func (d *DryRunClient) ImagePush(ctx context.Context, ref string, options image.PushOptions) (io.ReadCloser, error) { +func (d *DryRunClient) ImagePush(ctx context.Context, ref string, options client.ImagePushOptions) (io.ReadCloser, error) { 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{ - 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, }) @@ -273,7 +278,7 @@ func (d *DryRunClient) ImagePush(ctx context.Context, ref string, options image. return rc, nil } -func (d *DryRunClient) ImageRemove(ctx context.Context, imageName string, options image.RemoveOptions) ([]image.DeleteResponse, error) { +func (d *DryRunClient) ImageRemove(ctx context.Context, imageName string, options client.ImageRemoveOptions) ([]image.DeleteResponse, error) { return nil, nil } @@ -281,7 +286,7 @@ func (d *DryRunClient) NetworkConnect(ctx context.Context, networkName, containe return nil } -func (d *DryRunClient) NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) { +func (d *DryRunClient) NetworkCreate(ctx context.Context, name string, options client.NetworkCreateOptions) (network.CreateResponse, error) { return network.CreateResponse{ ID: name, Warning: "", @@ -335,7 +340,7 @@ func (d *DryRunClient) ContainerExecStart(ctx context.Context, execID string, co // Functions delegated to original APIClient (not used by Compose or not modifying the Compose stack -func (d *DryRunClient) ConfigList(ctx context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) { +func (d *DryRunClient) ConfigList(ctx context.Context, options client.ConfigListOptions) ([]swarm.Config, error) { return d.apiClient.ConfigList(ctx, options) } @@ -363,15 +368,15 @@ 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) { return d.apiClient.ContainerExecInspect(ctx, execID) } -func (d *DryRunClient) ContainerExecResize(ctx context.Context, execID string, options containerType.ResizeOptions) error { +func (d *DryRunClient) ContainerExecResize(ctx context.Context, execID string, options client.ContainerResizeOptions) error { return d.apiClient.ContainerExecResize(ctx, execID, options) } @@ -387,7 +392,7 @@ func (d *DryRunClient) ContainerLogs(ctx context.Context, container string, opti return d.apiClient.ContainerLogs(ctx, container, options) } -func (d *DryRunClient) ContainerResize(ctx context.Context, container string, options containerType.ResizeOptions) error { +func (d *DryRunClient) ContainerResize(ctx context.Context, container string, options client.ContainerResizeOptions) error { return d.apiClient.ContainerResize(ctx, container, options) } @@ -395,11 +400,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) } @@ -431,7 +436,7 @@ func (d *DryRunClient) BuildCancel(ctx context.Context, id string) error { return d.apiClient.BuildCancel(ctx, id) } -func (d *DryRunClient) ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error) { +func (d *DryRunClient) ImageCreate(ctx context.Context, parentReference string, options client.ImageCreateOptions) (io.ReadCloser, error) { return d.apiClient.ImageCreate(ctx, parentReference, options) } @@ -439,11 +444,11 @@ func (d *DryRunClient) ImageHistory(ctx context.Context, imageName string, optio return d.apiClient.ImageHistory(ctx, imageName, options...) } -func (d *DryRunClient) ImageImport(ctx context.Context, source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) { +func (d *DryRunClient) ImageImport(ctx context.Context, source client.ImageImportSource, ref string, options client.ImageImportOptions) (io.ReadCloser, error) { return d.apiClient.ImageImport(ctx, source, ref, options) } -func (d *DryRunClient) ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error) { +func (d *DryRunClient) ImageList(ctx context.Context, options client.ImageListOptions) ([]image.Summary, error) { return d.apiClient.ImageList(ctx, options) } @@ -451,7 +456,7 @@ func (d *DryRunClient) ImageLoad(ctx context.Context, input io.Reader, options . return d.apiClient.ImageLoad(ctx, input, options...) } -func (d *DryRunClient) ImageSearch(ctx context.Context, term string, options registry.SearchOptions) ([]registry.SearchResult, error) { +func (d *DryRunClient) ImageSearch(ctx context.Context, term string, options client.ImageSearchOptions) ([]registry.SearchResult, error) { return d.apiClient.ImageSearch(ctx, term, options) } @@ -471,11 +476,11 @@ func (d *DryRunClient) NodeInspectWithRaw(ctx context.Context, nodeID string) (s return d.apiClient.NodeInspectWithRaw(ctx, nodeID) } -func (d *DryRunClient) NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) { +func (d *DryRunClient) NodeList(ctx context.Context, options client.NodeListOptions) ([]swarm.Node, error) { return d.apiClient.NodeList(ctx, options) } -func (d *DryRunClient) NodeRemove(ctx context.Context, nodeID string, options swarm.NodeRemoveOptions) error { +func (d *DryRunClient) NodeRemove(ctx context.Context, nodeID string, options client.NodeRemoveOptions) error { return d.apiClient.NodeRemove(ctx, nodeID, options) } @@ -483,15 +488,15 @@ func (d *DryRunClient) NodeUpdate(ctx context.Context, nodeID string, version sw return d.apiClient.NodeUpdate(ctx, nodeID, version, node) } -func (d *DryRunClient) NetworkInspect(ctx context.Context, networkName string, options network.InspectOptions) (network.Inspect, error) { +func (d *DryRunClient) NetworkInspect(ctx context.Context, networkName string, options client.NetworkInspectOptions) (network.Inspect, error) { return d.apiClient.NetworkInspect(ctx, networkName, options) } -func (d *DryRunClient) NetworkInspectWithRaw(ctx context.Context, networkName string, options network.InspectOptions) (network.Inspect, []byte, error) { +func (d *DryRunClient) NetworkInspectWithRaw(ctx context.Context, networkName string, options client.NetworkInspectOptions) (network.Inspect, []byte, error) { return d.apiClient.NetworkInspectWithRaw(ctx, networkName, options) } -func (d *DryRunClient) NetworkList(ctx context.Context, options network.ListOptions) ([]network.Inspect, error) { +func (d *DryRunClient) NetworkList(ctx context.Context, options client.NetworkListOptions) ([]network.Inspect, error) { return d.apiClient.NetworkList(ctx, options) } @@ -499,27 +504,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,23 +536,23 @@ 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) } -func (d *DryRunClient) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options swarm.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) { +func (d *DryRunClient) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options client.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) { return d.apiClient.ServiceCreate(ctx, service, options) } -func (d *DryRunClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) { +func (d *DryRunClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, options client.ServiceInspectOptions) (swarm.Service, []byte, error) { return d.apiClient.ServiceInspectWithRaw(ctx, serviceID, options) } -func (d *DryRunClient) ServiceList(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) { +func (d *DryRunClient) ServiceList(ctx context.Context, options client.ServiceListOptions) ([]swarm.Service, error) { return d.apiClient.ServiceList(ctx, options) } @@ -555,8 +560,8 @@ func (d *DryRunClient) ServiceRemove(ctx context.Context, serviceID string) erro return d.apiClient.ServiceRemove(ctx, serviceID) } -func (d *DryRunClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) { - return d.apiClient.ServiceUpdate(ctx, serviceID, version, service, options) +func (d *DryRunClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, spec swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) { + return d.apiClient.ServiceUpdate(ctx, serviceID, version, spec, options) } func (d *DryRunClient) ServiceLogs(ctx context.Context, serviceID string, options containerType.LogsOptions) (io.ReadCloser, error) { @@ -571,7 +576,7 @@ func (d *DryRunClient) TaskInspectWithRaw(ctx context.Context, taskID string) (s return d.apiClient.TaskInspectWithRaw(ctx, taskID) } -func (d *DryRunClient) TaskList(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) { +func (d *DryRunClient) TaskList(ctx context.Context, options client.TaskListOptions) ([]swarm.Task, error) { return d.apiClient.TaskList(ctx, options) } @@ -599,11 +604,11 @@ func (d *DryRunClient) SwarmInspect(ctx context.Context) (swarm.Swarm, error) { return d.apiClient.SwarmInspect(ctx) } -func (d *DryRunClient) SwarmUpdate(ctx context.Context, version swarm.Version, swarmSpec swarm.Spec, flags swarm.UpdateFlags) error { +func (d *DryRunClient) SwarmUpdate(ctx context.Context, version swarm.Version, swarmSpec swarm.Spec, flags client.SwarmUpdateFlags) error { return d.apiClient.SwarmUpdate(ctx, version, swarmSpec, flags) } -func (d *DryRunClient) SecretList(ctx context.Context, options swarm.SecretListOptions) ([]swarm.Secret, error) { +func (d *DryRunClient) SecretList(ctx context.Context, options client.SecretListOptions) ([]swarm.Secret, error) { return d.apiClient.SecretList(ctx, options) } @@ -623,7 +628,7 @@ func (d *DryRunClient) SecretUpdate(ctx context.Context, id string, version swar return d.apiClient.SecretUpdate(ctx, id, version, secret) } -func (d *DryRunClient) Events(ctx context.Context, options events.ListOptions) (<-chan events.Message, <-chan error) { +func (d *DryRunClient) Events(ctx context.Context, options client.EventsListOptions) (<-chan events.Message, <-chan error) { return d.apiClient.Events(ctx, options) } @@ -635,7 +640,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 client.DiskUsageOptions) (system.DiskUsage, error) { return d.apiClient.DiskUsage(ctx, options) } @@ -651,7 +656,7 @@ func (d *DryRunClient) VolumeInspectWithRaw(ctx context.Context, volumeID string return d.apiClient.VolumeInspectWithRaw(ctx, volumeID) } -func (d *DryRunClient) VolumeList(ctx context.Context, opts volume.ListOptions) (volume.ListResponse, error) { +func (d *DryRunClient) VolumeList(ctx context.Context, opts client.VolumeListOptions) (volume.ListResponse, error) { return d.apiClient.VolumeList(ctx, opts) } diff --git a/pkg/bridge/convert.go b/pkg/bridge/convert.go index 8e9995b824f..ded4bfbec44 100644 --- a/pkg/bridge/convert.go +++ b/pkg/bridge/convert.go @@ -32,11 +32,12 @@ 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" + "github.com/moby/moby/client/pkg/jsonmessage" "gopkg.in/yaml.v3" ) @@ -206,13 +207,14 @@ func inspectWithPull(ctx context.Context, dockerCli command.Cli, imageName strin inspect, err := dockerCli.Client().ImageInspect(ctx, imageName) if errdefs.IsNotFound(err) { var stream io.ReadCloser - stream, err = dockerCli.Client().ImagePull(ctx, imageName, image.PullOptions{}) + stream, err = dockerCli.Client().ImagePull(ctx, imageName, client.ImagePullOptions{}) if err != nil { return image.InspectResponse{}, err } 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..aef3db1dd70 100644 --- a/pkg/bridge/transformers.go +++ b/pkg/bridge/transformers.go @@ -23,11 +23,12 @@ 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" + "github.com/moby/moby/client" ) const ( @@ -112,7 +113,7 @@ COPY templates /templates func ListTransformers(ctx context.Context, dockerCli command.Cli) ([]image.Summary, error) { api := dockerCli.Client() - return api.ImageList(ctx, image.ListOptions{ + return api.ImageList(ctx, client.ImageListOptions{ Filters: filters.NewArgs( filters.Arg("label", fmt.Sprintf("%s=%s", TransformerLabel, "transformation")), ), 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 434cf055599..e6f76062124 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" gitutil "github.com/moby/buildkit/frontend/dockerfile/dfgitutil" "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..e5433c4da30 100644 --- a/pkg/compose/compose.go +++ b/pkg/compose/compose.go @@ -30,13 +30,11 @@ 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/swarm" + "github.com/moby/moby/client" "github.com/docker/compose/v2/internal/desktop" "github.com/docker/compose/v2/internal/experimental" @@ -243,7 +241,7 @@ func increment(scale *int) *int { } func (s *composeService) actualVolumes(ctx context.Context, projectName string) (types.Volumes, error) { - opts := volume.ListOptions{ + opts := client.VolumeListOptions{ Filters: filters.NewArgs(projectFilter(projectName)), } volumes, err := s.apiClient().VolumeList(ctx, opts) @@ -263,7 +261,7 @@ func (s *composeService) actualVolumes(ctx context.Context, projectName string) } func (s *composeService) actualNetworks(ctx context.Context, projectName string) (types.Networks, error) { - networks, err := s.apiClient().NetworkList(ctx, network.ListOptions{ + networks, err := s.apiClient().NetworkList(ctx, client.NetworkListOptions{ Filters: filters.NewArgs(projectFilter(projectName)), }) if err != nil { 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 1fd6ec89879..1e8210d8b99 100644 --- a/pkg/compose/convergence.go +++ b/pkg/compose/convergence.go @@ -30,9 +30,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" @@ -187,11 +187,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 { @@ -245,7 +245,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) @@ -896,7 +896,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..a3cce5bfa50 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" @@ -327,10 +327,8 @@ func TestCreateMobyContainer(t *testing.T) { apiClient.EXPECT().ContainerInspect(gomock.Any(), gomock.Eq("an-id")).Times(1).Return( container.InspectResponse{ - ContainerJSONBase: &container.ContainerJSONBase{ - ID: "an-id", - Name: "a-name", - }, + ID: "an-id", + Name: "a-name", Config: &container.Config{}, NetworkSettings: &container.NetworkSettings{}, }, nil) @@ -420,10 +418,8 @@ func TestCreateMobyContainer(t *testing.T) { apiClient.EXPECT().ContainerInspect(gomock.Any(), gomock.Eq("an-id")).Times(1).Return( container.InspectResponse{ - ContainerJSONBase: &container.ContainerJSONBase{ - ID: "an-id", - Name: "a-name", - }, + ID: "an-id", + Name: "a-name", Config: &container.Config{}, NetworkSettings: &container.NetworkSettings{}, }, nil) 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..f0998f1a115 100644 --- a/pkg/compose/create.go +++ b/pkg/compose/create.go @@ -31,14 +31,15 @@ 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/moby/moby/client" "github.com/sirupsen/logrus" cdi "tags.cncf.io/container-device-interface/pkg/parser" @@ -1275,7 +1276,7 @@ func (s *composeService) resolveOrCreateNetwork(ctx context.Context, project *ty var dangledContainers Containers // First, try to find a unique network matching by name or ID - inspect, err := s.apiClient().NetworkInspect(ctx, n.Name, network.InspectOptions{}) + inspect, err := s.apiClient().NetworkInspect(ctx, n.Name, client.NetworkInspectOptions{}) if err == nil { // NetworkInspect will match on ID prefix, so double check we get the expected one // as looking for network named `db` we could erroneously match network ID `db9086999caf` @@ -1316,7 +1317,7 @@ func (s *composeService) resolveOrCreateNetwork(ctx context.Context, project *ty // ignore other errors. Typically, an ambiguous request by name results in some generic `invalidParameter` error // Either not found, or name is ambiguous - use NetworkList to list by name - networks, err := s.apiClient().NetworkList(ctx, network.ListOptions{ + networks, err := s.apiClient().NetworkList(ctx, client.NetworkListOptions{ Filters: filters.NewArgs(filters.Arg("name", n.Name)), }) if err != nil { @@ -1365,7 +1366,7 @@ func (s *composeService) resolveOrCreateNetwork(ctx context.Context, project *ty return "", err } n.CustomLabels = n.CustomLabels.Add(api.ConfigHashLabel, hash) - createOpts := network.CreateOptions{ + createOpts := client.NetworkCreateOptions{ Labels: mergeLabels(n.Labels, n.CustomLabels), Driver: n.Driver, Options: n.DriverOpts, @@ -1451,11 +1452,11 @@ func (s *composeService) removeDivergedNetwork(ctx context.Context, project *typ func (s *composeService) disconnectNetwork( ctx context.Context, - network string, + networkID string, containers Containers, ) error { for _, c := range containers { - err := s.apiClient().NetworkDisconnect(ctx, network, c.ID, true) + err := s.apiClient().NetworkDisconnect(ctx, networkID, c.ID, true) if err != nil { return err } @@ -1466,12 +1467,12 @@ func (s *composeService) disconnectNetwork( func (s *composeService) connectNetwork( ctx context.Context, - network string, + networkID string, containers Containers, config *network.EndpointSettings, ) error { for _, c := range containers { - err := s.apiClient().NetworkConnect(ctx, network, c.ID, config) + err := s.apiClient().NetworkConnect(ctx, networkID, c.ID, config) if err != nil { return err } @@ -1485,7 +1486,7 @@ func (s *composeService) resolveExternalNetwork(ctx context.Context, n *types.Ne // filter is used to look for an exact match to prevent e.g. a network // named `db` from getting erroneously matched to a network with an ID // like `db9086999caf` - networks, err := s.apiClient().NetworkList(ctx, network.ListOptions{ + networks, err := s.apiClient().NetworkList(ctx, client.NetworkListOptions{ Filters: filters.NewArgs(filters.Arg("name", n.Name)), }) if err != nil { @@ -1494,7 +1495,7 @@ func (s *composeService) resolveExternalNetwork(ctx context.Context, n *types.Ne if len(networks) == 0 { // in this instance, n.Name is really an ID - sn, err := s.apiClient().NetworkInspect(ctx, n.Name, network.InspectOptions{}) + sn, err := s.apiClient().NetworkInspect(ctx, n.Name, client.NetworkInspectOptions{}) if err == nil { networks = append(networks, sn) } else if !errdefs.IsNotFound(err) { 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..61d7bfbe84a 100644 --- a/pkg/compose/down.go +++ b/pkg/compose/down.go @@ -27,10 +27,9 @@ 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" + "github.com/moby/moby/client" "github.com/sirupsen/logrus" "golang.org/x/sync/errgroup" ) @@ -197,7 +196,7 @@ func (s *composeService) ensureNetworksDown(ctx context.Context, project *types. } func (s *composeService) removeNetwork(ctx context.Context, composeNetworkName string, projectName string, name string, w progress.Writer) error { - networks, err := s.apiClient().NetworkList(ctx, network.ListOptions{ + networks, err := s.apiClient().NetworkList(ctx, client.NetworkListOptions{ Filters: filters.NewArgs( projectFilter(projectName), networkFilter(composeNetworkName)), @@ -218,7 +217,7 @@ func (s *composeService) removeNetwork(ctx context.Context, composeNetworkName s if net.Name != name { continue } - nw, err := s.apiClient().NetworkInspect(ctx, net.ID, network.InspectOptions{}) + nw, err := s.apiClient().NetworkInspect(ctx, net.ID, client.NetworkInspectOptions{}) if errdefs.IsNotFound(err) { w.Event(progress.NewEvent(eventName, progress.Warning, "No resource found to remove")) return nil @@ -256,7 +255,7 @@ func (s *composeService) removeNetwork(ctx context.Context, composeNetworkName s func (s *composeService) removeImage(ctx context.Context, image string, w progress.Writer) error { id := fmt.Sprintf("Image %s", image) w.Event(progress.NewEvent(id, progress.Working, "Removing")) - _, err := s.apiClient().ImageRemove(ctx, image, imageapi.RemoveOptions{}) + _, err := s.apiClient().ImageRemove(ctx, image, client.ImageRemoveOptions{}) if err == nil { w.Event(progress.NewEvent(id, progress.Done, "Removed")) return nil diff --git a/pkg/compose/down_test.go b/pkg/compose/down_test.go index 58c1ec0b14c..86b84842712 100644 --- a/pkg/compose/down_test.go +++ b/pkg/compose/down_test.go @@ -26,11 +26,12 @@ 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" + "github.com/moby/moby/client" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" @@ -56,14 +57,14 @@ func TestDown(t *testing.T) { }, nil) api.EXPECT().VolumeList( gomock.Any(), - volume.ListOptions{ + client.VolumeListOptions{ Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject))), }). Return(volume.ListResponse{}, nil) // network names are not guaranteed to be unique, ensure Compose handles // cleanup properly if duplicates are inadvertently created - api.EXPECT().NetworkList(gomock.Any(), network.ListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). + api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). Return([]network.Summary{ {ID: "abc123", Name: "myProject_default", Labels: map[string]string{compose.NetworkLabel: "default"}}, {ID: "def456", Name: "myProject_default", Labels: map[string]string{compose.NetworkLabel: "default"}}, @@ -78,7 +79,7 @@ func TestDown(t *testing.T) { api.EXPECT().ContainerRemove(gomock.Any(), "456", container.RemoveOptions{Force: true}).Return(nil) api.EXPECT().ContainerRemove(gomock.Any(), "789", container.RemoveOptions{Force: true}).Return(nil) - api.EXPECT().NetworkList(gomock.Any(), network.ListOptions{ + api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{ Filters: filters.NewArgs( projectFilter(strings.ToLower(testProject)), networkFilter("default")), @@ -113,14 +114,14 @@ func TestDownWithGivenServices(t *testing.T) { }, nil) api.EXPECT().VolumeList( gomock.Any(), - volume.ListOptions{ + client.VolumeListOptions{ Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject))), }). Return(volume.ListResponse{}, nil) // network names are not guaranteed to be unique, ensure Compose handles // cleanup properly if duplicates are inadvertently created - api.EXPECT().NetworkList(gomock.Any(), network.ListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). + api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). Return([]network.Summary{ {ID: "abc123", Name: "myProject_default", Labels: map[string]string{compose.NetworkLabel: "default"}}, {ID: "def456", Name: "myProject_default", Labels: map[string]string{compose.NetworkLabel: "default"}}, @@ -131,7 +132,7 @@ func TestDownWithGivenServices(t *testing.T) { api.EXPECT().ContainerRemove(gomock.Any(), "123", container.RemoveOptions{Force: true}).Return(nil) - api.EXPECT().NetworkList(gomock.Any(), network.ListOptions{ + api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{ Filters: filters.NewArgs( projectFilter(strings.ToLower(testProject)), networkFilter("default")), @@ -165,14 +166,14 @@ func TestDownWithSpecifiedServiceButTheServicesAreNotRunning(t *testing.T) { }, nil) api.EXPECT().VolumeList( gomock.Any(), - volume.ListOptions{ + client.VolumeListOptions{ Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject))), }). Return(volume.ListResponse{}, nil) // network names are not guaranteed to be unique, ensure Compose handles // cleanup properly if duplicates are inadvertently created - api.EXPECT().NetworkList(gomock.Any(), network.ListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). + api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). Return([]network.Summary{ {ID: "abc123", Name: "myProject_default", Labels: map[string]string{compose.NetworkLabel: "default"}}, {ID: "def456", Name: "myProject_default", Labels: map[string]string{compose.NetworkLabel: "default"}}, @@ -201,11 +202,11 @@ func TestDownRemoveOrphans(t *testing.T) { }, nil) api.EXPECT().VolumeList( gomock.Any(), - volume.ListOptions{ + client.VolumeListOptions{ Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject))), }). Return(volume.ListResponse{}, nil) - api.EXPECT().NetworkList(gomock.Any(), network.ListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). + api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). Return([]network.Summary{ { Name: "myProject_default", @@ -222,7 +223,7 @@ func TestDownRemoveOrphans(t *testing.T) { api.EXPECT().ContainerRemove(gomock.Any(), "789", container.RemoveOptions{Force: true}).Return(nil) api.EXPECT().ContainerRemove(gomock.Any(), "321", container.RemoveOptions{Force: true}).Return(nil) - api.EXPECT().NetworkList(gomock.Any(), network.ListOptions{ + api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{ Filters: filters.NewArgs( networkFilter("default"), projectFilter(strings.ToLower(testProject)), @@ -248,7 +249,7 @@ func TestDownRemoveVolumes(t *testing.T) { []container.Summary{testContainer("service1", "123", false)}, nil) api.EXPECT().VolumeList( gomock.Any(), - volume.ListOptions{ + client.VolumeListOptions{ Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject))), }). Return(volume.ListResponse{ @@ -256,7 +257,7 @@ func TestDownRemoveVolumes(t *testing.T) { }, nil) api.EXPECT().VolumeInspect(gomock.Any(), "myProject_volume"). Return(volume.Volume{}, nil) - api.EXPECT().NetworkList(gomock.Any(), network.ListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). + api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). Return(nil, nil) api.EXPECT().ContainerStop(gomock.Any(), "123", container.StopOptions{}).Return(nil) @@ -297,7 +298,7 @@ func TestDownRemoveImages(t *testing.T) { }, nil). AnyTimes() - api.EXPECT().ImageList(gomock.Any(), image.ListOptions{ + api.EXPECT().ImageList(gomock.Any(), client.ImageListOptions{ Filters: filters.NewArgs( projectFilter(strings.ToLower(testProject)), filters.Arg("dangling", "false"), @@ -345,7 +346,7 @@ func TestDownRemoveImages(t *testing.T) { for _, img := range localImagesToBeRemoved { // test calls down --rmi=local then down --rmi=all, so local images // get "removed" 2x, while other images are only 1x - api.EXPECT().ImageRemove(gomock.Any(), img, image.RemoveOptions{}). + api.EXPECT().ImageRemove(gomock.Any(), img, client.ImageRemoveOptions{}). Return(nil, nil). Times(2) } @@ -360,7 +361,7 @@ func TestDownRemoveImages(t *testing.T) { "registry.example.com/remote-image-tagged:v1.0", } for _, img := range otherImagesToBeRemoved { - api.EXPECT().ImageRemove(gomock.Any(), img, image.RemoveOptions{}). + api.EXPECT().ImageRemove(gomock.Any(), img, client.ImageRemoveOptions{}). Return(nil, nil). Times(1) } @@ -387,18 +388,18 @@ func TestDownRemoveImages_NoLabel(t *testing.T) { api.EXPECT().VolumeList( gomock.Any(), - volume.ListOptions{ + client.VolumeListOptions{ Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject))), }). Return(volume.ListResponse{ Volumes: []*volume.Volume{{Name: "myProject_volume"}}, }, nil) - api.EXPECT().NetworkList(gomock.Any(), network.ListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). + api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). Return(nil, nil) // ImageList returns no images for the project since they were unlabeled // (created by an older version of Compose) - api.EXPECT().ImageList(gomock.Any(), image.ListOptions{ + api.EXPECT().ImageList(gomock.Any(), client.ImageListOptions{ Filters: filters.NewArgs( projectFilter(strings.ToLower(testProject)), filters.Arg("dangling", "false"), @@ -411,7 +412,7 @@ func TestDownRemoveImages_NoLabel(t *testing.T) { api.EXPECT().ContainerStop(gomock.Any(), "123", container.StopOptions{}).Return(nil) api.EXPECT().ContainerRemove(gomock.Any(), "123", container.RemoveOptions{Force: true}).Return(nil) - api.EXPECT().ImageRemove(gomock.Any(), "testproject-service1:latest", image.RemoveOptions{}).Return(nil, nil) + api.EXPECT().ImageRemove(gomock.Any(), "testproject-service1:latest", client.ImageRemoveOptions{}).Return(nil, nil) err := tested.Down(context.Background(), strings.ToLower(testProject), compose.DownOptions{Images: "local"}) assert.NilError(t, err) diff --git a/pkg/compose/events.go b/pkg/compose/events.go index 7ea8dc32651..4021c005731 100644 --- a/pkg/compose/events.go +++ b/pkg/compose/events.go @@ -22,15 +22,15 @@ import ( "strings" "time" - "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/filters" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/client" "github.com/docker/compose/v2/pkg/api" ) func (s *composeService) Events(ctx context.Context, projectName string, options api.EventsOptions) error { projectName = strings.ToLower(projectName) - evts, errors := s.apiClient().Events(ctx, events.ListOptions{ + evts, errors := s.apiClient().Events(ctx, client.EventsListOptions{ Filters: filters.NewArgs(projectFilter(projectName)), Since: options.Since, Until: options.Until, 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..c0249049127 100644 --- a/pkg/compose/generate.go +++ b/pkg/compose/generate.go @@ -25,10 +25,11 @@ 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" + "github.com/moby/moby/client" ) func (s *composeService) Generate(ctx context.Context, options api.GenerateOptions) (*types.Project, error) { @@ -221,7 +222,7 @@ func (s *composeService) toComposeNetwork(networks map[string]*network.EndpointS serviceNetworkConfigs := make(map[string]*types.ServiceNetworkConfig) for name, net := range networks { - inspect, err := s.apiClient().NetworkInspect(context.Background(), name, network.InspectOptions{}) + inspect, err := s.apiClient().NetworkInspect(context.Background(), name, client.NetworkInspectOptions{}) if err != nil { networkConfigs[name] = types.NetworkConfig{} } else { 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..cce926ff5fa 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" @@ -150,7 +150,7 @@ func (p *ImagePruner) namedImages(ctx context.Context) ([]string, error) { // The image name could either have been defined by the user or implicitly // created from the project + service name. func (p *ImagePruner) labeledLocalImages(ctx context.Context) ([]image.Summary, error) { - imageListOpts := image.ListOptions{ + return p.client.ImageList(ctx, client.ImageListOptions{ Filters: filters.NewArgs( projectFilter(p.project.Name), // TODO(milas): we should really clean up the dangling images as @@ -161,12 +161,7 @@ func (p *ImagePruner) labeledLocalImages(ctx context.Context) ([]image.Summary, // service filters.Arg("dangling", "false"), ), - } - projectImages, err := p.client.ImageList(ctx, imageListOpts) - if err != nil { - return nil, err - } - return projectImages, nil + }) } // unlabeledLocalImages are images that match the implicit naming convention diff --git a/pkg/compose/images.go b/pkg/compose/images.go index d49e92c6584..c8e7d8d1a95 100644 --- a/pkg/compose/images.go +++ b/pkg/compose/images.go @@ -27,10 +27,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 85a2b577007..3742b37ebf5 100644 --- a/pkg/compose/images_test.go +++ b/pkg/compose/images_test.go @@ -22,10 +22,10 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/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" @@ -55,7 +55,7 @@ func TestImages(t *testing.T) { api.EXPECT().ImageInspect(anyCancellableContext(), "bar:2").Return(image2, nil) c1 := containerDetail("service1", "123", "running", "foo:1") c2 := containerDetail("service1", "456", "running", "bar:2") - c2.Ports = []container.Port{{PublicPort: 80, PrivatePort: 90, IP: "localhost"}} + c2.Ports = []container.PortSummary{{PublicPort: 80, PrivatePort: 90, IP: "localhost"}} c3 := containerDetail("service2", "789", "exited", "foo:1") api.EXPECT().ContainerList(ctx, listOpts).Return([]container.Summary{c1, c2, c3}, nil) 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..d2deb3cae2d 100644 --- a/pkg/compose/kill_test.go +++ b/pkg/compose/kill_test.go @@ -23,10 +23,11 @@ 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" + "github.com/moby/moby/client" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" @@ -53,11 +54,11 @@ func TestKillAll(t *testing.T) { []container.Summary{testContainer("service1", "123", false), testContainer("service1", "456", false), testContainer("service2", "789", false)}, nil) api.EXPECT().VolumeList( gomock.Any(), - volume.ListOptions{ + client.VolumeListOptions{ Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject))), }). Return(volume.ListResponse{}, nil) - api.EXPECT().NetworkList(gomock.Any(), network.ListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). + api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). Return([]network.Summary{ {ID: "abc123", Name: "testProject_default"}, }, nil) @@ -88,11 +89,11 @@ func TestKillSignal(t *testing.T) { api.EXPECT().ContainerList(ctx, listOptions).Return([]container.Summary{testContainer(serviceName, "123", false)}, nil) api.EXPECT().VolumeList( gomock.Any(), - volume.ListOptions{ + client.VolumeListOptions{ Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject))), }). Return(volume.ListResponse{}, nil) - api.EXPECT().NetworkList(gomock.Any(), network.ListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). + api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). Return([]network.Summary{ {ID: "abc123", Name: "testProject_default"}, }, nil) @@ -111,7 +112,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..728a75f6910 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" @@ -59,8 +59,8 @@ func TestComposeService_Logs_Demux(t *testing.T) { api.EXPECT(). ContainerInspect(anyCancellableContext(), "c"). Return(containerType.InspectResponse{ - ContainerJSONBase: &containerType.ContainerJSONBase{ID: "c"}, - Config: &containerType.Config{Tty: false}, + ID: "c", + Config: &containerType.Config{Tty: false}, }, nil) c1Reader, c1Writer := io.Pipe() t.Cleanup(func() { @@ -137,8 +137,8 @@ func TestComposeService_Logs_ServiceFiltering(t *testing.T) { ContainerInspect(anyCancellableContext(), id). Return( containerType.InspectResponse{ - ContainerJSONBase: &containerType.ContainerJSONBase{ID: id}, - Config: &containerType.Config{Tty: true}, + ID: id, + Config: &containerType.Config{Tty: true}, }, nil, ) 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..1e4e2e57694 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" @@ -39,9 +39,9 @@ type monitor struct { listeners []api.ContainerEventListener } -func newMonitor(api client.APIClient, project string) *monitor { +func newMonitor(apiClient client.APIClient, project string) *monitor { return &monitor{ - api: api, + api: apiClient, project: project, services: map[string]bool{}, } @@ -79,7 +79,7 @@ func (c *monitor) Start(ctx context.Context) error { } restarting := utils.Set[string]{} - evtCh, errCh := c.api.Events(context.Background(), events.ListOptions{ + evtCh, errCh := c.api.Events(context.Background(), client.EventsListOptions{ Filters: filters.NewArgs( filters.Arg("type", "container"), projectFilter(c.project)), 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.go b/pkg/compose/ps.go index 42dfd272b04..99af8a9ac4c 100644 --- a/pkg/compose/ps.go +++ b/pkg/compose/ps.go @@ -21,7 +21,7 @@ import ( "sort" "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/ps_test.go b/pkg/compose/ps_test.go index ac2230e4ddb..5900f48d9d9 100644 --- a/pkg/compose/ps_test.go +++ b/pkg/compose/ps_test.go @@ -21,8 +21,8 @@ import ( "strings" "testing" - containerType "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/filters" + containerType "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" @@ -44,7 +44,7 @@ func TestPs(t *testing.T) { listOpts := containerType.ListOptions{Filters: args, All: false} c1, inspect1 := containerDetails("service1", "123", containerType.StateRunning, containerType.Healthy, 0) c2, inspect2 := containerDetails("service1", "456", containerType.StateRunning, "", 0) - c2.Ports = []containerType.Port{{PublicPort: 80, PrivatePort: 90, IP: "localhost"}} + c2.Ports = []containerType.PortSummary{{PublicPort: 80, PrivatePort: 90, IP: "localhost"}} c3, inspect3 := containerDetails("service2", "789", containerType.StateExited, "", 130) api.EXPECT().ContainerList(ctx, listOpts).Return([]containerType.Summary{c1, c2, c3}, nil) api.EXPECT().ContainerInspect(anyCancellableContext(), "123").Return(inspect1, nil) @@ -105,12 +105,10 @@ func containerDetails(service string, id string, status containerType.ContainerS State: status, } inspect := containerType.InspectResponse{ - ContainerJSONBase: &containerType.ContainerJSONBase{ - State: &containerType.State{ - Status: status, - Health: &containerType.Health{Status: health}, - ExitCode: exitCode, - }, + State: &containerType.State{ + Status: status, + Health: &containerType.Health{Status: health}, + ExitCode: exitCode, }, } return ctr, inspect diff --git a/pkg/compose/pull.go b/pkg/compose/pull.go index aea3403c3b8..fa6bbda07cd 100644 --- a/pkg/compose/pull.go +++ b/pkg/compose/pull.go @@ -31,9 +31,8 @@ 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/moby/moby/client" + "github.com/moby/moby/client/pkg/jsonmessage" "github.com/opencontainers/go-digest" "golang.org/x/sync/errgroup" @@ -198,7 +197,7 @@ func (s *composeService) pullServiceImage(ctx context.Context, service types.Ser platform = defaultPlatform } - stream, err := s.apiClient().ImagePull(ctx, service.Image, image.PullOptions{ + stream, err := s.apiClient().ImagePull(ctx, service.Image, client.ImagePullOptions{ RegistryAuth: encodedAuth, Platform: platform, }) diff --git a/pkg/compose/push.go b/pkg/compose/push.go index 97477eed866..17f283c9c9f 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/client" + "github.com/moby/moby/client/pkg/jsonmessage" "golang.org/x/sync/errgroup" "github.com/docker/compose/v2/internal/registry" @@ -100,7 +100,7 @@ func (s *composeService) pushServiceImage(ctx context.Context, tag string, confi return err } - stream, err := s.apiClient().ImagePush(ctx, tag, image.PushOptions{ + stream, err := s.apiClient().ImagePush(ctx, tag, client.ImagePushOptions{ RegistryAuth: base64.URLEncoding.EncodeToString(buf), }) if err != nil { 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..a2062d6f128 100644 --- a/pkg/compose/stop_test.go +++ b/pkg/compose/stop_test.go @@ -22,10 +22,11 @@ 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" + "github.com/moby/moby/client" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" @@ -51,11 +52,11 @@ func TestStopTimeout(t *testing.T) { }, nil) api.EXPECT().VolumeList( gomock.Any(), - volume.ListOptions{ + client.VolumeListOptions{ Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject))), }). Return(volume.ListResponse{}, nil) - api.EXPECT().NetworkList(gomock.Any(), network.ListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). + api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)))}). Return([]network.Summary{}, nil) timeout := 2 * time.Second diff --git a/pkg/compose/volumes.go b/pkg/compose/volumes.go index 8c7bbed2f6f..2d269438c4c 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/client" ) func (s *composeService) Volumes(ctx context.Context, project *types.Project, options api.VolumesOptions) ([]api.VolumesSummary, error) { @@ -50,7 +50,7 @@ func (s *composeService) Volumes(ctx context.Context, project *types.Project, op containers = allContainers } - volumesResponse, err := s.apiClient().VolumeList(ctx, volume.ListOptions{ + volumesResponse, err := s.apiClient().VolumeList(ctx, client.VolumeListOptions{ Filters: filters.NewArgs(projectFilter(projectName)), }) if err != nil { diff --git a/pkg/compose/volumes_test.go b/pkg/compose/volumes_test.go index 8e149159b23..f84fcec0a1d 100644 --- a/pkg/compose/volumes_test.go +++ b/pkg/compose/volumes_test.go @@ -22,9 +22,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/volume" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/filters" + "github.com/moby/moby/api/types/volume" + "github.com/moby/moby/client" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" ) @@ -63,7 +64,7 @@ func TestVolumes(t *testing.T) { args := filters.NewArgs(projectFilter(testProject)) listOpts := container.ListOptions{Filters: args} volumeListArgs := filters.NewArgs(projectFilter(testProject)) - volumeListOpts := volume.ListOptions{Filters: volumeListArgs} + volumeListOpts := client.VolumeListOptions{Filters: volumeListArgs} volumeReturn := volume.ListResponse{ Volumes: []*volume.Volume{vol1, vol2, vol3}, } diff --git a/pkg/compose/watch.go b/pkg/compose/watch.go index 60281dd0ed9..0c8b4f74633 100644 --- a/pkg/compose/watch.go +++ b/pkg/compose/watch.go @@ -36,14 +36,14 @@ import ( "github.com/docker/compose/v2/pkg/progress" cutils "github.com/docker/compose/v2/pkg/utils" "github.com/docker/compose/v2/pkg/watch" + "github.com/moby/moby/client" "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/sirupsen/logrus" "golang.org/x/sync/errgroup" ) @@ -674,7 +674,7 @@ func writeWatchSyncMessage(log api.LogConsumer, serviceName string, pathMappings } func (s *composeService) pruneDanglingImagesOnRebuild(ctx context.Context, projectName string, imageNameToIdMap map[string]string) { - images, err := s.apiClient().ImageList(ctx, image.ListOptions{ + images, err := s.apiClient().ImageList(ctx, client.ImageListOptions{ Filters: filters.NewArgs( filters.Arg("dangling", "true"), filters.Arg("label", api.ProjectLabel+"="+projectName), @@ -687,7 +687,7 @@ func (s *composeService) pruneDanglingImagesOnRebuild(ctx context.Context, proje for _, img := range images { if _, ok := imageNameToIdMap[img.ID]; !ok { - _, err := s.apiClient().ImageRemove(ctx, img.ID, image.RemoveOptions{}) + _, err := s.apiClient().ImageRemove(ctx, img.ID, client.ImageRemoveOptions{}) if err != nil { logrus.Debugf("Failed to remove image %s: %v", img.ID, err) } diff --git a/pkg/compose/watch_test.go b/pkg/compose/watch_test.go index c009fdfc04e..57c390b167c 100644 --- a/pkg/compose/watch_test.go +++ b/pkg/compose/watch_test.go @@ -27,10 +27,11 @@ 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/moby/moby/client" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" "gotest.tools/v3/assert" @@ -80,7 +81,7 @@ func TestWatch_Sync(t *testing.T) { testContainer("test", "123", false), }, nil).AnyTimes() // we expect the image to be pruned - apiClient.EXPECT().ImageList(gomock.Any(), image.ListOptions{ + apiClient.EXPECT().ImageList(gomock.Any(), client.ImageListOptions{ Filters: filters.NewArgs( filters.Arg("dangling", "true"), filters.Arg("label", api.ProjectLabel+"=myProjectName"), @@ -89,8 +90,8 @@ func TestWatch_Sync(t *testing.T) { {ID: "123"}, {ID: "456"}, }, nil).Times(1) - apiClient.EXPECT().ImageRemove(gomock.Any(), "123", image.RemoveOptions{}).Times(1) - apiClient.EXPECT().ImageRemove(gomock.Any(), "456", image.RemoveOptions{}).Times(1) + apiClient.EXPECT().ImageRemove(gomock.Any(), "123", client.ImageRemoveOptions{}).Times(1) + apiClient.EXPECT().ImageRemove(gomock.Any(), "456", client.ImageRemoveOptions{}).Times(1) // cli.EXPECT().Client().Return(apiClient).AnyTimes() diff --git a/pkg/mocks/mock_docker_api.go b/pkg/mocks/mock_docker_api.go index 4a6ebaaccf4..ea8bcf3a708 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" ) @@ -189,7 +190,7 @@ func (mr *MockAPIClientMockRecorder) ConfigInspectWithRaw(arg0, arg1 any) *gomoc } // ConfigList mocks base method. -func (m *MockAPIClient) ConfigList(arg0 context.Context, arg1 swarm.ConfigListOptions) ([]swarm.Config, error) { +func (m *MockAPIClient) ConfigList(arg0 context.Context, arg1 client.ConfigListOptions) ([]swarm.Config, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ConfigList", arg0, arg1) ret0, _ := ret[0].([]swarm.Config) @@ -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 } @@ -337,7 +338,7 @@ func (mr *MockAPIClientMockRecorder) ContainerExecInspect(arg0, arg1 any) *gomoc } // ContainerExecResize mocks base method. -func (m *MockAPIClient) ContainerExecResize(arg0 context.Context, arg1 string, arg2 container.ResizeOptions) error { +func (m *MockAPIClient) ContainerExecResize(arg0 context.Context, arg1 string, arg2 client.ContainerResizeOptions) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ContainerExecResize", arg0, arg1, arg2) ret0, _ := ret[0].(error) @@ -497,7 +498,7 @@ func (mr *MockAPIClientMockRecorder) ContainerRename(arg0, arg1, arg2 any) *gomo } // ContainerResize mocks base method. -func (m *MockAPIClient) ContainerResize(arg0 context.Context, arg1 string, arg2 container.ResizeOptions) error { +func (m *MockAPIClient) ContainerResize(arg0 context.Context, arg1 string, arg2 client.ContainerResizeOptions) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ContainerResize", arg0, arg1, arg2) ret0, _ := ret[0].(error) @@ -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 client.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 } @@ -775,7 +776,7 @@ func (mr *MockAPIClientMockRecorder) DistributionInspect(arg0, arg1, arg2 any) * } // Events mocks base method. -func (m *MockAPIClient) Events(arg0 context.Context, arg1 events.ListOptions) (<-chan events.Message, <-chan error) { +func (m *MockAPIClient) Events(arg0 context.Context, arg1 client.EventsListOptions) (<-chan events.Message, <-chan error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Events", arg0, arg1) ret0, _ := ret[0].(<-chan events.Message) @@ -819,7 +820,7 @@ func (mr *MockAPIClientMockRecorder) ImageBuild(arg0, arg1, arg2 any) *gomock.Ca } // ImageCreate mocks base method. -func (m *MockAPIClient) ImageCreate(arg0 context.Context, arg1 string, arg2 image.CreateOptions) (io.ReadCloser, error) { +func (m *MockAPIClient) ImageCreate(arg0 context.Context, arg1 string, arg2 client.ImageCreateOptions) (io.ReadCloser, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ImageCreate", arg0, arg1, arg2) ret0, _ := ret[0].(io.ReadCloser) @@ -854,7 +855,7 @@ func (mr *MockAPIClientMockRecorder) ImageHistory(arg0, arg1 any, arg2 ...any) * } // ImageImport mocks base method. -func (m *MockAPIClient) ImageImport(arg0 context.Context, arg1 image.ImportSource, arg2 string, arg3 image.ImportOptions) (io.ReadCloser, error) { +func (m *MockAPIClient) ImageImport(arg0 context.Context, arg1 client.ImageImportSource, arg2 string, arg3 client.ImageImportOptions) (io.ReadCloser, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ImageImport", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(io.ReadCloser) @@ -905,7 +906,7 @@ func (mr *MockAPIClientMockRecorder) ImageInspectWithRaw(arg0, arg1 any) *gomock } // ImageList mocks base method. -func (m *MockAPIClient) ImageList(arg0 context.Context, arg1 image.ListOptions) ([]image.Summary, error) { +func (m *MockAPIClient) ImageList(arg0 context.Context, arg1 client.ImageListOptions) ([]image.Summary, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ImageList", arg0, arg1) ret0, _ := ret[0].([]image.Summary) @@ -940,7 +941,7 @@ func (mr *MockAPIClientMockRecorder) ImageLoad(arg0, arg1 any, arg2 ...any) *gom } // ImagePull mocks base method. -func (m *MockAPIClient) ImagePull(arg0 context.Context, arg1 string, arg2 image.PullOptions) (io.ReadCloser, error) { +func (m *MockAPIClient) ImagePull(arg0 context.Context, arg1 string, arg2 client.ImagePullOptions) (io.ReadCloser, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ImagePull", arg0, arg1, arg2) ret0, _ := ret[0].(io.ReadCloser) @@ -955,7 +956,7 @@ func (mr *MockAPIClientMockRecorder) ImagePull(arg0, arg1, arg2 any) *gomock.Cal } // ImagePush mocks base method. -func (m *MockAPIClient) ImagePush(arg0 context.Context, arg1 string, arg2 image.PushOptions) (io.ReadCloser, error) { +func (m *MockAPIClient) ImagePush(arg0 context.Context, arg1 string, arg2 client.ImagePushOptions) (io.ReadCloser, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ImagePush", arg0, arg1, arg2) ret0, _ := ret[0].(io.ReadCloser) @@ -970,7 +971,7 @@ func (mr *MockAPIClientMockRecorder) ImagePush(arg0, arg1, arg2 any) *gomock.Cal } // ImageRemove mocks base method. -func (m *MockAPIClient) ImageRemove(arg0 context.Context, arg1 string, arg2 image.RemoveOptions) ([]image.DeleteResponse, error) { +func (m *MockAPIClient) ImageRemove(arg0 context.Context, arg1 string, arg2 client.ImageRemoveOptions) ([]image.DeleteResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ImageRemove", arg0, arg1, arg2) ret0, _ := ret[0].([]image.DeleteResponse) @@ -1005,7 +1006,7 @@ func (mr *MockAPIClientMockRecorder) ImageSave(arg0, arg1 any, arg2 ...any) *gom } // ImageSearch mocks base method. -func (m *MockAPIClient) ImageSearch(arg0 context.Context, arg1 string, arg2 registry.SearchOptions) ([]registry.SearchResult, error) { +func (m *MockAPIClient) ImageSearch(arg0 context.Context, arg1 string, arg2 client.ImageSearchOptions) ([]registry.SearchResult, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ImageSearch", arg0, arg1, arg2) ret0, _ := ret[0].([]registry.SearchResult) @@ -1102,7 +1103,7 @@ func (mr *MockAPIClientMockRecorder) NetworkConnect(arg0, arg1, arg2, arg3 any) } // NetworkCreate mocks base method. -func (m *MockAPIClient) NetworkCreate(arg0 context.Context, arg1 string, arg2 network.CreateOptions) (network.CreateResponse, error) { +func (m *MockAPIClient) NetworkCreate(arg0 context.Context, arg1 string, arg2 client.NetworkCreateOptions) (network.CreateResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NetworkCreate", arg0, arg1, arg2) ret0, _ := ret[0].(network.CreateResponse) @@ -1131,7 +1132,7 @@ func (mr *MockAPIClientMockRecorder) NetworkDisconnect(arg0, arg1, arg2, arg3 an } // NetworkInspect mocks base method. -func (m *MockAPIClient) NetworkInspect(arg0 context.Context, arg1 string, arg2 network.InspectOptions) (network.Inspect, error) { +func (m *MockAPIClient) NetworkInspect(arg0 context.Context, arg1 string, arg2 client.NetworkInspectOptions) (network.Inspect, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NetworkInspect", arg0, arg1, arg2) ret0, _ := ret[0].(network.Inspect) @@ -1146,7 +1147,7 @@ func (mr *MockAPIClientMockRecorder) NetworkInspect(arg0, arg1, arg2 any) *gomoc } // NetworkInspectWithRaw mocks base method. -func (m *MockAPIClient) NetworkInspectWithRaw(arg0 context.Context, arg1 string, arg2 network.InspectOptions) (network.Inspect, []byte, error) { +func (m *MockAPIClient) NetworkInspectWithRaw(arg0 context.Context, arg1 string, arg2 client.NetworkInspectOptions) (network.Inspect, []byte, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NetworkInspectWithRaw", arg0, arg1, arg2) ret0, _ := ret[0].(network.Inspect) @@ -1162,7 +1163,7 @@ func (mr *MockAPIClientMockRecorder) NetworkInspectWithRaw(arg0, arg1, arg2 any) } // NetworkList mocks base method. -func (m *MockAPIClient) NetworkList(arg0 context.Context, arg1 network.ListOptions) ([]network.Inspect, error) { +func (m *MockAPIClient) NetworkList(arg0 context.Context, arg1 client.NetworkListOptions) ([]network.Inspect, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NetworkList", arg0, arg1) ret0, _ := ret[0].([]network.Inspect) @@ -1222,7 +1223,7 @@ func (mr *MockAPIClientMockRecorder) NodeInspectWithRaw(arg0, arg1 any) *gomock. } // NodeList mocks base method. -func (m *MockAPIClient) NodeList(arg0 context.Context, arg1 swarm.NodeListOptions) ([]swarm.Node, error) { +func (m *MockAPIClient) NodeList(arg0 context.Context, arg1 client.NodeListOptions) ([]swarm.Node, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NodeList", arg0, arg1) ret0, _ := ret[0].([]swarm.Node) @@ -1237,7 +1238,7 @@ func (mr *MockAPIClientMockRecorder) NodeList(arg0, arg1 any) *gomock.Call { } // NodeRemove mocks base method. -func (m *MockAPIClient) NodeRemove(arg0 context.Context, arg1 string, arg2 swarm.NodeRemoveOptions) error { +func (m *MockAPIClient) NodeRemove(arg0 context.Context, arg1 string, arg2 client.NodeRemoveOptions) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NodeRemove", arg0, arg1, arg2) ret0, _ := ret[0].(error) @@ -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) @@ -1472,7 +1473,7 @@ func (mr *MockAPIClientMockRecorder) SecretInspectWithRaw(arg0, arg1 any) *gomoc } // SecretList mocks base method. -func (m *MockAPIClient) SecretList(arg0 context.Context, arg1 swarm.SecretListOptions) ([]swarm.Secret, error) { +func (m *MockAPIClient) SecretList(arg0 context.Context, arg1 client.SecretListOptions) ([]swarm.Secret, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SecretList", arg0, arg1) ret0, _ := ret[0].([]swarm.Secret) @@ -1530,7 +1531,7 @@ func (mr *MockAPIClientMockRecorder) ServerVersion(arg0 any) *gomock.Call { } // ServiceCreate mocks base method. -func (m *MockAPIClient) ServiceCreate(arg0 context.Context, arg1 swarm.ServiceSpec, arg2 swarm.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) { +func (m *MockAPIClient) ServiceCreate(arg0 context.Context, arg1 swarm.ServiceSpec, arg2 client.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ServiceCreate", arg0, arg1, arg2) ret0, _ := ret[0].(swarm.ServiceCreateResponse) @@ -1545,7 +1546,7 @@ func (mr *MockAPIClientMockRecorder) ServiceCreate(arg0, arg1, arg2 any) *gomock } // ServiceInspectWithRaw mocks base method. -func (m *MockAPIClient) ServiceInspectWithRaw(arg0 context.Context, arg1 string, arg2 swarm.ServiceInspectOptions) (swarm.Service, []byte, error) { +func (m *MockAPIClient) ServiceInspectWithRaw(arg0 context.Context, arg1 string, arg2 client.ServiceInspectOptions) (swarm.Service, []byte, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ServiceInspectWithRaw", arg0, arg1, arg2) ret0, _ := ret[0].(swarm.Service) @@ -1561,7 +1562,7 @@ func (mr *MockAPIClientMockRecorder) ServiceInspectWithRaw(arg0, arg1, arg2 any) } // ServiceList mocks base method. -func (m *MockAPIClient) ServiceList(arg0 context.Context, arg1 swarm.ServiceListOptions) ([]swarm.Service, error) { +func (m *MockAPIClient) ServiceList(arg0 context.Context, arg1 client.ServiceListOptions) ([]swarm.Service, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ServiceList", arg0, arg1) ret0, _ := ret[0].([]swarm.Service) @@ -1605,7 +1606,7 @@ func (mr *MockAPIClientMockRecorder) ServiceRemove(arg0, arg1 any) *gomock.Call } // ServiceUpdate mocks base method. -func (m *MockAPIClient) ServiceUpdate(arg0 context.Context, arg1 string, arg2 swarm.Version, arg3 swarm.ServiceSpec, arg4 swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) { +func (m *MockAPIClient) ServiceUpdate(arg0 context.Context, arg1 string, arg2 swarm.Version, arg3 swarm.ServiceSpec, arg4 client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ServiceUpdate", arg0, arg1, arg2, arg3, arg4) ret0, _ := ret[0].(swarm.ServiceUpdateResponse) @@ -1707,7 +1708,7 @@ func (mr *MockAPIClientMockRecorder) SwarmUnlock(arg0, arg1 any) *gomock.Call { } // SwarmUpdate mocks base method. -func (m *MockAPIClient) SwarmUpdate(arg0 context.Context, arg1 swarm.Version, arg2 swarm.Spec, arg3 swarm.UpdateFlags) error { +func (m *MockAPIClient) SwarmUpdate(arg0 context.Context, arg1 swarm.Version, arg2 swarm.Spec, arg3 client.SwarmUpdateFlags) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SwarmUpdate", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(error) @@ -1737,7 +1738,7 @@ func (mr *MockAPIClientMockRecorder) TaskInspectWithRaw(arg0, arg1 any) *gomock. } // TaskList mocks base method. -func (m *MockAPIClient) TaskList(arg0 context.Context, arg1 swarm.TaskListOptions) ([]swarm.Task, error) { +func (m *MockAPIClient) TaskList(arg0 context.Context, arg1 client.TaskListOptions) ([]swarm.Task, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "TaskList", arg0, arg1) ret0, _ := ret[0].([]swarm.Task) @@ -1813,7 +1814,7 @@ func (mr *MockAPIClientMockRecorder) VolumeInspectWithRaw(arg0, arg1 any) *gomoc } // VolumeList mocks base method. -func (m *MockAPIClient) VolumeList(arg0 context.Context, arg1 volume.ListOptions) (volume.ListResponse, error) { +func (m *MockAPIClient) VolumeList(arg0 context.Context, arg1 client.VolumeListOptions) (volume.ListResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "VolumeList", arg0, arg1) ret0, _ := ret[0].(volume.ListResponse) 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"