Merge pull request #145 from abursavich/master

consul: use empty slice instead of nil slice when no tags exist for /v1/catalog/services
This commit is contained in:
Armon Dadgar 2014-05-19 15:37:43 -07:00
commit 59c0d35184
2 changed files with 6 additions and 1 deletions

View File

@ -443,6 +443,11 @@ func TestCatalogListServices(t *testing.T) {
if len(out.Services) != 2 {
t.Fatalf("bad: %v", out)
}
for _, s := range out.Services {
if s == nil {
t.Fatalf("bad: %v", s)
}
}
// Consul service should auto-register
if _, ok := out.Services["consul"]; !ok {
t.Fatalf("bad: %v", out)

View File

@ -480,7 +480,7 @@ func (s *StateStore) Services() (uint64, map[string][]string) {
srv := r.(*structs.ServiceNode)
tags, ok := services[srv.ServiceName]
if !ok {
services[srv.ServiceName] = tags
services[srv.ServiceName] = make([]string, 0)
}
for _, tag := range srv.ServiceTags {