github.com/bscott/buffalo@v0.11.1/generators/docker/docker.go (about) 1 package docker 2 3 import ( 4 "github.com/gobuffalo/buffalo/generators" 5 "github.com/gobuffalo/makr" 6 "github.com/gobuffalo/packr" 7 "github.com/pkg/errors" 8 ) 9 10 // Run Docker generator 11 func (d Generator) Run(root string, data makr.Data) error { 12 g := makr.New() 13 data["opts"] = d 14 g.Add(&makr.Func{ 15 Should: func(data makr.Data) bool { 16 return d.Style != "none" 17 }, 18 Runner: func(root string, data makr.Data) error { 19 var box packr.Box 20 switch d.Style { 21 case "standard": 22 box = packr.NewBox("./standard/templates") 23 case "multi": 24 box = packr.NewBox("./multi/templates") 25 default: 26 return errors.Errorf("unknown Docker style: %s", d.Style) 27 } 28 files, err := generators.FindByBox(box) 29 if err != nil { 30 return errors.WithStack(err) 31 } 32 fg := makr.New() 33 for _, f := range files { 34 fg.Add(makr.NewFile(f.WritePath, f.Body)) 35 } 36 return fg.Run(root, data) 37 }, 38 }) 39 return g.Run(root, data) 40 }