github.com/Microsoft/fabrikate@v0.0.0-20190420002442-bff75be28d02/generators/static.go (about) 1 package generators 2 3 import ( 4 "fmt" 5 "io/ioutil" 6 "path" 7 8 "github.com/Microsoft/fabrikate/core" 9 "github.com/kyokomi/emoji" 10 log "github.com/sirupsen/logrus" 11 ) 12 13 type StaticGenerator struct{} 14 15 func (sg *StaticGenerator) Generate(component *core.Component) (manifest string, err error) { 16 log.Println(emoji.Sprintf(":truck: generating component '%s' statically from path %s", component.Name, component.Path)) 17 18 staticPath := path.Join(component.PhysicalPath, component.Path) 19 staticFiles, err := ioutil.ReadDir(staticPath) 20 21 manifests := "" 22 for _, staticFile := range staticFiles { 23 staticFilePath := path.Join(staticPath, staticFile.Name()) 24 25 staticFileManifest, err := ioutil.ReadFile(staticFilePath) 26 if err != nil { 27 return "", err 28 } 29 30 manifests += fmt.Sprintf("---\n%s\n", staticFileManifest) 31 } 32 33 return manifests, err 34 } 35 36 func (hg *StaticGenerator) Install(component *core.Component) (err error) { 37 return nil 38 }