service_factory.go 840 B

1234567891011121314151617181920212223242526272829
  1. package docker
  2. import (
  3. composeConfig "github.com/docker/libcompose/config"
  4. "github.com/docker/libcompose/docker"
  5. "github.com/docker/libcompose/project"
  6. "github.com/rancher/os/util"
  7. )
  8. type ServiceFactory struct {
  9. Context *docker.Context
  10. Deps map[string][]string
  11. }
  12. func (s *ServiceFactory) Create(project *project.Project, name string, serviceConfig *composeConfig.ServiceConfig) (project.Service, error) {
  13. if after := serviceConfig.Labels["io.rancher.os.after"]; after != "" {
  14. for _, dep := range util.TrimSplit(after, ",") {
  15. s.Deps[name] = append(s.Deps[name], dep)
  16. }
  17. }
  18. if before := serviceConfig.Labels["io.rancher.os.before"]; before != "" {
  19. for _, dep := range util.TrimSplit(before, ",") {
  20. s.Deps[dep] = append(s.Deps[dep], name)
  21. }
  22. }
  23. return NewService(s, name, serviceConfig, s.Context, project), nil
  24. }