nat: enable upper case proto
| ... | ... |
@@ -2293,6 +2293,27 @@ func TestBuildExposeOrder(t *testing.T) {
|
| 2293 | 2293 |
logDone("build - expose order")
|
| 2294 | 2294 |
} |
| 2295 | 2295 |
|
| 2296 |
+func TestBuildExposeUpperCaseProto(t *testing.T) {
|
|
| 2297 |
+ name := "testbuildexposeuppercaseproto" |
|
| 2298 |
+ expected := "map[5678/udp:map[]]" |
|
| 2299 |
+ defer deleteImages(name) |
|
| 2300 |
+ _, err := buildImage(name, |
|
| 2301 |
+ `FROM scratch |
|
| 2302 |
+ EXPOSE 5678/UDP`, |
|
| 2303 |
+ true) |
|
| 2304 |
+ if err != nil {
|
|
| 2305 |
+ t.Fatal(err) |
|
| 2306 |
+ } |
|
| 2307 |
+ res, err := inspectField(name, "Config.ExposedPorts") |
|
| 2308 |
+ if err != nil {
|
|
| 2309 |
+ t.Fatal(err) |
|
| 2310 |
+ } |
|
| 2311 |
+ if res != expected {
|
|
| 2312 |
+ t.Fatalf("Exposed ports %s, expected %s", res, expected)
|
|
| 2313 |
+ } |
|
| 2314 |
+ logDone("build - expose port with upper case proto")
|
|
| 2315 |
+} |
|
| 2316 |
+ |
|
| 2296 | 2317 |
func TestBuildEmptyEntrypointInheritance(t *testing.T) {
|
| 2297 | 2318 |
name := "testbuildentrypointinheritance" |
| 2298 | 2319 |
name2 := "testbuildentrypointinheritance2" |
| ... | ... |
@@ -140,7 +140,7 @@ func ParsePortSpecs(ports []string) (map[Port]struct{}, map[Port][]PortBinding,
|
| 140 | 140 |
return nil, nil, fmt.Errorf("Invalid ranges specified for container and host Ports: %s and %s", containerPort, hostPort)
|
| 141 | 141 |
} |
| 142 | 142 |
|
| 143 |
- if !validateProto(proto) {
|
|
| 143 |
+ if !validateProto(strings.ToLower(proto)) {
|
|
| 144 | 144 |
return nil, nil, fmt.Errorf("Invalid proto: %s", proto)
|
| 145 | 145 |
} |
| 146 | 146 |
|
| ... | ... |
@@ -149,7 +149,7 @@ func ParsePortSpecs(ports []string) (map[Port]struct{}, map[Port][]PortBinding,
|
| 149 | 149 |
if len(hostPort) > 0 {
|
| 150 | 150 |
hostPort = strconv.FormatUint(startHostPort+i, 10) |
| 151 | 151 |
} |
| 152 |
- port := NewPort(proto, containerPort) |
|
| 152 |
+ port := NewPort(strings.ToLower(proto), containerPort) |
|
| 153 | 153 |
if _, exists := exposedPorts[port]; !exists {
|
| 154 | 154 |
exposedPorts[port] = struct{}{}
|
| 155 | 155 |
} |