1
0
mirror of https://github.com/docker/cli.git synced 2026-01-26 15:41:42 +03:00

add TODOs for replacing nat.ParsePortSpecs

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-11-28 14:59:56 +01:00
parent 9c10a9c9ac
commit 6f75c0c8e2
3 changed files with 10 additions and 3 deletions

View File

@@ -426,6 +426,9 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con
return nil, err
}
// short syntax ([ip:]public:private[/proto])
//
// TODO(thaJeztah): we need an equivalent that handles the "ip-address" part without depending on the nat package.
ports, natPortBindings, err := nat.ParsePortSpecs(convertedOpts)
if err != nil {
return nil, err

View File

@@ -918,8 +918,9 @@ var transformStringToDuration TransformerFunc = func(value any) (any, error) {
}
func toServicePortConfigs(value string) ([]any, error) {
var portConfigs []any
// short syntax ([ip:]public:private[/proto])
//
// TODO(thaJeztah): we need an equivalent that handles the "ip-address" part without depending on the nat package.
ports, portBindings, err := nat.ParsePortSpecs([]string{value})
if err != nil {
return nil, err
@@ -931,6 +932,7 @@ func toServicePortConfigs(value string) ([]any, error) {
}
sort.Strings(keys)
var portConfigs []any
for _, key := range keys {
// Reuse ConvertPortToPortConfig so that it is consistent
port, err := network.ParsePort(key)

View File

@@ -100,7 +100,9 @@ func (p *PortOpt) Set(value string) error {
p.ports = append(p.ports, pConfig)
} else {
// short syntax
// short syntax ([ip:]public:private[/proto])
//
// TODO(thaJeztah): we need an equivalent that handles the "ip-address" part without depending on the nat package.
ports, portBindingMap, err := nat.ParsePortSpecs([]string{value})
if err != nil {
return err