Skip to content

Commit

Permalink
Treat empty-string tags as no tags at all
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Potęga committed Jun 29, 2016
1 parent 56eb3bb commit fcf913d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 8 additions & 0 deletions consul/prepared_query/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,13 @@ func (ct *CompiledTemplate) Render(name string) (*structs.PreparedQuery, error)
return nil, err
}

tags := []string(nil)
for _, tag := range query.Service.Tags {
if tag != "" {
tags = append(tags, tag)
}
}
query.Service.Tags = tags

return query, nil
}
8 changes: 0 additions & 8 deletions consul/prepared_query/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,10 @@ func TestTemplate_Render(t *testing.T) {
Service: structs.ServiceQuery{
Service: "hello- xxx hello-foo-bar-none xxx foo-bar-none",
Tags: []string{
"",
"hello-foo-bar-none",
"hello",
"foo",
"bar-none",
"",
"42",
},
},
Expand All @@ -274,12 +272,6 @@ func TestTemplate_Render(t *testing.T) {
Service: structs.ServiceQuery{
Service: "hello- xxx hello-nope xxx nope",
Tags: []string{
"",
"",
"",
"",
"",
"",
"42",
},
},
Expand Down

0 comments on commit fcf913d

Please sign in to comment.