| gio | f884341 | 2024-05-22 16:38:05 +0400 | [diff] [blame] | 1 | package installer |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | |
| 6 | helmv2 "github.com/fluxcd/helm-controller/api/v2" |
| 7 | ) |
| 8 | |
| 9 | type LocalChartGenerator interface { |
| 10 | Generate(path string) helmv2.HelmChartTemplateSpec |
| 11 | } |
| 12 | |
| 13 | type GitRepositoryLocalChartGenerator struct { |
| 14 | Name string |
| 15 | Namespace string |
| 16 | } |
| 17 | |
| 18 | func (g GitRepositoryLocalChartGenerator) Generate(path string) helmv2.HelmChartTemplateSpec { |
| 19 | p, _ := strings.CutPrefix(path, "/") |
| 20 | return helmv2.HelmChartTemplateSpec{ |
| 21 | Chart: p, |
| 22 | SourceRef: helmv2.CrossNamespaceObjectReference{ |
| 23 | Kind: "GitRepository", |
| 24 | Name: g.Name, |
| 25 | Namespace: g.Namespace, |
| 26 | }, |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | type InfraLocalChartGenerator struct { |
| 31 | GitRepositoryLocalChartGenerator |
| 32 | } |
| 33 | |
| 34 | func NewInfraLocalChartGenerator() InfraLocalChartGenerator { |
| 35 | return InfraLocalChartGenerator{GitRepositoryLocalChartGenerator{"dodo-flux", "dodo-flux"}} |
| 36 | } |