Add 'environment' package
This commit adds a new environment package that manages all calls to the underlying operating system.
This commit is contained in:
parent
822c70cd69
commit
f19619ef9f
60 changed files with 539 additions and 308 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/FAU-CDI/wisski-distillery/internal/component"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/component/instances"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/core"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
|
||||
)
|
||||
|
||||
// Control represents the control server
|
||||
|
|
@ -24,8 +25,8 @@ func (control Control) Name() string {
|
|||
//go:embed all:control control.env
|
||||
var resources embed.FS
|
||||
|
||||
func (control Control) Stack() component.StackWithResources {
|
||||
return control.ComponentBase.MakeStack(component.StackWithResources{
|
||||
func (control Control) Stack(env environment.Environment) component.StackWithResources {
|
||||
return control.ComponentBase.MakeStack(env, component.StackWithResources{
|
||||
Resources: resources,
|
||||
ContextPath: "control",
|
||||
EnvPath: "control.env",
|
||||
|
|
@ -49,6 +50,6 @@ func (control Control) Stack() component.StackWithResources {
|
|||
|
||||
func (control Control) Context(parent component.InstallationContext) component.InstallationContext {
|
||||
return component.InstallationContext{
|
||||
core.Executable: control.Config.CurrentExecutable(),
|
||||
core.Executable: control.Config.CurrentExecutable(control.Environment), // TODO: Does this make sense?
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package control
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
||||
|
|
@ -37,7 +36,7 @@ func (control Control) resolver(io stream.IOStream) (p wdresolve.ResolveHandler,
|
|||
|
||||
// open the prefix file
|
||||
prefixFile := control.ResolverConfigPath()
|
||||
fs, err := os.Open(prefixFile)
|
||||
fs, err := control.Environment.Open(prefixFile)
|
||||
io.Println("loading prefixes from ", prefixFile)
|
||||
if err != nil {
|
||||
return p, err
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
|
|
@ -13,7 +12,7 @@ import (
|
|||
// self returns the handler for the self overrides
|
||||
func (control Control) self(io stream.IOStream) (redirect Redirect, err error) {
|
||||
// open the overrides file
|
||||
overrides, err := os.Open(control.Config.SelfOverridesFile)
|
||||
overrides, err := control.Environment.Open(control.Config.SelfOverridesFile)
|
||||
io.Printf("loading overrides from %q\n", control.Config.SelfOverridesFile)
|
||||
if err != nil {
|
||||
return redirect, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue