mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -07:00
[docker_network] Add handling for Python booleans in driver_options (#48105)
Fixes #26708
This commit is contained in:
parent
0d9c923464
commit
d7686e1bc0
3 changed files with 75 additions and 2 deletions
|
@ -268,6 +268,21 @@ def get_ip_version(cidr):
|
|||
raise ValueError('"{0}" is not a valid CIDR'.format(cidr))
|
||||
|
||||
|
||||
def get_driver_options(driver_options):
|
||||
result = dict()
|
||||
if driver_options is not None:
|
||||
for k, v in driver_options.items():
|
||||
# Go doesn't like 'True' or 'False'
|
||||
if v is True:
|
||||
v = 'true'
|
||||
elif v is False:
|
||||
v = 'false'
|
||||
else:
|
||||
v = str(v)
|
||||
result[str(k)] = v
|
||||
return result
|
||||
|
||||
|
||||
class DockerNetworkManager(object):
|
||||
|
||||
def __init__(self, client):
|
||||
|
@ -288,6 +303,9 @@ class DockerNetworkManager(object):
|
|||
if self.parameters.ipam_options:
|
||||
self.parameters.ipam_config = [self.parameters.ipam_options]
|
||||
|
||||
if self.parameters.driver_options:
|
||||
self.parameters.driver_options = get_driver_options(self.parameters.driver_options)
|
||||
|
||||
state = self.parameters.state
|
||||
if state == 'present':
|
||||
self.present()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue