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:
Mehrad Dadar 2022-02-23 21:34:34 +03:30
parent 7e7262bc77
commit 67f7b84829
2 changed files with 11 additions and 3 deletions

View File

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

View File

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