func (p *Project) CreateService(name string) (Service, error) {
	existing, ok := p.ServiceConfigs.Get(name)
	if !ok {
		return nil, fmt.Errorf("Failed to find service: %s", name)
	}
	config := *existing
	if p.context.EnvironmentLookup != nil {
		parsedEnv := make([]string, 0, len(config.Environment))
		for _, env := range config.Environment {
			parts := strings.SplitN(env, "=", 2)
			if len(parts) > 1 && parts[1] != "" {
				parsedEnv = append(parsedEnv, env)
				continue
			} else {
				env = parts[0]
			}
			for _, value := range p.context.EnvironmentLookup.Lookup(env, name, &config) {
				parsedEnv = append(parsedEnv, value)
			}
		}
		config.Environment = parsedEnv
	}
	return p.context.ServiceFactory.Create(p, name, &config)
}
CreateService creates a service with the specified name based. If there
is no config in the project for this service, it will return an error.
package project
import (
	"errors"
	"fmt"
	"strings"
	"golang.org/x/net/context"
	log "github.com/Sirupsen/logrus"
	"github.com/docker/engine-api/types"
	"github.com/docker/engine-api/types/filters"
	"github.com/docker/libcompose/config"
	"github.com/docker/libcompose/labels"
	"github.com/docker/libcompose/logger"
	"github.com/docker/libcompose/project/events"
	"github.com/docker/libcompose/project/options"
	"github.com/docker/libcompose/utils"
)
type wrapperAction func(*serviceWrapper, map[string]*serviceWrapper)
type serviceAction func(service Service) error
type Project struct {
	Name           string
	ServiceConfigs *config.ServiceConfigs
	VolumeConfigs  map[string]*config.VolumeConfig
	NetworkConfigs map[string]*config.NetworkConfig
	Files          []string
	ReloadCallback func() error
	ParseOptions   *config.ParseOptions
	context       *Context
	clientFactory ClientFactory
	reload        []string
	upCount       int
	listeners     []chan<- events.Event
	hasListeners  bool
}
func NewProject(clientFactory ClientFactory, context *Context, parseOptions *config.ParseOptions) *Project {
	p := &Project{
		context:        context,
		clientFactory:  clientFactory,
		ParseOptions:   parseOptions,
		ServiceConfigs: config.NewServiceConfigs(),
		VolumeConfigs:  make(map[string]*config.VolumeConfig),
		NetworkConfigs: make(map[string]*config.NetworkConfig),
	}
	if context.LoggerFactory == nil {
		context.LoggerFactory = &logger.NullLogger{}
	}
	context.Project = p
	p.listeners = []chan<- events.Event{NewDefaultListener(p)}
	return p
}
func (p *Project) Parse() error {
	err := p.context.open()
	if err != nil {
		return err
	}
	p.Name = p.context.ProjectName
	p.Files = p.context.ComposeFiles
	if len(p.Files) == 1 && p.Files[0] == "-" {
		p.Files = []string{"."}
	}
	if p.context.ComposeBytes != nil {
		for i, composeBytes := range p.context.ComposeBytes {
			file := ""
			if i < len(p.context.ComposeFiles) {
				file = p.Files[i]
			}
			if err := p.load(file, composeBytes); err != nil {
				return err
			}
		}
	}
	return nil
}