mirror of https://github.com/docker/compose.git
Make use of Containers.filter() and isService()
Signed-off-by: i-ky <gl.ivanovsky@gmail.com>
This commit is contained in:
parent
7f975fa40b
commit
c74a77e895
|
@ -126,22 +126,13 @@ func updateServices(service *types.ServiceConfig, cnts Containers) {
|
|||
if len(cnts) == 0 {
|
||||
return
|
||||
}
|
||||
serviceName2containerID := make(map[string]string)
|
||||
for _, cnt := range cnts {
|
||||
serviceName := cnt.Labels[api.ServiceLabel]
|
||||
if _, exists := serviceName2containerID[serviceName]; !exists {
|
||||
serviceName2containerID[serviceName] = cnt.ID
|
||||
}
|
||||
}
|
||||
|
||||
if id, found := serviceName2containerID[getDependentServiceFromMode(service.NetworkMode)]; found {
|
||||
service.NetworkMode = types.NetworkModeContainerPrefix + id
|
||||
}
|
||||
if id, found := serviceName2containerID[getDependentServiceFromMode(service.Ipc)]; found {
|
||||
service.Ipc = types.NetworkModeContainerPrefix + id
|
||||
}
|
||||
if id, found := serviceName2containerID[getDependentServiceFromMode(service.Pid)]; found {
|
||||
service.Pid = types.NetworkModeContainerPrefix + id
|
||||
for _, str := range []*string{&service.NetworkMode, &service.Ipc, &service.Pid} {
|
||||
if d := getDependentServiceFromMode(*str); d != "" {
|
||||
if serviceContainers := cnts.filter(isService(d)); len(serviceContainers) > 0 {
|
||||
*str = types.NetworkModeContainerPrefix + serviceContainers[0].ID
|
||||
}
|
||||
}
|
||||
}
|
||||
var links []string
|
||||
for _, serviceLink := range service.Links {
|
||||
|
|
Loading…
Reference in New Issue