@@ -36,16 +36,8 @@ import (
36
36
37
37
var 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))$` )
38
38
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
-
47
39
// 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 ) {
49
41
match := apiPortRegexp .FindStringSubmatch (exposedPortSpec )
50
42
51
43
if len (match ) == 0 {
@@ -91,7 +83,7 @@ func parsePortExposureSpec(exposedPortSpec, internalPort string, enforcePortMatc
91
83
}
92
84
93
85
// 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" {
95
87
l .Log ().Debugf ("Port Exposure Mapping didn't specify hostPort, choosing one randomly..." )
96
88
freePort , err := GetFreePort ()
97
89
if err != nil || freePort == 0 {
@@ -104,10 +96,6 @@ func parsePortExposureSpec(exposedPortSpec, internalPort string, enforcePortMatc
104
96
}
105
97
}
106
98
107
- if enforcePortMatch {
108
- internalPort = submatches ["port" ]
109
- }
110
-
111
99
realPortString += fmt .Sprintf ("%s:%s/tcp" , submatches ["port" ], internalPort )
112
100
113
101
portMapping , err := nat .ParsePortSpec (realPortString )
0 commit comments