Merge pull request #814 from milosgajdos83/etcd-port
Append a port to address if it does not exist
This commit is contained in:
		| @@ -107,9 +107,9 @@ func configure(c *consulRegistry, opts ...registry.Option) { | |||||||
| 		if ae, ok := err.(*net.AddrError); ok && ae.Err == "missing port in address" { | 		if ae, ok := err.(*net.AddrError); ok && ae.Err == "missing port in address" { | ||||||
| 			port = "8500" | 			port = "8500" | ||||||
| 			addr = address | 			addr = address | ||||||
| 			addrs = append(addrs, fmt.Sprintf("%s:%s", addr, port)) | 			addrs = append(addrs, net.JoinHostPort(addr, port)) | ||||||
| 		} else if err == nil { | 		} else if err == nil { | ||||||
| 			addrs = append(addrs, fmt.Sprintf("%s:%s", addr, port)) | 			addrs = append(addrs, net.JoinHostPort(addr, port)) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ import ( | |||||||
| 	"crypto/tls" | 	"crypto/tls" | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"errors" | 	"errors" | ||||||
|  | 	"net" | ||||||
| 	"path" | 	"path" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"sync" | 	"sync" | ||||||
| @@ -74,11 +75,18 @@ func configure(e *etcdRegistry, opts ...registry.Option) error { | |||||||
|  |  | ||||||
| 	var cAddrs []string | 	var cAddrs []string | ||||||
|  |  | ||||||
| 	for _, addr := range e.options.Addrs { | 	for _, address := range e.options.Addrs { | ||||||
| 		if len(addr) == 0 { | 		if len(address) == 0 { | ||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
| 		cAddrs = append(cAddrs, addr) | 		addr, port, err := net.SplitHostPort(address) | ||||||
|  | 		if ae, ok := err.(*net.AddrError); ok && ae.Err == "missing port in address" { | ||||||
|  | 			port = "2379" | ||||||
|  | 			addr = address | ||||||
|  | 			cAddrs = append(cAddrs, net.JoinHostPort(addr, port)) | ||||||
|  | 		} else if err == nil { | ||||||
|  | 			cAddrs = append(cAddrs, net.JoinHostPort(addr, port)) | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// if we got addrs then we'll update | 	// if we got addrs then we'll update | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user