much cleaner way to init etcd client
This commit is contained in:
parent
e7ea06aff1
commit
8f97bb0335
1 changed files with 9 additions and 11 deletions
20
config.py
20
config.py
|
@ -1,15 +1,13 @@
|
||||||
from etcd3_wrapper import Etcd3Wrapper
|
from etcd3_wrapper import Etcd3Wrapper
|
||||||
import decouple
|
import decouple
|
||||||
|
|
||||||
__ETCD_HOST = decouple.config("ETCD_HOST", None)
|
etcd_wrapper_args = ()
|
||||||
__ETCD_PORT = decouple.config("ETCD_PORT", None)
|
etcd_wrapper_kwargs = {
|
||||||
__CA_CERT = decouple.config("CA_CERT", None)
|
'host': decouple.config('ETCD_URL', 'localhost'),
|
||||||
__CERT_CERT = decouple.config("CERT_CERT", None)
|
'port': decouple.config('ETCD_PORT', 2379),
|
||||||
__CERT_KEY = decouple.config("CERT_KEY", None)
|
'ca_cert': decouple.config('CA_CERT', None),
|
||||||
|
'cert_cert': decouple.config('CERT_CERT', None),
|
||||||
|
'cert_key': decouple.config('CERT_KEY', None)
|
||||||
|
}
|
||||||
|
|
||||||
if __ETCD_HOST and __ETCD_PORT and __CA_CERT and __CERT_CERT and __CERT_KEY:
|
etcd_client = Etcd3Wrapper(*etcd_wrapper_args, **etcd_wrapper_kwargs)
|
||||||
etcd_client = Etcd3Wrapper(host=__ETCD_HOST, port=__ETCD_PORT,
|
|
||||||
ca_cert=__CA_CERT, cert_cert=__CERT_CERT,
|
|
||||||
cert_key=__CERT_KEY)
|
|
||||||
else:
|
|
||||||
etcd_client = Etcd3Wrapper()
|
|
||||||
|
|
Loading…
Reference in a new issue