add https support for consul
using enviroment variables for example: export CONSUL_HTTP_SSL=1 export CONSUL_HTTP_ADDR="https://example.com" export CONSUL_CLIENT_CERT="/Users/foo/.ssh/consul/consul.cert" export CONSUL_CLIENT_KEY="/Users/foo/.ssh/consul/consul.key" export CONSUL_CACERT="/Users/foo/.ssh/consul/ca.cert"
This commit is contained in:
		| @@ -59,14 +59,6 @@ func newConsulRegistry(opts ...Option) Registry { | |||||||
| 			config = c | 			config = c | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	if config.HttpClient == nil { |  | ||||||
| 		config.HttpClient = new(http.Client) |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	// set timeout |  | ||||||
| 	if options.Timeout > 0 { |  | ||||||
| 		config.HttpClient.Timeout = options.Timeout |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	// check if there are any addrs | 	// check if there are any addrs | ||||||
| 	if len(options.Addrs) > 0 { | 	if len(options.Addrs) > 0 { | ||||||
| @@ -82,6 +74,10 @@ func newConsulRegistry(opts ...Option) Registry { | |||||||
|  |  | ||||||
| 	// requires secure connection? | 	// requires secure connection? | ||||||
| 	if options.Secure || options.TLSConfig != nil { | 	if options.Secure || options.TLSConfig != nil { | ||||||
|  | 		if config.HttpClient == nil { | ||||||
|  | 			config.HttpClient = new(http.Client) | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		config.Scheme = "https" | 		config.Scheme = "https" | ||||||
| 		// We're going to support InsecureSkipVerify | 		// We're going to support InsecureSkipVerify | ||||||
| 		config.HttpClient.Transport = newTransport(options.TLSConfig) | 		config.HttpClient.Transport = newTransport(options.TLSConfig) | ||||||
| @@ -90,6 +86,11 @@ func newConsulRegistry(opts ...Option) Registry { | |||||||
| 	// create the client | 	// create the client | ||||||
| 	client, _ := consul.NewClient(config) | 	client, _ := consul.NewClient(config) | ||||||
|  |  | ||||||
|  | 	// set timeout | ||||||
|  | 	if options.Timeout > 0 { | ||||||
|  | 		config.HttpClient.Timeout = options.Timeout | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	cr := &consulRegistry{ | 	cr := &consulRegistry{ | ||||||
| 		Address:  config.Address, | 		Address:  config.Address, | ||||||
| 		Client:   client, | 		Client:   client, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user