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 d1f392fed3
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 { if len(out.Services) != 2 {
t.Fatalf("bad: %v", out) t.Fatalf("bad: %v", out)
} }
for _, s := range out.Services {
if s == nil {
t.Fatalf("bad: %v", s)
}
}
// Consul service should auto-register // Consul service should auto-register
if _, ok := out.Services["consul"]; !ok { if _, ok := out.Services["consul"]; !ok {
t.Fatalf("bad: %v", out) t.Fatalf("bad: %v", out)

View File

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