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