WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit fa986a4

Browse files
Merge pull request docker#145 from thaJeztah/nat_cleanups_2
nat: SortPortMap: don't require PortMap as argument
2 parents 9354edd + 20ac217 commit fa986a4

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

nat/sort.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (s portMapSorter) Less(i, j int) bool {
5555

5656
// SortPortMap sorts the list of ports and their respected mapping. The ports
5757
// will explicit HostPort will be placed first.
58-
func SortPortMap(ports []Port, bindings PortMap) {
58+
func SortPortMap(ports []Port, bindings map[Port][]PortBinding) {
5959
s := portMapSorter{}
6060
for _, p := range ports {
6161
if binding, ok := bindings[p]; ok && len(binding) > 0 {

nat/sort_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ func TestSortPortMap(t *testing.T) {
5050
"9999/tcp",
5151
}
5252

53-
portMap := PortMap{
54-
"22/tcp": []PortBinding{{}},
55-
"8000/tcp": []PortBinding{{}},
56-
"8443/tcp": []PortBinding{},
57-
"6379/tcp": []PortBinding{{}, {HostIP: "0.0.0.0", HostPort: "32749"}},
58-
"9999/tcp": []PortBinding{{HostIP: "0.0.0.0", HostPort: "40000"}},
53+
portMap := map[Port][]PortBinding{
54+
"22/tcp": {{}},
55+
"8000/tcp": {{}},
56+
"8443/tcp": {},
57+
"6379/tcp": {{}, {HostIP: "0.0.0.0", HostPort: "32749"}},
58+
"9999/tcp": {{HostIP: "0.0.0.0", HostPort: "40000"}},
5959
}
6060

6161
SortPortMap(ports, portMap)
@@ -69,7 +69,7 @@ func TestSortPortMap(t *testing.T) {
6969
}) {
7070
t.Errorf("failed to prioritize port with explicit mappings, got %v", ports)
7171
}
72-
if pm := portMap[Port("6379/tcp")]; !reflect.DeepEqual(pm, []PortBinding{
72+
if pm := portMap["6379/tcp"]; !reflect.DeepEqual(pm, []PortBinding{
7373
{HostIP: "0.0.0.0", HostPort: "32749"},
7474
{},
7575
}) {

0 commit comments

Comments
 (0)