github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/boom/templator/yaml/yaml.go (about) 1 package yaml 2 3 import ( 4 "errors" 5 "path/filepath" 6 7 "github.com/caos/orbos/internal/operator/boom/name" 8 "github.com/caos/orbos/internal/operator/boom/templator" 9 "github.com/caos/orbos/mntr" 10 ) 11 12 const ( 13 templatorName name.Templator = "yaml" 14 ) 15 16 func GetName() name.Templator { 17 return templatorName 18 } 19 20 type YAML struct { 21 monitor mntr.Monitor 22 overlay string 23 templatorDirectoryPath string 24 } 25 26 func New(monitor mntr.Monitor, overlay, templatorDirectoryPath string) *YAML { 27 return &YAML{ 28 monitor: monitor, 29 overlay: overlay, 30 templatorDirectoryPath: templatorDirectoryPath, 31 } 32 } 33 34 func (y *YAML) getResultsFileDirectory(appName name.Application, overlay, basePath string) string { 35 return filepath.Join(basePath, appName.String(), overlay, "results") 36 } 37 38 func (y *YAML) GetResultsFilePath(appName name.Application, overlay, basePath string) string { 39 return filepath.Join(y.getResultsFileDirectory(appName, overlay, basePath), "results.yaml") 40 } 41 42 func (y *YAML) CleanUp() error { 43 return nil 44 } 45 46 func checkTemplatorInterface(templatorInterface interface{}) (templator.YamlApplication, error) { 47 app, isTemplator := templatorInterface.(templator.YamlApplication) 48 if !isTemplator { 49 return nil, errors.New("YAML templating interface not implemented") 50 } 51 52 return app, nil 53 }