github.com/xiaobinqt/libcompose@v1.1.0/docker/service/service_factory.go (about)

     1  package service
     2  
     3  import (
     4  	"github.com/xiaobinqt/libcompose/config"
     5  	"github.com/xiaobinqt/libcompose/docker/ctx"
     6  	"github.com/xiaobinqt/libcompose/project"
     7  )
     8  
     9  // Factory is an implementation of project.ServiceFactory.
    10  type Factory struct {
    11  	context *ctx.Context
    12  }
    13  
    14  // NewFactory creates a new service factory for the given context
    15  func NewFactory(context *ctx.Context) *Factory {
    16  	return &Factory{
    17  		context: context,
    18  	}
    19  }
    20  
    21  // Create creates a Service based on the specified project, name and service configuration.
    22  func (s *Factory) Create(project *project.Project, name string, serviceConfig *config.ServiceConfig) (project.Service, error) {
    23  	return NewService(name, serviceConfig, s.context), nil
    24  }