Lots of internal cleanup
This commit is contained in:
parent
8b7fe41309
commit
8210612198
13 changed files with 939 additions and 78 deletions
7
env/component.go
vendored
7
env/component.go
vendored
|
|
@ -14,15 +14,10 @@ import (
|
|||
"github.com/FAU-CDI/wisski-distillery/component/web"
|
||||
)
|
||||
|
||||
// TODO: Remove me when migration is complete
|
||||
type Component = component.Component
|
||||
|
||||
// TODO: Move everything into specific subpackages
|
||||
|
||||
// Stacks returns the Stacks of this distillery
|
||||
func (dis *Distillery) Components() []component.Component {
|
||||
// TODO: Do we want to cache these components?
|
||||
return []Component{
|
||||
return []component.Component{
|
||||
dis.Web(),
|
||||
dis.Self(),
|
||||
dis.Resolver(),
|
||||
|
|
|
|||
17
env/instances.go
vendored
17
env/instances.go
vendored
|
|
@ -201,15 +201,6 @@ func (instance Instance) Domain() string {
|
|||
return fmt.Sprintf("%s.%s", instance.Slug, instance.dis.Config.DefaultDomain)
|
||||
}
|
||||
|
||||
// IfHttps returns value if the distillery has https enabled, the empty string otherwise
|
||||
// TODO: Fix this into config!
|
||||
func (dis *Distillery) IfHttps(value string) string {
|
||||
if !dis.Config.HTTPSEnabled() {
|
||||
return ""
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
// URL returns the public URL of this instance
|
||||
func (instance Instance) URL() *url.URL {
|
||||
// setup domain and path
|
||||
|
|
@ -248,8 +239,8 @@ func (instance Instance) Stack() component.Installable {
|
|||
"SLUG": instance.Slug,
|
||||
"VIRTUAL_HOST": instance.Domain(),
|
||||
|
||||
"LETSENCRYPT_HOST": instance.dis.IfHttps(instance.Domain()),
|
||||
"LETSENCRYPT_EMAIL": instance.dis.IfHttps(instance.dis.Config.CertbotEmail),
|
||||
"LETSENCRYPT_HOST": instance.dis.Config.IfHttps(instance.Domain()),
|
||||
"LETSENCRYPT_EMAIL": instance.dis.Config.IfHttps(instance.dis.Config.CertbotEmail),
|
||||
|
||||
"RUNTIME_DIR": instance.dis.RuntimeDir(),
|
||||
"GLOBAL_AUTHORIZED_KEYS_FILE": instance.dis.Config.GlobalAuthorizedKeysFile,
|
||||
|
|
@ -280,8 +271,8 @@ func (instance Instance) ReserveStack() component.Installable {
|
|||
EnvContext: map[string]string{
|
||||
"VIRTUAL_HOST": instance.Domain(),
|
||||
|
||||
"LETSENCRYPT_HOST": instance.dis.IfHttps(instance.Domain()),
|
||||
"LETSENCRYPT_EMAIL": instance.dis.IfHttps(instance.dis.Config.CertbotEmail),
|
||||
"LETSENCRYPT_HOST": instance.dis.Config.IfHttps(instance.Domain()),
|
||||
"LETSENCRYPT_EMAIL": instance.dis.Config.IfHttps(instance.dis.Config.CertbotEmail),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
env/instances_provision.go
vendored
12
env/instances_provision.go
vendored
|
|
@ -5,7 +5,6 @@ import (
|
|||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/bookkeeping"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/config"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/password"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
|
@ -29,11 +28,6 @@ func (dis *Distillery) InstanceGraphDB(slug string) (repo, user string) {
|
|||
return
|
||||
}
|
||||
|
||||
// Password returns a new password
|
||||
func (dis *Distillery) NewPassword() (value string, err error) {
|
||||
return password.Password(dis.Config.PasswordLength)
|
||||
}
|
||||
|
||||
var errInvalidSlug = errors.New("Not a valid slug")
|
||||
|
||||
// NewInstance fills the struct for a new distillery instance.
|
||||
|
|
@ -48,21 +42,21 @@ func (dis *Distillery) NewInstance(slug string) (i Instance, err error) {
|
|||
}
|
||||
|
||||
// generate sql data
|
||||
sqlPassword, err := dis.NewPassword()
|
||||
sqlPassword, err := dis.Config.NewPassword()
|
||||
if err != nil {
|
||||
return i, err
|
||||
}
|
||||
sqlDB, sqlUser := dis.InstanceSQL(slug)
|
||||
|
||||
// generate ts data
|
||||
tsPassword, err := dis.NewPassword()
|
||||
tsPassword, err := dis.Config.NewPassword()
|
||||
if err != nil {
|
||||
return i, err
|
||||
}
|
||||
tsRepo, tsUser := dis.InstanceGraphDB(slug)
|
||||
|
||||
// generate drupal data
|
||||
drPassword, err := dis.NewPassword()
|
||||
drPassword, err := dis.Config.NewPassword()
|
||||
if err != nil {
|
||||
return i, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue