Skip to content

Commit

Permalink
Use "host" as var name to avoid shadowing the url var and don't skip …
Browse files Browse the repository at this point in the history
…the service.Registry lookup if it's enabled
  • Loading branch information
Anton Osmond committed Aug 6, 2018
1 parent 8e738cd commit 1e6718c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lile.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,16 @@ func AddStreamInterceptor(sint grpc.StreamServerInterceptor) {
// if not available via the registry
func URLForService(name string) string {

var url string
host := name
port := "80"

if val, ok := os.LookupEnv("SERVICE_HOST_OVERRIDE"); ok {
url = val
host = val
}
if val, ok := os.LookupEnv("SERVICE_PORT_OVERRIDE"); ok {
port = val
}

if url != "" {
return fmt.Sprintf("%s:%s", url, port)
}

if service.Registry != nil {
url, err := service.Registry.Get(name)
if err != nil {
Expand All @@ -136,7 +132,8 @@ func URLForService(name string) string {
return url
}

return name + ":80"
return fmt.Sprintf("%s:%s", host, port)

}

// ContextClientInterceptor passes around headers for tracing and linkerd
Expand Down

0 comments on commit 1e6718c

Please sign in to comment.