Move runtime around

This commit is contained in:
Tom Wiesing 2022-09-14 14:42:21 +02:00
parent ef1243ea39
commit feacd4eeae
No known key found for this signature in database
18 changed files with 39 additions and 35 deletions

View file

@ -26,11 +26,6 @@ type Component interface {
// By convention it is /var/www/deploy/internal/core/${Name()}
Path() string
// Stack can be used to gain access to the "docker compose" stack.
//
// This should internally call
Stack() Installable
// Context returns a new InstallationContext to be used during installation from the command line.
// Typically this should just pass through the parent, but might perform other tasks.
Context(parent InstallationContext) InstallationContext
@ -40,6 +35,16 @@ type Component interface {
Base() *ComponentBase
}
// ComponentWithStack implements a component with a Stack method.
type ComponentWithStack interface {
Component
// Stack can be used to gain access to the "docker compose" stack.
//
// This should internally call
Stack() Installable
}
// ComponentBase implements base functionality for a component
type ComponentBase struct {
Dir string // Dir is the directory this component lives in

View file

@ -0,0 +1,15 @@
package config
import (
"embed"
"path/filepath"
)
// Runtime contains runtime resources to be installed into any instance
//go:embed all:runtime
var Runtime embed.FS
// RuntimeDir returns the path to the runtime directory
func (cfg Config) RuntimeDir() string {
return filepath.Join(cfg.DeployRoot, "runtime")
}

View file

@ -1,9 +0,0 @@
package core
import (
"embed"
)
// Runtime contains runtime resources to be installed into any instance
//go:embed all:runtime
var Runtime embed.FS

View file

@ -72,9 +72,9 @@ func makeComponent[C component.Component](dis *Distillery, field *C, init func(C
return *field
}
// Components returns all components of the distillery
func (dis *Distillery) Components() []component.Component {
return []component.Component{
// Components returns all components that have a stack function
func (dis *Distillery) Components() []component.ComponentWithStack {
return []component.ComponentWithStack{
dis.Web(),
dis.Self(),
dis.Resolver(),

View file

@ -242,7 +242,7 @@ func (instance Instance) Stack() component.Installable {
"LETSENCRYPT_HOST": instance.dis.Config.IfHttps(instance.Domain()),
"LETSENCRYPT_EMAIL": instance.dis.Config.IfHttps(instance.dis.Config.CertbotEmail),
"RUNTIME_DIR": instance.dis.RuntimeDir(),
"RUNTIME_DIR": instance.dis.Config.RuntimeDir(),
"GLOBAL_AUTHORIZED_KEYS_FILE": instance.dis.Config.GlobalAuthorizedKeysFile,
},

View file

@ -1,8 +0,0 @@
package wisski
import "path/filepath"
// RuntimeDir returns the path to the runtime directory
func (dis *Distillery) RuntimeDir() string {
return filepath.Join(dis.Config.DeployRoot, "runtime")
}