mirror of https://github.com/docker/compose.git
modified com.docker.compose.depends_on label to contain dependency type
Signed-off-by: Mehrad Dadar <mehrad.dadar@gmail.com>
This commit is contained in:
parent
7e7262bc77
commit
67f7b84829
|
@ -114,8 +114,16 @@ func (s *composeService) projectFromName(containers Containers, projectName stri
|
|||
dependencies := c.Labels[api.DependenciesLabel]
|
||||
if len(dependencies) > 0 {
|
||||
service.DependsOn = types.DependsOnConfig{}
|
||||
for _, d := range strings.Split(dependencies, ",") {
|
||||
service.DependsOn[d] = types.ServiceDependency{Condition: ServiceConditionRunningOrHealthy}
|
||||
for _, dc := range strings.Split(dependencies, ",") {
|
||||
dcArr := strings.Split(dc, ":")
|
||||
condition := ServiceConditionRunningOrHealthy
|
||||
dependency := dcArr[0]
|
||||
|
||||
// backward compatibility
|
||||
if len(dcArr) > 1 {
|
||||
condition = dcArr[1]
|
||||
}
|
||||
service.DependsOn[dependency] = types.ServiceDependency{Condition: condition}
|
||||
}
|
||||
}
|
||||
project.Services = append(project.Services, service)
|
||||
|
|
|
@ -433,7 +433,7 @@ func (s *composeService) prepareLabels(service types.ServiceConfig, number int)
|
|||
|
||||
var dependencies []string
|
||||
for s := range service.DependsOn {
|
||||
dependencies = append(dependencies, s)
|
||||
dependencies = append(dependencies, s+":"+service.DependsOn[s].Condition)
|
||||
}
|
||||
labels[api.DependenciesLabel] = strings.Join(dependencies, ",")
|
||||
return labels, nil
|
||||
|
|
Loading…
Reference in New Issue