@@ -36,16 +36,8 @@ import (
3636
3737var apiPortRegexp = regexp .MustCompile (`^(?P<hostref>(?P<hostip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|(?P<hostname>\S+):)?(?P<port>(\d{1,5}|random))$` )
3838
39- func ParsePortExposureSpec (exposedPortSpec , internalPort string ) (* k3d.ExposureOpts , error ) {
40- return parsePortExposureSpec (exposedPortSpec , internalPort , false )
41- }
42-
43- func ParseRegistryPortExposureSpec (exposedPortSpec string ) (* k3d.ExposureOpts , error ) {
44- return parsePortExposureSpec (exposedPortSpec , k3d .DefaultRegistryPort , true )
45- }
46-
4739// ParsePortExposureSpec parses/validates a string to create an exposePort struct from it
48- func parsePortExposureSpec (exposedPortSpec , internalPort string , enforcePortMatch bool ) (* k3d.ExposureOpts , error ) {
40+ func ParsePortExposureSpec (exposedPortSpec , internalPort string ) (* k3d.ExposureOpts , error ) {
4941 match := apiPortRegexp .FindStringSubmatch (exposedPortSpec )
5042
5143 if len (match ) == 0 {
@@ -91,7 +83,7 @@ func parsePortExposureSpec(exposedPortSpec, internalPort string, enforcePortMatc
9183 }
9284
9385 // port: get a free one if there's none defined or set to random
94- if submatches ["port" ] == "random" {
86+ if submatches ["port" ] == "" || submatches [ "port" ] == " random" {
9587 l .Log ().Debugf ("Port Exposure Mapping didn't specify hostPort, choosing one randomly..." )
9688 freePort , err := GetFreePort ()
9789 if err != nil || freePort == 0 {
@@ -104,10 +96,6 @@ func parsePortExposureSpec(exposedPortSpec, internalPort string, enforcePortMatc
10496 }
10597 }
10698
107- if enforcePortMatch {
108- internalPort = submatches ["port" ]
109- }
110-
11199 realPortString += fmt .Sprintf ("%s:%s/tcp" , submatches ["port" ], internalPort )
112100
113101 portMapping , err := nat .ParsePortSpec (realPortString )
0 commit comments