env: Move each component into a separate struct

This commit cleans up the distillery code by making each component a
distinct struct. Each of these components is also returned by by a new
Component() function that replaces the Stacks() function.
This commit is contained in:
Tom Wiesing 2022-09-05 15:50:23 +02:00
parent 2a14d93d3c
commit 09431c4869
No known key found for this signature in database
16 changed files with 265 additions and 148 deletions

24
env/stack_web.go vendored
View file

@ -2,14 +2,28 @@ package env
import "github.com/FAU-CDI/wisski-distillery/internal/stack"
func (dis *Distillery) WebStack() stack.Installable {
return dis.asCoreStack("web", stack.Installable{
// WebComponent represents the 'web' layer belonging to a distillery
type WebComponent struct {
dis *Distillery
}
// Web returns the WebComponent belonging to this distillery
func (dis *Distillery) Web() WebComponent {
return WebComponent{dis: dis}
}
func (WebComponent) Name() string {
return "web"
}
func (web WebComponent) Stack() stack.Installable {
return web.dis.makeComponentStack(web, stack.Installable{
EnvFileContext: map[string]string{
"DEFAULT_HOST": dis.Config.DefaultDomain,
"DEFAULT_HOST": web.dis.Config.DefaultDomain,
},
})
}
func (dis *Distillery) WebStackPath() string {
return dis.WebStack().Dir
func (web WebComponent) Path() string {
return web.Stack().Dir
}