forked from hashicorp/otto
/
default.go
47 lines (39 loc) · 893 Bytes
/
default.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
package appfile
import (
"path/filepath"
"github.com/hashicorp/otto/appfile/detect"
)
// Default will generate a default Appfile for the given directory.
//
// The path to the directory must be absolute, since the path is used
// as a way to determine the name of the application.
func Default(dir string, det *detect.Config) (*File, error) {
appName := filepath.Base(dir)
appType, err := detect.App(dir, det)
if err != nil {
return nil, err
}
return &File{
Path: filepath.Join(dir, "Appfile"),
Application: &Application{
Name: appName,
Type: appType,
},
Project: &Project{
Name: appName,
Infrastructure: appName,
},
Infrastructure: []*Infrastructure{
&Infrastructure{
Name: appName,
Type: "aws",
Flavor: "simple",
Foundations: []*Foundation{
&Foundation{
Name: "consul",
},
},
},
},
}, nil
}