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
reviewable/pr18780/r1
Paul Myjavec 11 years ago
parent 8d9da7e89f
commit 267d107fe6

@ -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]

Loading…
Cancel
Save