Skip to content
This repository was archived by the owner on Apr 15, 2024. It is now read-only.

Commit 83cfde3

Browse files
committed
Merge pull request #74 from amayausky/using-environment-vars
Use standard consul environment variables to override configuration
2 parents 232702d + 60bfa22 commit 83cfde3

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

consul/base.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
import base64
44
import json
5+
import os
56

67
import six
78

@@ -190,8 +191,16 @@ def __init__(
190191

191192
# TODO: Status
192193

194+
if os.getenv('CONSUL_HTTP_ADDR'):
195+
host, port = os.getenv('CONSUL_HTTP_ADDR').split(':')
196+
use_ssl = os.getenv('CONSUL_HTTP_SSL')
197+
if use_ssl is not None:
198+
scheme = 'https' if use_ssl == 'true' else 'http'
199+
if os.getenv('CONSUL_HTTP_SSL_VERIFY') is not None:
200+
verify = os.getenv('CONSUL_HTTP_SSL_VERIFY') == 'true'
201+
193202
self.http = self.connect(host, port, scheme, verify)
194-
self.token = token
203+
self.token = os.getenv('CONSUL_HTTP_TOKEN', token)
195204
self.scheme = scheme
196205
self.dc = dc
197206
assert consistency in ('default', 'consistent', 'stale'), \

0 commit comments

Comments
 (0)