blob: 6f766b9205abeb9e876087fcf3a9e5d907c52e8a [file] [log] [blame]
giolekva8aa73e82022-07-09 11:34:39 +04001package installer
giolekva050609f2021-12-29 15:51:40 +04002
giolekva8aa73e82022-07-09 11:34:39 +04003import (
4 "embed"
Giorgi Lekveishvilibd6be7f2023-05-26 15:51:28 +04005 "fmt"
giolekva8aa73e82022-07-09 11:34:39 +04006 "log"
7 "text/template"
8)
giolekva050609f2021-12-29 15:51:40 +04009
Giorgi Lekveishvilibd6be7f2023-05-26 15:51:28 +040010//go:embed values-tmpl
11var valuesTmpls embed.FS
12
giolekva050609f2021-12-29 15:51:40 +040013type App struct {
14 Name string
15 Templates []*template.Template
16}
17
Giorgi Lekveishvilibd6be7f2023-05-26 15:51:28 +040018type AppRepository interface {
19 Find(name string) (*App, error)
20}
21
22type InMemoryAppRepository struct {
23 apps []App
24}
25
26func NewInMemoryAppRepository(apps []App) AppRepository {
27 return &InMemoryAppRepository{
28 apps,
29 }
30}
31
32func (r InMemoryAppRepository) Find(name string) (*App, error) {
33 for _, a := range r.apps {
34 if a.Name == name {
35 return &a, nil
36 }
37 }
38 return nil, fmt.Errorf("Application not found: %s", name)
39}
giolekva8aa73e82022-07-09 11:34:39 +040040
41func CreateAllApps() []App {
42 tmpls, err := template.ParseFS(valuesTmpls, "values-tmpl/*.yaml")
43 if err != nil {
44 log.Fatal(err)
45 }
giolekvaef76a3e2022-01-10 12:22:28 +040046 return []App{
Giorgi Lekveishvili23ef7f82023-05-26 11:57:48 +040047 // CreateAppIngressPublic(tmpls),
giolekvaef76a3e2022-01-10 12:22:28 +040048 CreateAppIngressPrivate(tmpls),
49 CreateAppCoreAuth(tmpls),
50 CreateAppVaultwarden(tmpls),
51 CreateAppMatrix(tmpls),
52 CreateAppPihole(tmpls),
53 CreateAppMaddy(tmpls),
54 CreateAppQBittorrent(tmpls),
55 CreateAppJellyfin(tmpls),
Giorgi Lekveishvili23ef7f82023-05-26 11:57:48 +040056 CreateAppRpuppy(tmpls),
57 CreateAppHeadscale(tmpls),
58 }
59}
60
61func CreateAppIngressPublic(tmpls *template.Template) App {
62 return App{
63 "ingress-public",
64 []*template.Template{
65 tmpls.Lookup("ingress-public.yaml"),
66 },
giolekvaef76a3e2022-01-10 12:22:28 +040067 }
68}
69
giolekva050609f2021-12-29 15:51:40 +040070func CreateAppIngressPrivate(tmpls *template.Template) App {
71 return App{
72 "ingress-private",
73 []*template.Template{
Giorgi Lekveishvili23ef7f82023-05-26 11:57:48 +040074 // tmpls.Lookup("vpn-mesh-config.yaml"),
giolekva050609f2021-12-29 15:51:40 +040075 tmpls.Lookup("ingress-private.yaml"),
76 tmpls.Lookup("certificate-issuer.yaml"),
77 },
78 }
79}
80
81func CreateAppCoreAuth(tmpls *template.Template) App {
82 return App{
83 "core-auth",
84 []*template.Template{
85 tmpls.Lookup("core-auth-storage.yaml"),
86 tmpls.Lookup("core-auth.yaml"),
87 },
88 }
89}
90
91func CreateAppVaultwarden(tmpls *template.Template) App {
92 return App{
93 "vaultwarden",
94 []*template.Template{
95 tmpls.Lookup("vaultwarden.yaml"),
96 },
97 }
98}
99
100func CreateAppMatrix(tmpls *template.Template) App {
101 return App{
102 "matrix",
103 []*template.Template{
104 tmpls.Lookup("matrix-storage.yaml"),
105 tmpls.Lookup("matrix.yaml"),
106 },
107 }
108}
109
110func CreateAppPihole(tmpls *template.Template) App {
111 return App{
112 "pihole",
113 []*template.Template{
114 tmpls.Lookup("pihole.yaml"),
115 },
116 }
117}
118
119func CreateAppMaddy(tmpls *template.Template) App {
120 return App{
121 "maddy",
122 []*template.Template{
123 tmpls.Lookup("maddy.yaml"),
124 },
125 }
126}
giolekvaef76a3e2022-01-10 12:22:28 +0400127
128func CreateAppQBittorrent(tmpls *template.Template) App {
129 return App{
130 "qbittorrent",
131 []*template.Template{
132 tmpls.Lookup("qbittorrent.yaml"),
133 },
134 }
135}
136
137func CreateAppJellyfin(tmpls *template.Template) App {
138 return App{
139 "jellyfin",
140 []*template.Template{
141 tmpls.Lookup("jellyfin.yaml"),
142 },
143 }
144}
Giorgi Lekveishvili23ef7f82023-05-26 11:57:48 +0400145
146func CreateAppRpuppy(tmpls *template.Template) App {
147 return App{
148 "rpuppy",
149 []*template.Template{
150 tmpls.Lookup("rpuppy.yaml"),
151 },
152 }
153}
154
155func CreateAppHeadscale(tmpls *template.Template) App {
156 return App{
157 "headscale",
158 []*template.Template{
159 tmpls.Lookup("headscale.yaml"),
160 },
161 }
162}