1
0
mirror of https://github.com/rancher/os.git synced 2025-06-24 14:01:34 +00:00
os/docker/service_factory.go

35 lines
968 B
Go
Raw Normal View History

2015-08-04 21:45:38 +00:00
package docker
import (
2016-05-24 00:21:28 +00:00
composeConfig "github.com/docker/libcompose/config"
2015-08-04 21:45:38 +00:00
"github.com/docker/libcompose/docker"
"github.com/docker/libcompose/project"
"github.com/rancher/os/util"
2015-08-04 21:45:38 +00:00
)
type ServiceFactory struct {
Context *docker.Context
Deps map[string][]string
}
2016-05-24 00:21:28 +00:00
func (s *ServiceFactory) Create(project *project.Project, name string, serviceConfig *composeConfig.ServiceConfig) (project.Service, error) {
if after := serviceConfig.Labels["io.rancher.os.after"]; after != "" {
2015-08-04 21:45:38 +00:00
for _, dep := range util.TrimSplit(after, ",") {
if dep == "cloud-init" {
dep = "cloud-init-execute"
}
2015-08-04 21:45:38 +00:00
s.Deps[name] = append(s.Deps[name], dep)
}
}
2016-05-24 00:21:28 +00:00
if before := serviceConfig.Labels["io.rancher.os.before"]; before != "" {
2015-08-04 21:45:38 +00:00
for _, dep := range util.TrimSplit(before, ",") {
if dep == "cloud-init" {
dep = "cloud-init-execute"
}
2015-08-04 21:45:38 +00:00
s.Deps[dep] = append(s.Deps[dep], name)
}
}
return NewService(s, name, serviceConfig, s.Context, project), nil
2015-08-04 21:45:38 +00:00
}