Merge internal/stack => component

This commit is contained in:
Tom Wiesing 2022-09-11 16:03:13 +02:00
parent 7b2f79bea1
commit 91a088a56a
No known key found for this signature in database
16 changed files with 40 additions and 72 deletions

26
env/component.go vendored
View file

@ -12,8 +12,6 @@ import (
"github.com/FAU-CDI/wisski-distillery/component/ssh"
"github.com/FAU-CDI/wisski-distillery/component/triplestore"
"github.com/FAU-CDI/wisski-distillery/component/web"
"github.com/FAU-CDI/wisski-distillery/embed"
"github.com/FAU-CDI/wisski-distillery/internal/stack"
)
// TODO: Remove me when migration is complete
@ -92,28 +90,6 @@ func (dis *Distillery) Triplestore() (ts triplestore.Triplestore) {
// makeComponent updates the baseComponent belonging to component
func (dis *Distillery) makeComponent(component component.Component, base *component.ComponentBase) {
base.Dir = dis.getComponentPath(component)
base.Config = dis.Config
}
// asCoreStack treats the provided stack as a core component of this distillery.
// TODO: this should no longer be used
func (dis *Distillery) makeComponentStack(component Component, stack stack.Installable) stack.Installable {
stack.Dir = dis.getComponentPath(component)
name := component.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
}
func (dis *Distillery) getComponentPath(component Component) string {
return filepath.Join(dis.Config.DeployRoot, "core", component.Name())
base.Dir = filepath.Join(dis.Config.DeployRoot, "core", component.Name())
}

2
env/distillery.go vendored
View file

@ -12,7 +12,7 @@ import (
// Distillery represents a running instance for the distillery
type Distillery struct {
Config *config.Config
Upstream Upstream
Upstream Upstream // TODO: not sure this belongs here
}
// Upstream are the upstream urls connecting to the various external components.

16
env/instances.go vendored
View file

@ -11,10 +11,10 @@ import (
"path/filepath"
"strings"
"github.com/FAU-CDI/wisski-distillery/component"
"github.com/FAU-CDI/wisski-distillery/embed"
"github.com/FAU-CDI/wisski-distillery/internal/bookkeeping"
"github.com/FAU-CDI/wisski-distillery/internal/fsx"
"github.com/FAU-CDI/wisski-distillery/internal/stack"
"github.com/alessio/shellescape"
"github.com/pkg/errors"
"github.com/tkw1536/goprogram/exit"
@ -229,9 +229,9 @@ func (instance Instance) URL() *url.URL {
}
// Stack represents a stack representing this instance
func (instance Instance) Stack() stack.Installable {
return stack.Installable{
Stack: stack.Stack{
func (instance Instance) Stack() component.Installable {
return component.Installable{
Stack: component.Stack{
Dir: instance.FilesystemBase,
},
Resources: embed.ResourceEmbed, // TODO: Move this over
@ -260,9 +260,9 @@ func (instance Instance) Stack() stack.Installable {
}
}
func (instance Instance) ReserveStack() stack.Installable {
return stack.Installable{
Stack: stack.Stack{
func (instance Instance) ReserveStack() component.Installable {
return component.Installable{
Stack: component.Stack{
Dir: instance.FilesystemBase,
},
ContextPath: filepath.Join("resources", "compose", "reserve"),
@ -282,7 +282,7 @@ func (instance Instance) Provision(io stream.IOStream) error {
// create the basic st!
st := instance.Stack()
if err := st.Install(io, stack.InstallationContext{}); err != nil {
if err := st.Install(io, component.InstallationContext{}); err != nil {
return err
}