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
46
env/stack_resolver.go
vendored
46
env/stack_resolver.go
vendored
|
|
@ -7,29 +7,47 @@ import (
|
|||
"github.com/FAU-CDI/wisski-distillery/internal/stack"
|
||||
)
|
||||
|
||||
const ResolverPrefixFile = "prefix.cfg"
|
||||
// ResolverComponent represents the 'resolver' layer belonging to a distillery
|
||||
type ResolverComponent struct {
|
||||
ConfigName string // Filename of the configuration file
|
||||
|
||||
func (dis *Distillery) ResolverStack() stack.Installable {
|
||||
stack := dis.asCoreStack("resolver", stack.Installable{
|
||||
dis *Distillery
|
||||
}
|
||||
|
||||
// Resolver returns the ResolverComponent belonging to this distillery
|
||||
func (dis *Distillery) Resolver() ResolverComponent {
|
||||
return ResolverComponent{
|
||||
ConfigName: "prefix.cfg",
|
||||
|
||||
dis: dis,
|
||||
}
|
||||
}
|
||||
|
||||
func (ResolverComponent) Name() string {
|
||||
return "resolver"
|
||||
}
|
||||
|
||||
func (resolver ResolverComponent) Stack() stack.Installable {
|
||||
stack := resolver.dis.makeComponentStack(resolver, stack.Installable{
|
||||
EnvFileContext: map[string]string{
|
||||
"VIRTUAL_HOST": dis.DefaultVirtualHost(),
|
||||
"LETSENCRYPT_HOST": dis.DefaultLetsencryptHost(),
|
||||
"LETSENCRYPT_EMAIL": dis.Config.CertbotEmail,
|
||||
"VIRTUAL_HOST": resolver.dis.DefaultVirtualHost(),
|
||||
"LETSENCRYPT_HOST": resolver.dis.DefaultLetsencryptHost(),
|
||||
"LETSENCRYPT_EMAIL": resolver.dis.Config.CertbotEmail,
|
||||
"PREFIX_FILE": "", // set below!
|
||||
"DEFAULT_DOMAIN": dis.Config.DefaultDomain,
|
||||
"LEGACY_DOMAIN": strings.Join(dis.Config.SelfExtraDomains, ","),
|
||||
"DEFAULT_DOMAIN": resolver.dis.Config.DefaultDomain,
|
||||
"LEGACY_DOMAIN": strings.Join(resolver.dis.Config.SelfExtraDomains, ","),
|
||||
},
|
||||
|
||||
TouchFiles: []string{ResolverPrefixFile},
|
||||
TouchFiles: []string{resolver.ConfigName},
|
||||
})
|
||||
stack.EnvFileContext["PREFIX_FILE"] = filepath.Join(stack.Dir, ResolverPrefixFile)
|
||||
stack.EnvFileContext["PREFIX_FILE"] = filepath.Join(stack.Dir, resolver.ConfigName)
|
||||
return stack
|
||||
}
|
||||
|
||||
func (dis *Distillery) ResolverStackPath() string {
|
||||
return dis.ResolverStack().Dir
|
||||
func (resolver ResolverComponent) Path() string {
|
||||
return resolver.Stack().Dir
|
||||
}
|
||||
|
||||
func (dis Distillery) ResolverPrefixConfig() string {
|
||||
return filepath.Join(dis.ResolverStackPath(), ResolverPrefixFile)
|
||||
func (resolver ResolverComponent) ConfigPath() string {
|
||||
return filepath.Join(resolver.Path(), resolver.ConfigName)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue