forked from gobuffalo/buffalo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.go
36 lines (33 loc) · 851 Bytes
/
docker.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
package docker
import (
"path/filepath"
"github.com/gobuffalo/buffalo/generators"
"github.com/gobuffalo/makr"
"github.com/pkg/errors"
)
// Run Docker generator
func (d Generator) Run(root string, data makr.Data) error {
g := makr.New()
data["opts"] = d
g.Add(&makr.Func{
Should: func(data makr.Data) bool {
return d.Style != "none"
},
Runner: func(root string, data makr.Data) error {
style := d.Style
if style != "multi" && style != "standard" {
return errors.Errorf("unknown Docker style: %s", style)
}
files, err := generators.Find(filepath.Join(generators.TemplatesPath, "docker", style))
if err != nil {
return errors.WithStack(err)
}
fg := makr.New()
for _, f := range files {
fg.Add(makr.NewFile(f.WritePath, f.Body))
}
return fg.Run(root, data)
},
})
return g.Run(root, data)
}