embed: Begin refactor to use clearer paths
This commit is contained in:
parent
e75dc29de1
commit
e1ee569629
16 changed files with 431 additions and 181 deletions
11
env/component.go
vendored
11
env/component.go
vendored
|
|
@ -3,6 +3,7 @@ package env
|
|||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/embed"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/stack"
|
||||
)
|
||||
|
||||
|
|
@ -37,8 +38,14 @@ func (dis *Distillery) makeComponentStack(component Component, stack stack.Insta
|
|||
stack.Dir = dis.getComponentPath(component)
|
||||
|
||||
name := component.Name()
|
||||
stack.ContextResource = filepath.Join("resources", "compose", name)
|
||||
stack.EnvFileResource = filepath.Join("resources", "templates", "docker-env", name)
|
||||
|
||||
// TODO: This writes out resources.
|
||||
// Should migrate this directly!
|
||||
if stack.Resources == nil {
|
||||
stack.Resources = embed.ResourceEmbed
|
||||
stack.ContextPath = filepath.Join("resources", "compose", name)
|
||||
stack.EnvPath = filepath.Join("resources", "templates", "docker-env", name)
|
||||
}
|
||||
|
||||
return stack
|
||||
}
|
||||
|
|
|
|||
2
env/component_dis.go
vendored
2
env/component_dis.go
vendored
|
|
@ -21,7 +21,7 @@ func (DisComponent) Name() string {
|
|||
|
||||
func (dis DisComponent) Stack() stack.Installable {
|
||||
return dis.dis.makeComponentStack(dis, stack.Installable{
|
||||
EnvFileContext: map[string]string{
|
||||
EnvContext: map[string]string{
|
||||
"VIRTUAL_HOST": dis.dis.DefaultVirtualHost(),
|
||||
"LETSENCRYPT_HOST": dis.dis.DefaultLetsencryptHost(),
|
||||
"LETSENCRYPT_EMAIL": dis.dis.Config.CertbotEmail,
|
||||
|
|
|
|||
3
env/component_resolver.go
vendored
3
env/component_resolver.go
vendored
|
|
@ -35,7 +35,7 @@ func (ResolverComponent) Name() string {
|
|||
|
||||
func (resolver ResolverComponent) Stack() stack.Installable {
|
||||
return resolver.dis.makeComponentStack(resolver, stack.Installable{
|
||||
EnvFileContext: map[string]string{
|
||||
EnvContext: map[string]string{
|
||||
"VIRTUAL_HOST": resolver.dis.DefaultVirtualHost(),
|
||||
"LETSENCRYPT_HOST": resolver.dis.DefaultLetsencryptHost(),
|
||||
"LETSENCRYPT_EMAIL": resolver.dis.Config.CertbotEmail,
|
||||
|
|
@ -47,6 +47,7 @@ func (resolver ResolverComponent) Stack() stack.Installable {
|
|||
"SELF_OVERRIDES_FILE": resolver.dis.Config.SelfOverridesFile,
|
||||
"RESOLVER_CONFIG": resolver.ConfigPath(),
|
||||
},
|
||||
TouchFiles: []string{resolver.ConfigName},
|
||||
CopyContextFiles: []string{core.Executable},
|
||||
})
|
||||
}
|
||||
|
|
|
|||
2
env/component_self.go
vendored
2
env/component_self.go
vendored
|
|
@ -27,7 +27,7 @@ func (sc SelfComponent) Stack() stack.Installable {
|
|||
}
|
||||
|
||||
return sc.dis.makeComponentStack(sc, stack.Installable{
|
||||
EnvFileContext: map[string]string{
|
||||
EnvContext: map[string]string{
|
||||
"VIRTUAL_HOST": sc.dis.DefaultVirtualHost(),
|
||||
"LETSENCRYPT_HOST": sc.dis.DefaultLetsencryptHost(),
|
||||
"LETSENCRYPT_EMAIL": sc.dis.Config.CertbotEmail,
|
||||
|
|
|
|||
14
env/component_triplestore.go
vendored
14
env/component_triplestore.go
vendored
|
|
@ -13,8 +13,10 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/embed"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/fsx"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/logging"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/stack"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/unpack"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wait"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tkw1536/goprogram/exit"
|
||||
|
|
@ -154,10 +156,14 @@ func (ts TriplestoreComponent) Provision(name, domain, user, password string) er
|
|||
}
|
||||
|
||||
// prepare the create repo request
|
||||
createRepo, err := embed.ReadTemplate(filepath.Join("resources", "templates", "repository", "graphdb-repo.ttl"), map[string]string{
|
||||
"GRAPHDB_REPO": name,
|
||||
"INSTANCE_DOMAIN": domain,
|
||||
})
|
||||
// TODO: Move this into a seperate file
|
||||
createRepo, _, err := unpack.UnpackTemplate(
|
||||
map[string]string{
|
||||
"GRAPHDB_REPO": name,
|
||||
"INSTANCE_DOMAIN": domain,
|
||||
},
|
||||
fsx.OpenFS(filepath.Join("resources", "templates", "repository", "graphdb-repo.ttl"), embed.ResourceEmbed),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
2
env/component_web.go
vendored
2
env/component_web.go
vendored
|
|
@ -18,7 +18,7 @@ func (WebComponent) Name() string {
|
|||
|
||||
func (web WebComponent) Stack() stack.Installable {
|
||||
return web.dis.makeComponentStack(web, stack.Installable{
|
||||
EnvFileContext: map[string]string{
|
||||
EnvContext: map[string]string{
|
||||
"DEFAULT_HOST": web.dis.Config.DefaultDomain,
|
||||
},
|
||||
})
|
||||
|
|
|
|||
12
env/instances.go
vendored
12
env/instances.go
vendored
|
|
@ -233,10 +233,10 @@ func (instance Instance) Stack() stack.Installable {
|
|||
Stack: stack.Stack{
|
||||
Dir: instance.FilesystemBase,
|
||||
},
|
||||
ContextResource: filepath.Join("resources", "compose", "barrel"),
|
||||
ContextPath: filepath.Join("resources", "compose", "barrel"),
|
||||
|
||||
EnvFileResource: filepath.Join("resources", "templates", "docker-env", "barrel"),
|
||||
EnvFileContext: map[string]string{
|
||||
EnvPath: filepath.Join("resources", "templates", "docker-env", "barrel"),
|
||||
EnvContext: map[string]string{
|
||||
"DATA_PATH": filepath.Join(instance.FilesystemBase, "data"),
|
||||
|
||||
"SLUG": instance.Slug,
|
||||
|
|
@ -263,10 +263,10 @@ func (instance Instance) ReserveStack() stack.Installable {
|
|||
Stack: stack.Stack{
|
||||
Dir: instance.FilesystemBase,
|
||||
},
|
||||
ContextResource: filepath.Join("resources", "compose", "reserve"),
|
||||
ContextPath: filepath.Join("resources", "compose", "reserve"),
|
||||
|
||||
EnvFileResource: filepath.Join("resources", "templates", "docker-env", "reserve"),
|
||||
EnvFileContext: map[string]string{
|
||||
EnvPath: filepath.Join("resources", "templates", "docker-env", "reserve"),
|
||||
EnvContext: map[string]string{
|
||||
"VIRTUAL_HOST": instance.Domain(),
|
||||
|
||||
"LETSENCRYPT_HOST": instance.dis.IfHttps(instance.Domain()),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue