forked from docker/libcompose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.go
51 lines (40 loc) · 1.02 KB
/
project.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package docker
import (
"github.com/Sirupsen/logrus"
"github.com/docker/libcompose/lookup"
"github.com/docker/libcompose/project"
)
// NewProject creates a Project with the specified context.
func NewProject(context *Context) (*project.Project, error) {
if context.ResourceLookup == nil {
context.ResourceLookup = &lookup.FileConfigLookup{}
}
if context.EnvironmentLookup == nil {
context.EnvironmentLookup = &lookup.OsEnvLookup{}
}
if context.ServiceFactory == nil {
context.ServiceFactory = &ServiceFactory{
context: context,
}
}
if context.Builder == nil {
context.Builder = NewDaemonBuilder(context)
}
if context.ClientFactory == nil {
factory, err := NewDefaultClientFactory(ClientOpts{})
if err != nil {
return nil, err
}
context.ClientFactory = factory
}
p := project.NewProject(&context.Context)
err := p.Parse()
if err != nil {
return nil, err
}
if err = context.open(); err != nil {
logrus.Errorf("Failed to open project %s: %v", p.Name, err)
return nil, err
}
return p, err
}