This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
helm.go
59 lines (47 loc) · 1.44 KB
/
helm.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package helm
import (
"os"
"path/filepath"
"github.com/caos/orbos/internal/operator/boom/name"
"github.com/caos/orbos/internal/operator/boom/templator"
"github.com/caos/orbos/mntr"
"github.com/pkg/errors"
)
const (
templatorName name.Templator = "helm"
)
func GetName() name.Templator {
return templatorName
}
func GetPrio() name.Templator {
return templatorName
}
type Helm struct {
overlay string
monitor mntr.Monitor
templatorDirectoryPath string
}
func New(monitor mntr.Monitor, overlay, templatorDirectoryPath string) templator.Templator {
return &Helm{
monitor: monitor,
templatorDirectoryPath: templatorDirectoryPath,
overlay: overlay,
}
}
func (h *Helm) CleanUp() error {
return os.RemoveAll(h.templatorDirectoryPath)
}
func (h *Helm) getResultsFileDirectory(appName name.Application, overlay, basePath string) string {
return filepath.Join(basePath, appName.String(), overlay, "results")
}
func (h *Helm) GetResultsFilePath(appName name.Application, overlay, basePath string) string {
return filepath.Join(h.getResultsFileDirectory(appName, overlay, basePath), "results.yaml")
}
func checkTemplatorInterface(templatorInterface interface{}) (templator.HelmApplication, error) {
app, isTemplator := templatorInterface.(templator.HelmApplication)
if !isTemplator {
err := errors.Errorf("Helm templating interface not implemented")
return nil, err
}
return app, nil
}