mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make env param a dict type instead of list
Also modifies param type checking code to remove whitespace from around params before splitting them into k=v pairs. Fixes #8199
This commit is contained in:
parent
a230a3fad9
commit
8dafacd4e9
2 changed files with 3 additions and 5 deletions
|
@ -808,7 +808,7 @@ class AnsibleModule(object):
|
||||||
self.fail_json(msg="unable to evaluate dictionary for %s" % k)
|
self.fail_json(msg="unable to evaluate dictionary for %s" % k)
|
||||||
self.params[k] = result
|
self.params[k] = result
|
||||||
elif '=' in value:
|
elif '=' in value:
|
||||||
self.params[k] = dict([x.split("=", 1) for x in value.split(",")])
|
self.params[k] = dict([x.strip().split("=", 1) for x in value.split(",")])
|
||||||
else:
|
else:
|
||||||
self.fail_json(msg="dictionary requested, could not parse JSON or key=value")
|
self.fail_json(msg="dictionary requested, could not parse JSON or key=value")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -411,9 +411,7 @@ class DockerManager:
|
||||||
if self.module.params.get('links'):
|
if self.module.params.get('links'):
|
||||||
self.links = self.get_links(self.module.params.get('links'))
|
self.links = self.get_links(self.module.params.get('links'))
|
||||||
|
|
||||||
self.env = None
|
self.env = self.module.params.get('env', None)
|
||||||
if self.module.params.get('env'):
|
|
||||||
self.env = dict(map(lambda x: x.split("=", 1), self.module.params.get('env')))
|
|
||||||
|
|
||||||
# connect to docker server
|
# connect to docker server
|
||||||
docker_url = urlparse(module.params.get('docker_url'))
|
docker_url = urlparse(module.params.get('docker_url'))
|
||||||
|
@ -706,7 +704,7 @@ def main():
|
||||||
password = dict(),
|
password = dict(),
|
||||||
email = dict(),
|
email = dict(),
|
||||||
hostname = dict(default=None),
|
hostname = dict(default=None),
|
||||||
env = dict(type='list'),
|
env = dict(type='dict'),
|
||||||
dns = dict(),
|
dns = dict(),
|
||||||
detach = dict(default=True, type='bool'),
|
detach = dict(default=True, type='bool'),
|
||||||
state = dict(default='running', choices=['absent', 'present', 'running', 'stopped', 'killed', 'restarted']),
|
state = dict(default='running', choices=['absent', 'present', 'running', 'stopped', 'killed', 'restarted']),
|
||||||
|
|
Loading…
Reference in a new issue