Move code into new component package
This commit cleans up the resources in the 'embed' package, and instead moves them into subpackages of a new 'compose' package. This makes sure that '.env' templates and docker compose contexts are located in the same location.
This commit is contained in:
parent
2ee90bf462
commit
7b2f79bea1
44 changed files with 579 additions and 559 deletions
25
internal/config/derived.go
Normal file
25
internal/config/derived.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package config
|
||||
|
||||
import "strings"
|
||||
|
||||
// This file contains derived configuration values
|
||||
|
||||
func (cfg Config) HTTPSEnabled() bool {
|
||||
return cfg.CertbotEmail != ""
|
||||
}
|
||||
|
||||
// Returns the default virtual host
|
||||
func (cfg Config) DefaultVirtualHost() string {
|
||||
VIRTUAL_HOST := cfg.DefaultDomain
|
||||
if len(cfg.SelfExtraDomains) > 0 {
|
||||
VIRTUAL_HOST += "," + strings.Join(cfg.SelfExtraDomains, ",")
|
||||
}
|
||||
return VIRTUAL_HOST
|
||||
}
|
||||
|
||||
func (cfg Config) DefaultLetsencryptHost() string {
|
||||
if !cfg.HTTPSEnabled() {
|
||||
return ""
|
||||
}
|
||||
return cfg.DefaultVirtualHost()
|
||||
}
|
||||
|
|
@ -5,13 +5,14 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/embed"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/fsx"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/unpack"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
)
|
||||
|
||||
// TODO: Move this package into components
|
||||
|
||||
// Installable represents a Stack that can be automatically installed from a set of resources
|
||||
// See the [Install] method.
|
||||
type Installable struct {
|
||||
|
|
@ -42,15 +43,18 @@ type InstallationContext map[string]string
|
|||
// Installation is non-interactive, but will provide debugging output onto io.
|
||||
// InstallationContext
|
||||
func (is Installable) Install(io stream.IOStream, context InstallationContext) error {
|
||||
// setup the base files
|
||||
if err := embed.InstallResource(
|
||||
is.Dir,
|
||||
is.ContextPath,
|
||||
func(dst, src string) {
|
||||
io.Printf("[install] %s\n", dst)
|
||||
},
|
||||
); err != nil {
|
||||
return err
|
||||
if is.ContextPath != "" {
|
||||
// setup the base files
|
||||
if err := unpack.InstallResource(
|
||||
is.Dir,
|
||||
is.ContextPath,
|
||||
is.Resources,
|
||||
func(dst, src string) {
|
||||
io.Printf("[install] %s\n", dst)
|
||||
},
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// configure .env
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue