wisski-cloud-distillery/internal/wisski/ingredient/barrel/stack.go
Tom Wiesing 8235ea9105
Require access to Still via method
This commit adds a safeguard to accessing the still from a specific
component by requiring access via the component.GetStill method.
2024-04-08 22:39:32 +02:00

58 lines
1.6 KiB
Go

package barrel
import (
"embed"
"path/filepath"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
)
//go:embed all:barrel
var barrelResources embed.FS
const localSettingsName = "settings.local.php"
//go:embed local.settings.php
var localSettingsTemplate string
// Barrel returns a stack representing the running WissKI Instance
func (barrel *Barrel) Stack() component.StackWithResources {
liquid := ingredient.GetLiquid(barrel)
config := ingredient.GetStill(barrel).Config
return component.StackWithResources{
Stack: component.Stack{
Dir: liquid.FilesystemBase,
},
Resources: barrelResources,
ContextPath: filepath.Join("barrel"),
CreateFiles: map[string]string{
localSettingsName: localSettingsTemplate,
},
EnvContext: map[string]string{
"DOCKER_NETWORK_NAME": config.Docker.Network(),
"SLUG": liquid.Slug,
"HOST_RULE": liquid.HostRule(),
"WISSKI_HOSTNAME": liquid.Hostname(),
"HTTPS_ENABLED": config.HTTP.HTTPSEnabledEnv(),
"DATA_PATH": filepath.Join(liquid.FilesystemBase, "data"),
"RUNTIME_DIR": config.Paths.RuntimeDir(),
"LOCAL_SETTINGS_PATH": filepath.Join(liquid.FilesystemBase, localSettingsName),
"LOCAL_SETTINGS_MOUNT": LocalSettingsPath,
"BARREL_BASE_IMAGE": liquid.GetDockerBaseImage(),
"IIP_SERVER_ENABLED": liquid.GetIIPServerEnabled(),
"OPCACHE_MODE": liquid.OpCacheMode(),
"CONTENT_SECURITY_POLICY": liquid.ContentSecurityPolicy,
},
MakeDirs: []string{"data", ".composer"},
}
}