Commit 074a6f3e by Paul Myjavec

Docker links and required alias

If no alias is passed one will now be created for you with the same name
as the target link container, as per the documentation
parent 8e3b5122
......@@ -380,7 +380,7 @@ class DockerManager:
self.links = None
if self.module.params.get('links'):
self.links = dict(map(lambda x: x.split(':'), self.module.params.get('links')))
self.links = self.get_links(self.module.params.get('links'))
self.env = None
if self.module.params.get('env'):
......@@ -391,6 +391,22 @@ class DockerManager:
self.client = docker.Client(base_url=docker_url.geturl())
def get_links(self, links):
"""
Parse the links passed, if a link is specified without an alias then just create the alias of the same name as the link
"""
processed_links = {}
for link in links:
parsed_link = link.split(':', 1)
if(len(parsed_link) == 2):
processed_links[parsed_link[0]] = parsed_link[1]
else:
processed_links[parsed_link[0]] = parsed_link[0]
return processed_links
def get_exposed_ports(self, expose_list):
"""
Parse the ports and protocols (TCP/UDP) to expose in the docker-py `create_container` call from the docker CLI-style syntax.
......@@ -452,7 +468,6 @@ class DockerManager:
return binds
def get_split_image_tag(self, image):
if '/' in image:
image = image.split('/')[1]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment