Skip to content

Commit

Permalink
Merge pull request #14 from trafficstars/set-datacenter
Browse files Browse the repository at this point in the history
set datacenter name to consul service
  • Loading branch information
DoubleDi authored Jan 7, 2021
2 parents 20a5311 + 56527c6 commit 34a3a8e
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (d *discovery) lookup(filter *Filter) ([]Service, error) {
srv = Service{
ID: item.ServiceID,
Name: item.ServiceName,
Datacenter: dc(item.ServiceTags),
Datacenter: item.Datacenter,
Address: item.ServiceAddress,
Port: item.ServicePort,
Tags: item.ServiceTags,
Expand Down Expand Up @@ -174,12 +174,3 @@ func (d *discovery) lookup(filter *Filter) ([]Service, error) {
}
return services, nil
}

func dc(tags []string) string {
for _, tag := range tags {
if strings.HasPrefix(tag, "DC=") {
return strings.TrimPrefix(tag, "DC=")
}
}
return ""
}

0 comments on commit 34a3a8e

Please sign in to comment.