mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
[docker_network] Add handling for Python booleans in driver_options (#48105)
Fixes #26708
This commit is contained in:
committed by
John R Barker
parent
0d9c923464
commit
d7686e1bc0
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user