diff --git a/cmd/bootstrap.go b/cmd/bootstrap.go index ae1e7bb..b62b1b4 100644 --- a/cmd/bootstrap.go +++ b/cmd/bootstrap.go @@ -7,7 +7,7 @@ import ( "path/filepath" wisski_distillery "github.com/FAU-CDI/wisski-distillery" - cfg "github.com/FAU-CDI/wisski-distillery/internal/config" + "github.com/FAU-CDI/wisski-distillery/internal/config" "github.com/FAU-CDI/wisski-distillery/internal/core" "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/FAU-CDI/wisski-distillery/pkg/hostname" @@ -188,11 +188,11 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error { } defer f.Close() - var config cfg.Config - if err := config.Unmarshal(f); err != nil { + var cfg config.Config + if err := cfg.Unmarshal(f); err != nil { return errBootstrapOpenConfig.WithMessageF(err) } - context.Println(config) + context.Println(cfg) // Tell the user how to proceed logging.LogMessage(context.IOStream, "Bootstrap is complete") diff --git a/cmd/config.go b/cmd/config.go index 1189277..28cdf2d 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -6,12 +6,12 @@ import ( ) // Config is the configuration command -var Config wisski_distillery.Command = config{} +var Config wisski_distillery.Command = cfg{} -type config struct { +type cfg struct { } -func (s config) Description() wisski_distillery.Description { +func (s cfg) Description() wisski_distillery.Description { return wisski_distillery.Description{ Requirements: core.Requirements{ NeedsDistillery: true, @@ -21,7 +21,7 @@ func (s config) Description() wisski_distillery.Description { } } -func (s config) Run(context wisski_distillery.Context) error { +func (s cfg) Run(context wisski_distillery.Context) error { context.Printf("%#v", context.Environment.Config) return nil } diff --git a/cmd/system_update.go b/cmd/system_update.go index 2369238..ab1633b 100644 --- a/cmd/system_update.go +++ b/cmd/system_update.go @@ -5,6 +5,7 @@ import ( wisski_distillery "github.com/FAU-CDI/wisski-distillery" "github.com/FAU-CDI/wisski-distillery/internal/component" + "github.com/FAU-CDI/wisski-distillery/internal/config" "github.com/FAU-CDI/wisski-distillery/internal/core" "github.com/FAU-CDI/wisski-distillery/pkg/execx" "github.com/FAU-CDI/wisski-distillery/pkg/logging" @@ -142,7 +143,7 @@ func (si systemupdate) Run(context wisski_distillery.Context) error { } if err := logging.LogOperation(func() error { - return unpack.InstallDir(dis.RuntimeDir(), "runtime", core.Runtime, func(dst, src string) { + return unpack.InstallDir(dis.Config.RuntimeDir(), "runtime", config.Runtime, func(dst, src string) { context.Printf("[copy] %s\n", dst) }) }, context.IOStream, "Unpacking Runtime Components"); err != nil { diff --git a/internal/component/component.go b/internal/component/component.go index ce14ca2..08664df 100644 --- a/internal/component/component.go +++ b/internal/component/component.go @@ -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 diff --git a/internal/config/runtime.go b/internal/config/runtime.go new file mode 100644 index 0000000..af7c17d --- /dev/null +++ b/internal/config/runtime.go @@ -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") +} diff --git a/internal/core/runtime/README b/internal/config/runtime/README similarity index 100% rename from internal/core/runtime/README rename to internal/config/runtime/README diff --git a/internal/core/runtime/blind_update.sh b/internal/config/runtime/blind_update.sh similarity index 100% rename from internal/core/runtime/blind_update.sh rename to internal/config/runtime/blind_update.sh diff --git a/internal/core/runtime/create_admin.sh b/internal/config/runtime/create_admin.sh similarity index 100% rename from internal/core/runtime/create_admin.sh rename to internal/config/runtime/create_admin.sh diff --git a/internal/core/runtime/cron.sh b/internal/config/runtime/cron.sh similarity index 100% rename from internal/core/runtime/cron.sh rename to internal/config/runtime/cron.sh diff --git a/internal/core/runtime/install_colorbox.sh b/internal/config/runtime/install_colorbox.sh similarity index 100% rename from internal/core/runtime/install_colorbox.sh rename to internal/config/runtime/install_colorbox.sh diff --git a/internal/core/runtime/patch_easyrdf.sh b/internal/config/runtime/patch_easyrdf.sh similarity index 100% rename from internal/core/runtime/patch_easyrdf.sh rename to internal/config/runtime/patch_easyrdf.sh diff --git a/internal/core/runtime/patch_triples.sh b/internal/config/runtime/patch_triples.sh similarity index 100% rename from internal/core/runtime/patch_triples.sh rename to internal/config/runtime/patch_triples.sh diff --git a/internal/core/runtime/use_wisski.sh b/internal/config/runtime/use_wisski.sh similarity index 100% rename from internal/core/runtime/use_wisski.sh rename to internal/config/runtime/use_wisski.sh diff --git a/internal/core/runtime/wisski_2x_3x.sh b/internal/config/runtime/wisski_2x_3x.sh similarity index 100% rename from internal/core/runtime/wisski_2x_3x.sh rename to internal/config/runtime/wisski_2x_3x.sh diff --git a/internal/core/runtime.go b/internal/core/runtime.go deleted file mode 100644 index 486b996..0000000 --- a/internal/core/runtime.go +++ /dev/null @@ -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 diff --git a/internal/wisski/component.go b/internal/wisski/component.go index 7b7d3cf..9e14686 100644 --- a/internal/wisski/component.go +++ b/internal/wisski/component.go @@ -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(), diff --git a/internal/wisski/instances.go b/internal/wisski/instances.go index 8461f12..559e559 100644 --- a/internal/wisski/instances.go +++ b/internal/wisski/instances.go @@ -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, }, diff --git a/internal/wisski/runtime.go b/internal/wisski/runtime.go deleted file mode 100644 index 730f2ff..0000000 --- a/internal/wisski/runtime.go +++ /dev/null @@ -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") -}