Skip to content

Commit 6f75c0c

Browse files
committed
add TODOs for replacing nat.ParsePortSpecs
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 9c10a9c commit 6f75c0c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

cli/command/container/opts.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,9 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con
426426
return nil, err
427427
}
428428

429+
// short syntax ([ip:]public:private[/proto])
430+
//
431+
// TODO(thaJeztah): we need an equivalent that handles the "ip-address" part without depending on the nat package.
429432
ports, natPortBindings, err := nat.ParsePortSpecs(convertedOpts)
430433
if err != nil {
431434
return nil, err

cli/compose/loader/loader.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,8 +918,9 @@ var transformStringToDuration TransformerFunc = func(value any) (any, error) {
918918
}
919919

920920
func toServicePortConfigs(value string) ([]any, error) {
921-
var portConfigs []any
922-
921+
// short syntax ([ip:]public:private[/proto])
922+
//
923+
// TODO(thaJeztah): we need an equivalent that handles the "ip-address" part without depending on the nat package.
923924
ports, portBindings, err := nat.ParsePortSpecs([]string{value})
924925
if err != nil {
925926
return nil, err
@@ -931,6 +932,7 @@ func toServicePortConfigs(value string) ([]any, error) {
931932
}
932933
sort.Strings(keys)
933934

935+
var portConfigs []any
934936
for _, key := range keys {
935937
// Reuse ConvertPortToPortConfig so that it is consistent
936938
port, err := network.ParsePort(key)

opts/swarmopts/port.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ func (p *PortOpt) Set(value string) error {
100100

101101
p.ports = append(p.ports, pConfig)
102102
} else {
103-
// short syntax
103+
// short syntax ([ip:]public:private[/proto])
104+
//
105+
// TODO(thaJeztah): we need an equivalent that handles the "ip-address" part without depending on the nat package.
104106
ports, portBindingMap, err := nat.ParsePortSpecs([]string{value})
105107
if err != nil {
106108
return err

0 commit comments

Comments
 (0)