mirror of https://github.com/docker/compose.git
create: pull all services logic out of loop; add DependsOn deps
Signed-off-by: Nick Sieger <nick@nicksieger.com>
This commit is contained in:
parent
10532201a2
commit
3c561e7017
|
@ -146,6 +146,9 @@ func prepareNetworks(project *types.Project) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareServicesDependsOn(p *types.Project) error {
|
func prepareServicesDependsOn(p *types.Project) error {
|
||||||
|
allServices := types.Project{}
|
||||||
|
allServices.Services = p.AllServices()
|
||||||
|
|
||||||
for i, service := range p.Services {
|
for i, service := range p.Services {
|
||||||
var dependencies []string
|
var dependencies []string
|
||||||
networkDependency := getDependentServiceFromMode(service.NetworkMode)
|
networkDependency := getDependentServiceFromMode(service.NetworkMode)
|
||||||
|
@ -178,20 +181,24 @@ func prepareServicesDependsOn(p *types.Project) error {
|
||||||
dependencies = append(dependencies, strings.Split(link, ":")[0])
|
dependencies = append(dependencies, strings.Split(link, ":")[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for d := range service.DependsOn {
|
||||||
|
dependencies = append(dependencies, d)
|
||||||
|
}
|
||||||
|
|
||||||
if len(dependencies) == 0 {
|
if len(dependencies) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify dependencies exist in the project, whether disabled or not
|
||||||
|
deps, err := allServices.GetServices(dependencies...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if service.DependsOn == nil {
|
if service.DependsOn == nil {
|
||||||
service.DependsOn = make(types.DependsOnConfig)
|
service.DependsOn = make(types.DependsOnConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify dependencies exist in the project, whether disabled or not
|
|
||||||
projAllServices := types.Project{}
|
|
||||||
projAllServices.Services = p.AllServices()
|
|
||||||
deps, err := projAllServices.GetServices(dependencies...)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
for _, d := range deps {
|
for _, d := range deps {
|
||||||
if _, ok := service.DependsOn[d.Name]; !ok {
|
if _, ok := service.DependsOn[d.Name]; !ok {
|
||||||
service.DependsOn[d.Name] = types.ServiceDependency{
|
service.DependsOn[d.Name] = types.ServiceDependency{
|
||||||
|
|
Loading…
Reference in New Issue