Skip to content

Commit

Permalink
Include service.Attrs as Consul Meta for the service
Browse files Browse the repository at this point in the history
  • Loading branch information
dsouzajude committed Jun 17, 2018
1 parent 7d5571e commit d91f662
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"fmt"
"log"
"net/url"
"strings"
"strconv"
"os"
"strconv"
"strings"

"github.com/gliderlabs/registrator/bridge"
consulapi "github.com/hashicorp/consul/api"
"github.com/hashicorp/go-cleanhttp"
Expand Down Expand Up @@ -34,16 +35,16 @@ func (f *Factory) New(uri *url.URL) bridge.RegistryAdapter {
if uri.Scheme == "consul-unix" {
config.Address = strings.TrimPrefix(uri.String(), "consul-")
} else if uri.Scheme == "consul-tls" {
tlsConfigDesc := &consulapi.TLSConfig {
Address: uri.Host,
CAFile: os.Getenv("CONSUL_CACERT"),
CertFile: os.Getenv("CONSUL_TLSCERT"),
KeyFile: os.Getenv("CONSUL_TLSKEY"),
InsecureSkipVerify: false,
tlsConfigDesc := &consulapi.TLSConfig{
Address: uri.Host,
CAFile: os.Getenv("CONSUL_CACERT"),
CertFile: os.Getenv("CONSUL_TLSCERT"),
KeyFile: os.Getenv("CONSUL_TLSKEY"),
InsecureSkipVerify: false,
}
tlsConfig, err := consulapi.SetupTLSConfig(tlsConfigDesc)
if err != nil {
log.Fatal("Cannot set up Consul TLSConfig", err)
log.Fatal("Cannot set up Consul TLSConfig", err)
}
config.Scheme = "https"
transport := cleanhttp.DefaultPooledTransport()
Expand Down Expand Up @@ -84,6 +85,7 @@ func (r *ConsulAdapter) Register(service *bridge.Service) error {
registration.Tags = service.Tags
registration.Address = service.IP
registration.Check = r.buildCheck(service)
registration.Meta = service.Attrs
return r.client.Agent().ServiceRegister(registration)
}

Expand Down

0 comments on commit d91f662

Please sign in to comment.