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:
parent
2a14d93d3c
commit
09431c4869
16 changed files with 265 additions and 148 deletions
34
env/stack_self.go
vendored
34
env/stack_self.go
vendored
|
|
@ -2,23 +2,37 @@ package env
|
|||
|
||||
import "github.com/FAU-CDI/wisski-distillery/internal/stack"
|
||||
|
||||
func (dis *Distillery) SelfStack() stack.Installable {
|
||||
// SelfComponent represents the 'self' layer belonging to a distillery
|
||||
type SelfComponent struct {
|
||||
dis *Distillery
|
||||
}
|
||||
|
||||
// Self returns the SelfComponent belonging to this distillery
|
||||
func (dis *Distillery) Self() SelfComponent {
|
||||
return SelfComponent{dis: dis}
|
||||
}
|
||||
|
||||
func (SelfComponent) Name() string {
|
||||
return "self"
|
||||
}
|
||||
|
||||
func (sc SelfComponent) Stack() stack.Installable {
|
||||
TARGET := "https://github.com/FAU-CDI/wisski-distillery"
|
||||
if dis.Config.SelfRedirect != nil {
|
||||
TARGET = dis.Config.SelfRedirect.String()
|
||||
if sc.dis.Config.SelfRedirect != nil {
|
||||
TARGET = sc.dis.Config.SelfRedirect.String()
|
||||
}
|
||||
|
||||
return dis.asCoreStack("self", stack.Installable{
|
||||
return sc.dis.makeComponentStack(sc, stack.Installable{
|
||||
EnvFileContext: map[string]string{
|
||||
"VIRTUAL_HOST": dis.DefaultVirtualHost(),
|
||||
"LETSENCRYPT_HOST": dis.DefaultLetsencryptHost(),
|
||||
"LETSENCRYPT_EMAIL": dis.Config.CertbotEmail,
|
||||
"VIRTUAL_HOST": sc.dis.DefaultVirtualHost(),
|
||||
"LETSENCRYPT_HOST": sc.dis.DefaultLetsencryptHost(),
|
||||
"LETSENCRYPT_EMAIL": sc.dis.Config.CertbotEmail,
|
||||
"TARGET": TARGET,
|
||||
"OVERRIDES_FILE": dis.Config.SelfOverridesFile,
|
||||
"OVERRIDES_FILE": sc.dis.Config.SelfOverridesFile,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (dis *Distillery) SelfStackPath() string {
|
||||
return dis.SelfStack().Dir
|
||||
func (sc SelfComponent) Path() string {
|
||||
return sc.Stack().Dir
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue