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.
This commit is contained in:
Tom Wiesing 2024-04-08 22:39:32 +02:00
parent 81fa84c244
commit 8235ea9105
No known key found for this signature in database
63 changed files with 288 additions and 197 deletions

View file

@ -18,7 +18,7 @@ var (
)
func (binder *Binder) Path() string {
return filepath.Join(binder.Still.Config.Paths.Root, "core", "binder")
return filepath.Join(component.GetStill(binder).Config.Paths.Root, "core", "binder")
}
func (binder *Binder) Context(parent component.InstallationContext) component.InstallationContext {
@ -29,17 +29,20 @@ func (binder *Binder) Context(parent component.InstallationContext) component.In
var composeTemplate embed.FS
func (binder *Binder) Stack() component.StackWithResources {
config := component.GetStill(binder).Config
return component.MakeStack(binder, component.StackWithResources{
ContextPath: ".",
Resources: composeTemplate,
ComposerYML: func(root *yaml.Node) (*yaml.Node, error) {
ports := binder.Config.Listen.ComposePorts("8000")
ports := config.Listen.ComposePorts("8000")
if err := yamlx.ReplaceWith(root, ports, "services", "binder", "ports"); err != nil {
return nil, err
}
command := binder.Config.HTTP.TCPMuxCommand("0.0.0.0:8000", "http:80", "http:443", "ssh:2222")
command := config.HTTP.TCPMuxCommand("0.0.0.0:8000", "http:80", "http:443", "ssh:2222")
if err := yamlx.ReplaceWith(root, command, "services", "binder", "command"); err != nil {
return nil, err
}
@ -48,7 +51,7 @@ func (binder *Binder) Stack() component.StackWithResources {
},
EnvContext: map[string]string{
"DOCKER_NETWORK_NAME": binder.Config.Docker.Network(),
"DOCKER_NETWORK_NAME": config.Docker.Network(),
},
})
}