mirror of https://github.com/docker/compose.git
Move get_networks() out of Project class
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
87326c00eb
commit
4e61377c6d
|
@ -72,7 +72,7 @@ class Project(object):
|
|||
|
||||
for service_dict in config_data.services:
|
||||
if use_networking:
|
||||
networks = project.get_networks(
|
||||
networks = get_networks(
|
||||
service_dict,
|
||||
custom_networks + [project.default_network])
|
||||
net = Net(networks[0]) if networks else Net("none")
|
||||
|
@ -171,21 +171,6 @@ class Project(object):
|
|||
service.remove_duplicate_containers()
|
||||
return services
|
||||
|
||||
def get_networks(self, service_dict, network_definitions):
|
||||
networks = []
|
||||
for name in service_dict.pop('networks', ['default']):
|
||||
if name in ['bridge', 'host']:
|
||||
networks.append(name)
|
||||
else:
|
||||
matches = [n for n in network_definitions if n.name == name]
|
||||
if matches:
|
||||
networks.append(matches[0].full_name)
|
||||
else:
|
||||
raise ConfigurationError(
|
||||
'Service "{}" uses an undefined network "{}"'
|
||||
.format(service_dict['name'], name))
|
||||
return networks
|
||||
|
||||
def get_links(self, service_dict):
|
||||
links = []
|
||||
if 'links' in service_dict:
|
||||
|
@ -474,6 +459,22 @@ class Project(object):
|
|||
return acc + dep_services
|
||||
|
||||
|
||||
def get_networks(service_dict, network_definitions):
|
||||
networks = []
|
||||
for name in service_dict.pop('networks', ['default']):
|
||||
if name in ['bridge', 'host']:
|
||||
networks.append(name)
|
||||
else:
|
||||
matches = [n for n in network_definitions if n.name == name]
|
||||
if matches:
|
||||
networks.append(matches[0].full_name)
|
||||
else:
|
||||
raise ConfigurationError(
|
||||
'Service "{}" uses an undefined network "{}"'
|
||||
.format(service_dict['name'], name))
|
||||
return networks
|
||||
|
||||
|
||||
def get_volumes_from(project, service_dict):
|
||||
volumes_from = service_dict.pop('volumes_from', None)
|
||||
if not volumes_from:
|
||||
|
|
Loading…
Reference in New Issue