if arg of put is str don't decode it
This commit is contained in:
parent
deee2b59cb
commit
96dc46032c
1 changed files with 6 additions and 1 deletions
|
@ -2,6 +2,7 @@ import etcd3
|
|||
import json
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass(init=False)
|
||||
class EtcdEntry:
|
||||
def __init__(self, meta, value, value_in_json=False):
|
||||
|
@ -15,6 +16,7 @@ class EtcdEntry:
|
|||
key: str
|
||||
value: str
|
||||
|
||||
|
||||
class Etcd3Wrapper(object):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.client = etcd3.client(*args, **kwargs)
|
||||
|
@ -29,8 +31,11 @@ class Etcd3Wrapper(object):
|
|||
_key, _value = args
|
||||
if value_in_json:
|
||||
_value = json.dumps(_value)
|
||||
return self.client.put(_key.decode("utf-8"), _value)
|
||||
|
||||
if not isinstance(_key, str):
|
||||
_key = _key.decode("utf-8")
|
||||
|
||||
return self.client.put(_key, _value, **kwargs)
|
||||
|
||||
def get_prefix(self, *args, value_in_json=False, **kwargs):
|
||||
r = self.client.get_prefix(*args, **kwargs)
|
||||
|
|
Loading…
Reference in a new issue