From c21ff501070f7123deabfd0bc500f7a875970467 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Sun, 13 Sep 2015 14:36:33 -0700 Subject: [PATCH] nomad: exposing IntContains --- nomad/structs/network.go | 6 +++--- nomad/structs/network_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nomad/structs/network.go b/nomad/structs/network.go index 0141665d3..f1314cf7d 100644 --- a/nomad/structs/network.go +++ b/nomad/structs/network.go @@ -147,7 +147,7 @@ func (idx *NetworkIndex) AssignNetwork(ask *NetworkResource) (out *NetworkResour if _, ok := idx.UsedPorts[ipStr][randPort]; ok { goto PICK } - if intContains(offer.ReservedPorts, randPort) { + if IntContains(offer.ReservedPorts, randPort) { goto PICK } offer.ReservedPorts = append(offer.ReservedPorts, randPort) @@ -160,8 +160,8 @@ func (idx *NetworkIndex) AssignNetwork(ask *NetworkResource) (out *NetworkResour return } -// intContains scans an integer slice for a value -func intContains(haystack []int, needle int) bool { +// IntContains scans an integer slice for a value +func IntContains(haystack []int, needle int) bool { for _, item := range haystack { if item == needle { return true diff --git a/nomad/structs/network_test.go b/nomad/structs/network_test.go index c894b63cf..eb7094d75 100644 --- a/nomad/structs/network_test.go +++ b/nomad/structs/network_test.go @@ -268,13 +268,13 @@ func TestNetworkIndex_AssignNetwork(t *testing.T) { func TestIntContains(t *testing.T) { l := []int{1, 2, 10, 20} - if intContains(l, 50) { + if IntContains(l, 50) { t.Fatalf("bad") } - if !intContains(l, 20) { + if !IntContains(l, 20) { t.Fatalf("bad") } - if !intContains(l, 1) { + if !IntContains(l, 1) { t.Fatalf("bad") } }