mirror of
https://github.com/docker/docs.git
synced 2026-04-03 01:38:58 +07:00
Ignore empty addresses when creating discovery entries
Signed-off-by: Ferran Rodenas <frodenas@gmail.com>
This commit is contained in:
@@ -84,6 +84,9 @@ func CreateEntries(addrs []string) ([]*Entry, error) {
|
||||
}
|
||||
|
||||
for _, addr := range addrs {
|
||||
if len(addr) == 0 {
|
||||
continue
|
||||
}
|
||||
entry, err := NewEntry(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -43,7 +43,8 @@ func TestCreateEntries(t *testing.T) {
|
||||
assert.Equal(t, entries, []*Entry{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
entries, err = CreateEntries([]string{"127.0.0.1:2375", "127.0.0.2:2375"})
|
||||
entries, err = CreateEntries([]string{"127.0.0.1:2375", "127.0.0.2:2375", ""})
|
||||
assert.Equal(t, len(entries), 2)
|
||||
assert.Equal(t, entries[0].String(), "127.0.0.1:2375")
|
||||
assert.Equal(t, entries[1].String(), "127.0.0.2:2375")
|
||||
assert.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user