Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/command/container/hijack.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"sync"

"github.com/docker/cli/cli/command"
"github.com/moby/moby/api/stdcopy"
"github.com/moby/moby/api/pkg/stdcopy"
"github.com/moby/moby/client"
"github.com/moby/term"
"github.com/sirupsen/logrus"
Expand Down
2 changes: 1 addition & 1 deletion cli/command/container/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/completion"
"github.com/moby/moby/api/stdcopy"
"github.com/moby/moby/api/pkg/stdcopy"
"github.com/moby/moby/api/types/container"
"github.com/spf13/cobra"
)
Expand Down
4 changes: 2 additions & 2 deletions cli/command/container/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con

publishOpts := copts.publish.GetSlice()
var (
ports map[nat.Port]struct{}
portBindings map[nat.Port][]nat.PortBinding
ports map[container.PortRangeProto]struct{}
portBindings map[container.PortRangeProto][]container.PortBinding
convertedOpts []string
)

Expand Down
5 changes: 2 additions & 3 deletions cli/command/container/opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"testing"
"time"

"github.com/docker/go-connections/nat"
"github.com/moby/moby/api/types/container"
networktypes "github.com/moby/moby/api/types/network"
"github.com/spf13/pflag"
Expand Down Expand Up @@ -439,7 +438,7 @@ func TestParseWithExpose(t *testing.T) {
"8080-NaN/tcp": `invalid range format for --expose: 8080-NaN/tcp, error: strconv.ParseUint: parsing "NaN": invalid syntax`,
"1234567890-8080/tcp": `invalid range format for --expose: 1234567890-8080/tcp, error: strconv.ParseUint: parsing "1234567890": value out of range`,
}
valids := map[string][]nat.Port{
valids := map[string][]container.PortRangeProto{
"8080/tcp": {"8080/tcp"},
"8080/udp": {"8080/udp"},
"8080/ncp": {"8080/ncp"},
Expand Down Expand Up @@ -473,7 +472,7 @@ func TestParseWithExpose(t *testing.T) {
if len(config.ExposedPorts) != 2 {
t.Fatalf("Expected 2 exposed ports, got %v", config.ExposedPorts)
}
ports := []nat.Port{"80/tcp", "81/tcp"}
ports := []container.PortRangeProto{"80/tcp", "81/tcp"}
for _, port := range ports {
if _, ok := config.ExposedPorts[port]; !ok {
t.Fatalf("Expected %v, got %v", ports, config.ExposedPorts)
Expand Down
4 changes: 2 additions & 2 deletions cli/command/container/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/completion"
"github.com/docker/go-connections/nat"
"github.com/fvbommel/sortorder"
"github.com/moby/moby/api/types/container"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -67,7 +67,7 @@ func runPort(ctx context.Context, dockerCli command.Cli, opts *portOptions) erro
if _, err = strconv.ParseUint(port, 10, 16); err != nil {
return errors.Wrapf(err, "Error: invalid port (%s)", port)
}
frontends, exists := c.NetworkSettings.Ports[nat.Port(port+"/"+proto)]
frontends, exists := c.NetworkSettings.Ports[container.PortRangeProto(port+"/"+proto)]
if !exists || len(frontends) == 0 {
return errors.Errorf("Error: No public port '%s' published for %s", opts.port, opts.container)
}
Expand Down
15 changes: 7 additions & 8 deletions cli/command/container/port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"

"github.com/docker/cli/internal/test"
"github.com/docker/go-connections/nat"
"github.com/moby/moby/api/types/container"
"gotest.tools/v3/assert"
"gotest.tools/v3/golden"
Expand Down Expand Up @@ -47,19 +46,19 @@ func TestNewPortCommandOutput(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
inspectFunc: func(string) (container.InspectResponse, error) {
ci := container.InspectResponse{NetworkSettings: &container.NetworkSettings{}}
ci.NetworkSettings.Ports = nat.PortMap{
"80/tcp": make([]nat.PortBinding, len(tc.ips)),
"443/tcp": make([]nat.PortBinding, len(tc.ips)),
"443/udp": make([]nat.PortBinding, len(tc.ips)),
ci.NetworkSettings.Ports = container.PortMap{
"80/tcp": make([]container.PortBinding, len(tc.ips)),
"443/tcp": make([]container.PortBinding, len(tc.ips)),
"443/udp": make([]container.PortBinding, len(tc.ips)),
}
for i, ip := range tc.ips {
ci.NetworkSettings.Ports["80/tcp"][i] = nat.PortBinding{
ci.NetworkSettings.Ports["80/tcp"][i] = container.PortBinding{
HostIP: ip, HostPort: "3456",
}
ci.NetworkSettings.Ports["443/tcp"][i] = nat.PortBinding{
ci.NetworkSettings.Ports["443/tcp"][i] = container.PortBinding{
HostIP: ip, HostPort: "4567",
}
ci.NetworkSettings.Ports["443/udp"][i] = nat.PortBinding{
ci.NetworkSettings.Ports["443/udp"][i] = container.PortBinding{
HostIP: ip, HostPort: "5678",
}
}
Expand Down
11 changes: 7 additions & 4 deletions cli/command/container/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import (
"github.com/docker/cli/cli/streams"
"github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/notary"
"github.com/docker/docker/pkg/jsonmessage"
"github.com/moby/moby/api/types"
"github.com/moby/moby/api/types/container"
"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/client"
"github.com/moby/moby/client/pkg/jsonmessage"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/spf13/pflag"
"gotest.tools/v3/assert"
Expand Down Expand Up @@ -256,9 +257,11 @@ func TestRunPullTermination(t *testing.T) {
TimeNano: time.Now().UnixNano(),
Time: time.Now().Unix(),
Progress: &jsonmessage.JSONProgress{
Current: int64(i),
Total: 100,
Start: 0,
Progress: jsonstream.Progress{
Current: int64(i),
Total: 100,
Start: 0,
},
},
}))
time.Sleep(100 * time.Millisecond)
Expand Down
4 changes: 2 additions & 2 deletions cli/command/image/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"github.com/docker/cli/cli/streams"
"github.com/docker/cli/internal/jsonstream"
"github.com/docker/cli/opts"
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter"
"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"
registrytypes "github.com/moby/moby/api/types/registry"
Expand Down
4 changes: 2 additions & 2 deletions cli/command/image/build/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
"time"

"github.com/docker/cli/cli/command/image/build/internal/git"
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter"
"github.com/moby/go-archive"
"github.com/moby/go-archive/compression"
"github.com/moby/moby/api/pkg/progress"
"github.com/moby/moby/api/pkg/streamformatter"
"github.com/moby/patternmatcher"
"github.com/pkg/errors"
)
Expand Down
2 changes: 1 addition & 1 deletion cli/command/service/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/docker/cli/cli/command/formatter"
"github.com/docker/cli/cli/command/idresolver"
"github.com/docker/cli/internal/logdetails"
"github.com/moby/moby/api/stdcopy"
"github.com/moby/moby/api/pkg/stdcopy"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
Expand Down
4 changes: 2 additions & 2 deletions cli/command/service/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"time"

"github.com/docker/cli/cli/command/formatter"
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter"
"github.com/moby/moby/api/pkg/progress"
"github.com/moby/moby/api/pkg/streamformatter"
"github.com/moby/moby/api/types/filters"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
Expand Down
2 changes: 1 addition & 1 deletion cli/command/service/progress/progress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strconv"
"testing"

"github.com/docker/docker/pkg/progress"
"github.com/moby/moby/api/pkg/progress"
"github.com/moby/moby/api/types/swarm"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
Expand Down
4 changes: 2 additions & 2 deletions cli/command/swarm/progress/root_rotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"os/signal"
"time"

"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter"
"github.com/moby/moby/api/pkg/progress"
"github.com/moby/moby/api/pkg/streamformatter"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/opencontainers/go-digest"
Expand Down
3 changes: 2 additions & 1 deletion cli/compose/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/docker/go-units"
"github.com/go-viper/mapstructure/v2"
"github.com/google/shlex"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/versions"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -934,7 +935,7 @@ func toServicePortConfigs(value string) ([]any, error) {

for _, key := range keys {
// Reuse ConvertPortToPortConfig so that it is consistent
portConfig, err := swarmopts.ConvertPortToPortConfig(nat.Port(key), portBindings)
portConfig, err := swarmopts.ConvertPortToPortConfig(container.PortRangeProto(key), portBindings)
if err != nil {
return nil, err
}
Expand Down
9 changes: 5 additions & 4 deletions internal/jsonstream/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"context"
"io"

"github.com/docker/docker/pkg/jsonmessage"
"github.com/docker/cli/cli/streams"
"github.com/moby/moby/api/types/jsonstream"
"github.com/moby/moby/client/pkg/jsonmessage"
)

type (
Stream = jsonmessage.Stream
JSONError = jsonstream.Error
JSONMessage = jsonmessage.JSONMessage
JSONError = jsonmessage.JSONError
JSONProgress = jsonmessage.JSONProgress
)

Expand Down Expand Up @@ -46,7 +47,7 @@ func WithAuxCallback(cb func(JSONMessage)) Options {
// "context aware" and appropriately returns why the function was canceled.
//
// It returns an error if the context is canceled, but not if the input reader / stream is closed.
func Display(ctx context.Context, in io.Reader, stream Stream, opts ...Options) error {
func Display(ctx context.Context, in io.Reader, stream *streams.Out, opts ...Options) error {
if ctx.Err() != nil {
return ctx.Err()
}
Expand Down
9 changes: 6 additions & 3 deletions internal/jsonstream/display_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/docker/cli/cli/streams"
"github.com/moby/moby/api/types/jsonstream"
"gotest.tools/v3/assert"
)

Expand All @@ -35,9 +36,11 @@ func TestDisplay(t *testing.T) {
TimeNano: time.Now().UnixNano(),
Time: time.Now().Unix(),
Progress: &JSONProgress{
Current: int64(i),
Total: 100,
Start: 0,
Progress: jsonstream.Progress{
Current: int64(i),
Total: 100,
Start: 0,
},
},
})
if err != nil {
Expand Down
20 changes: 12 additions & 8 deletions opts/swarmopts/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"

"github.com/docker/go-connections/nat"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/swarm"
"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -150,28 +151,31 @@ func (p *PortOpt) Value() []swarm.PortConfig {

// ConvertPortToPortConfig converts ports to the swarm type
func ConvertPortToPortConfig(
port nat.Port,
portBindings map[nat.Port][]nat.PortBinding,
portRangeProto container.PortRangeProto,
portBindings map[container.PortRangeProto][]container.PortBinding,
) ([]swarm.PortConfig, error) {
ports := []swarm.PortConfig{}
proto, port := nat.SplitProtoPort(string(portRangeProto))
portInt, _ := strconv.ParseUint(port, 10, 16)
proto = strings.ToLower(proto)

for _, binding := range portBindings[port] {
var ports []swarm.PortConfig
for _, binding := range portBindings[portRangeProto] {
if p := net.ParseIP(binding.HostIP); p != nil && !p.IsUnspecified() {
// TODO(thaJeztah): use context-logger, so that this output can be suppressed (in tests).
logrus.Warnf("ignoring IP-address (%s:%s) service will listen on '0.0.0.0'", net.JoinHostPort(binding.HostIP, binding.HostPort), port)
logrus.Warnf("ignoring IP-address (%s:%s) service will listen on '0.0.0.0'", net.JoinHostPort(binding.HostIP, binding.HostPort), portRangeProto)
}

startHostPort, endHostPort, err := nat.ParsePortRange(binding.HostPort)

if err != nil && binding.HostPort != "" {
return nil, fmt.Errorf("invalid hostport binding (%s) for port (%s)", binding.HostPort, port.Port())
return nil, fmt.Errorf("invalid hostport binding (%s) for port (%s)", binding.HostPort, port)
}

for i := startHostPort; i <= endHostPort; i++ {
ports = append(ports, swarm.PortConfig{
// TODO Name: ?
Protocol: swarm.PortConfigProtocol(strings.ToLower(port.Proto())),
TargetPort: uint32(port.Int()),
Protocol: swarm.PortConfigProtocol(proto),
TargetPort: uint32(portInt),
PublishedPort: uint32(i),
PublishMode: swarm.PortConfigPublishModeIngress,
})
Expand Down
4 changes: 2 additions & 2 deletions opts/swarmopts/port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"testing"

"github.com/docker/go-connections/nat"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/swarm"
"github.com/sirupsen/logrus"
"gotest.tools/v3/assert"
Expand Down Expand Up @@ -347,7 +347,7 @@ func TestConvertPortToPortConfigWithIP(t *testing.T) {
logrus.SetOutput(&b)
for _, tc := range testCases {
t.Run(tc.value, func(t *testing.T) {
_, err := ConvertPortToPortConfig("80/tcp", map[nat.Port][]nat.PortBinding{
_, err := ConvertPortToPortConfig("80/tcp", map[container.PortRangeProto][]container.PortBinding{
"80/tcp": {{HostIP: tc.value, HostPort: "2345"}},
})
assert.NilError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions vendor.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ go 1.23.0

replace (
// FIXME(thaJeztah): temporarily need to pin on commits, otherwise go modules won't resolve until these are tagged.
github.com/moby/moby/api => github.com/moby/moby/api v0.0.0-20250729125042-2574c2b2e917
github.com/moby/moby/client => github.com/moby/moby/client v0.0.0-20250729125042-2574c2b2e917
github.com/moby/moby/api => github.com/moby/moby/api v0.0.0-20250731152656-4faedf2bec36
github.com/moby/moby/client => github.com/moby/moby/client v0.0.0-20250731152656-4faedf2bec36
)

require (
Expand All @@ -22,7 +22,7 @@ require (
github.com/distribution/reference v0.6.0
github.com/docker/cli-docs-tool v0.10.0
github.com/docker/distribution v2.8.3+incompatible
github.com/docker/docker v28.2.3-0.20250729125042-2574c2b2e917+incompatible // master (v29.0-dev)
github.com/docker/docker v28.2.3-0.20250731152656-4faedf2bec36+incompatible // master (v29.0-dev)
github.com/docker/docker-credential-helpers v0.9.3
github.com/docker/go-connections v0.5.0
github.com/docker/go-units v0.5.0
Expand Down
12 changes: 6 additions & 6 deletions vendor.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ github.com/docker/cli-docs-tool v0.10.0/go.mod h1:5EM5zPnT2E7yCLERZmrDA234Vwn09f
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.2.3-0.20250729125042-2574c2b2e917+incompatible h1:PmHpYwC9kywp7yqeiUlJYvQaOXoYh7Xy5C1N7Z+urVo=
github.com/docker/docker v28.2.3-0.20250729125042-2574c2b2e917+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v28.2.3-0.20250731152656-4faedf2bec36+incompatible h1:V1yo9808DrQaHES6Q3hW5Rtd44+mrc4oKulmzPgRDAM=
github.com/docker/docker v28.2.3-0.20250731152656-4faedf2bec36+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=
Expand Down Expand Up @@ -172,10 +172,10 @@ github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3N
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ=
github.com/moby/go-archive v0.1.0/go.mod h1:G9B+YoujNohJmrIYFBpSd54GTUB4lt9S+xVQvsJyFuo=
github.com/moby/moby/api v0.0.0-20250729125042-2574c2b2e917 h1:kUXvd5/UxuA9rOrBBJ79GKKuBD/HR76jJBZed/bg4+E=
github.com/moby/moby/api v0.0.0-20250729125042-2574c2b2e917/go.mod h1:UXRe3/H6L2SB5SrOqAhx5tsC0RqrhqtBoY8PFxjyp5k=
github.com/moby/moby/client v0.0.0-20250729125042-2574c2b2e917 h1:roWTPpD2XjM1Z8uYZO4HAD1pUKSpm1X5S3JqNsWYnVE=
github.com/moby/moby/client v0.0.0-20250729125042-2574c2b2e917/go.mod h1:aJbR/d6IN3wIBmj3XPFEY5E5Ndd6F57YQsqivzmCyO4=
github.com/moby/moby/api v0.0.0-20250731152656-4faedf2bec36 h1:2o6bmPZvLOYqE6mQGqnyt+556TMpa26ZtSxvgSpT+98=
github.com/moby/moby/api v0.0.0-20250731152656-4faedf2bec36/go.mod h1:GNQ0zU3WJGeJIcrLPE3xiQnsnLElvfqXQZZZiOqWuiE=
github.com/moby/moby/client v0.0.0-20250731152656-4faedf2bec36 h1:o32ntpp76dDd5Hf9+XL09+qs06120KvZl+Ogt+RkYG0=
github.com/moby/moby/client v0.0.0-20250731152656-4faedf2bec36/go.mod h1:+TFnycF6RuAUAq1tGTjZiSXuRcywpKUGo2dLkJ6tC48=
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/swarmkit/v2 v2.0.0 h1:jkWQKQaJ4ltA61/mC9UdPe1McLma55RUcacTO+pPweY=
Expand Down
Loading
Loading