@@ -77,24 +77,30 @@ func toBuildkitExtraHosts(ctx context.Context, inp []string, nodeDriver *driver.
7777 }
7878 // If the IP Address is a "host-gateway", replace this value with the
7979 // IP address provided by the worker's label.
80+ var ips []string
8081 if ip == mobyHostGatewayName {
8182 hgip , err := nodeDriver .HostGatewayIP (ctx )
8283 if err != nil {
8384 return "" , errors .Wrap (err , "unable to derive the IP value for host-gateway" )
8485 }
85- ip = hgip .String ()
86+ ips = append ( ips , hgip .String () )
8687 } else {
87- // If the address is enclosed in square brackets, extract it (for IPv6, but
88- // permit it for IPv4 as well; we don't know the address family here, but it's
89- // unambiguous).
90- if len (ip ) > 2 && ip [0 ] == '[' && ip [len (ip )- 1 ] == ']' {
91- ip = ip [1 : len (ip )- 1 ]
92- }
93- if net .ParseIP (ip ) == nil {
94- return "" , errors .Errorf ("invalid host %s" , h )
88+ for _ , v := range strings .Split (ip , "," ) {
89+ // If the address is enclosed in square brackets, extract it
90+ // (for IPv6, but permit it for IPv4 as well; we don't know the
91+ // address family here, but it's unambiguous).
92+ if len (v ) > 2 && v [0 ] == '[' && v [len (v )- 1 ] == ']' {
93+ v = v [1 : len (v )- 1 ]
94+ }
95+ if net .ParseIP (v ) == nil {
96+ return "" , errors .Errorf ("invalid host %s" , h )
97+ }
98+ ips = append (ips , v )
9599 }
96100 }
97- hosts = append (hosts , host + "=" + ip )
101+ for _ , v := range ips {
102+ hosts = append (hosts , host + "=" + v )
103+ }
98104 }
99105 return strings .Join (hosts , "," ), nil
100106}
0 commit comments