mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
putting look back in, do some linting #2124
This commit is contained in:
parent
d2869b2f22
commit
87eeec7180
2 changed files with 16 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
bugfixes:
|
||||
- consul_kv lookup - use ``self.get_option`` and
|
||||
remove the function parse_params all together with its for loop
|
||||
remove the function parse_params get key form self.terms
|
||||
(https://github.com/ansible-collections/community.general/issues/2124).
|
||||
|
|
|
@ -126,7 +126,6 @@ class LookupModule(LookupBase):
|
|||
|
||||
# get options
|
||||
self.set_options(direct=kwargs)
|
||||
key = terms[0].split(' ')[0]
|
||||
scheme = self.get_option('scheme')
|
||||
host = self.get_option('host')
|
||||
port = self.get_option('port')
|
||||
|
@ -148,20 +147,22 @@ class LookupModule(LookupBase):
|
|||
|
||||
values = []
|
||||
try:
|
||||
consul_api = consul.Consul(host=host, port=port, scheme=scheme, token=token, dc=datacenter,
|
||||
verify=validate_certs, cert=client_cert)
|
||||
for term in terms:
|
||||
key = term.split(' ')[0]
|
||||
consul_api = consul.Consul(host=host, port=port, scheme=scheme, token=token,
|
||||
dc=datacenter,verify=validate_certs, cert=client_cert)
|
||||
|
||||
results = consul_api.kv.get(key,
|
||||
index=index,
|
||||
recurse=recurse,
|
||||
)
|
||||
if results[1]:
|
||||
# responds with a single or list of result maps
|
||||
if isinstance(results[1], list):
|
||||
for r in results[1]:
|
||||
values.append(to_text(r['Value']))
|
||||
else:
|
||||
values.append(to_text(results[1]['Value']))
|
||||
results = consul_api.kv.get(key,
|
||||
index=index,
|
||||
recurse=recurse,
|
||||
)
|
||||
if results[1]:
|
||||
# responds with a single or list of result maps
|
||||
if isinstance(results[1], list):
|
||||
for r in results[1]:
|
||||
values.append(to_text(r['Value']))
|
||||
else:
|
||||
values.append(to_text(results[1]['Value']))
|
||||
except Exception as e:
|
||||
raise AnsibleError(
|
||||
"Error locating '%s' in kv store. Error was %s" % (key, e))
|
||||
|
|
Loading…
Reference in a new issue