44 "errors"
55 "fmt"
66 "io"
7+ "net/netip"
78 "os"
89 "runtime"
910 "strings"
@@ -438,12 +439,12 @@ func TestParseWithExpose(t *testing.T) {
438439 "8080-NaN/tcp" : `invalid range format for --expose: 8080-NaN/tcp, error: strconv.ParseUint: parsing "NaN": invalid syntax` ,
439440 "1234567890-8080/tcp" : `invalid range format for --expose: 1234567890-8080/tcp, error: strconv.ParseUint: parsing "1234567890": value out of range` ,
440441 }
441- valids := map [string ][]container. PortRangeProto {
442- "8080/tcp" : {"8080/tcp" },
443- "8080/udp" : {"8080/udp" },
444- "8080/ncp" : {"8080/ncp" },
445- "8080-8080/udp" : {"8080/udp" },
446- "8080-8082/tcp" : {"8080/tcp" , "8081/tcp" , "8082/tcp" },
442+ valids := map [string ][]networktypes. Port {
443+ "8080/tcp" : {networktypes . MustParsePort ( "8080/tcp" ) },
444+ "8080/udp" : {networktypes . MustParsePort ( "8080/udp" ) },
445+ "8080/ncp" : {networktypes . MustParsePort ( "8080/ncp" ) },
446+ "8080-8080/udp" : {networktypes . MustParsePort ( "8080/udp" ) },
447+ "8080-8082/tcp" : {networktypes . MustParsePort ( "8080/tcp" ), networktypes . MustParsePort ( "8081/tcp" ), networktypes . MustParsePort ( "8082/tcp" ) },
447448 }
448449 for expose , expectedError := range invalids {
449450 if _ , _ , _ , err := parseRun ([]string {fmt .Sprintf ("--expose=%v" , expose ), "img" , "cmd" }); err == nil || err .Error () != expectedError {
@@ -472,7 +473,7 @@ func TestParseWithExpose(t *testing.T) {
472473 if len (config .ExposedPorts ) != 2 {
473474 t .Fatalf ("Expected 2 exposed ports, got %v" , config .ExposedPorts )
474475 }
475- ports := []container. PortRangeProto { "80/tcp" , "81/tcp" }
476+ ports := []networktypes. Port { networktypes . MustParsePort ( "80/tcp" ), networktypes . MustParsePort ( "81/tcp" ) }
476477 for _ , port := range ports {
477478 if _ , ok := config .ExposedPorts [port ]; ! ok {
478479 t .Fatalf ("Expected %v, got %v" , ports , config .ExposedPorts )
@@ -607,9 +608,9 @@ func TestParseNetworkConfig(t *testing.T) {
607608 expected : map [string ]* networktypes.EndpointSettings {
608609 "net1" : {
609610 IPAMConfig : & networktypes.EndpointIPAMConfig {
610- IPv4Address : "172.20.88.22" ,
611- IPv6Address : "2001:db8::8822" ,
612- LinkLocalIPs : []string { "169.254.2.2" , "fe80::169:254:2:2" },
611+ IPv4Address : netip . MustParseAddr ( "172.20.88.22" ) ,
612+ IPv6Address : netip . MustParseAddr ( "2001:db8::8822" ) ,
613+ LinkLocalIPs : []netip. Addr { netip . MustParseAddr ( "169.254.2.2" ), netip . MustParseAddr ( "fe80::169:254:2:2" ) },
613614 },
614615 Links : []string {"foo:bar" , "bar:baz" },
615616 Aliases : []string {"web1" , "web2" },
@@ -637,9 +638,9 @@ func TestParseNetworkConfig(t *testing.T) {
637638 "net1" : {
638639 DriverOpts : map [string ]string {"field1" : "value1" },
639640 IPAMConfig : & networktypes.EndpointIPAMConfig {
640- IPv4Address : "172.20.88.22" ,
641- IPv6Address : "2001:db8::8822" ,
642- LinkLocalIPs : []string { "169.254.2.2" , "fe80::169:254:2:2" },
641+ IPv4Address : netip . MustParseAddr ( "172.20.88.22" ) ,
642+ IPv6Address : netip . MustParseAddr ( "2001:db8::8822" ) ,
643+ LinkLocalIPs : []netip. Addr { netip . MustParseAddr ( "169.254.2.2" ), netip . MustParseAddr ( "fe80::169:254:2:2" ) },
643644 },
644645 Links : []string {"foo:bar" , "bar:baz" },
645646 Aliases : []string {"web1" , "web2" },
@@ -648,15 +649,15 @@ func TestParseNetworkConfig(t *testing.T) {
648649 "net3" : {
649650 DriverOpts : map [string ]string {"field3" : "value3" },
650651 IPAMConfig : & networktypes.EndpointIPAMConfig {
651- IPv4Address : "172.20.88.22" ,
652- IPv6Address : "2001:db8::8822" ,
652+ IPv4Address : netip . MustParseAddr ( "172.20.88.22" ) ,
653+ IPv6Address : netip . MustParseAddr ( "2001:db8::8822" ) ,
653654 },
654655 Aliases : []string {"web3" },
655656 },
656657 "net4" : {
657658 MacAddress : "02:32:1c:23:00:04" ,
658659 IPAMConfig : & networktypes.EndpointIPAMConfig {
659- LinkLocalIPs : []string { "169.254.169.254" },
660+ LinkLocalIPs : []netip. Addr { netip . MustParseAddr ( "169.254.169.254" ) },
660661 },
661662 },
662663 },
@@ -672,8 +673,8 @@ func TestParseNetworkConfig(t *testing.T) {
672673 "field2" : "value2" ,
673674 },
674675 IPAMConfig : & networktypes.EndpointIPAMConfig {
675- IPv4Address : "172.20.88.22" ,
676- IPv6Address : "2001:db8::8822" ,
676+ IPv4Address : netip . MustParseAddr ( "172.20.88.22" ) ,
677+ IPv6Address : netip . MustParseAddr ( "2001:db8::8822" ) ,
677678 },
678679 Aliases : []string {"web1" , "web2" },
679680 MacAddress : "02:32:1c:23:00:04" ,
0 commit comments