def get_kv(consul_host, key, list_keys=False):
"""
Retrieve value for specified key from Consul (output: dict or list)
"""
url = '{}/{}/{}'.format(consul_host, CONSUL_KV_API, key)
if list_keys:
value = req('GET', url + '/?keys')
else:
try:
value = json.loads(b64decode(req('GET', url)[0]['Value']))
except ValueError as e:
abort(422, 'Bad JSON: {}'.format(e))
return value
评论列表
文章目录