wisski-cloud-distillery/internal/dis/component/control/control.go
Tom Wiesing 890022ae64
internal: Annotate all components with groups
This commit ensures that the compiler has to check every component
against the groups they implement by explicitly annotating the
appropriate interfaces.
2022-11-30 11:08:46 +01:00

58 lines
1.6 KiB
Go

package control
import (
"embed"
"path/filepath"
"github.com/FAU-CDI/wisski-distillery/internal/bootstrap"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
)
// Control represents the running control server.
type Control struct {
component.Base
Servables []component.Servable
}
var (
_ component.Installable = (*Control)(nil)
)
func (control Control) Path() string {
return filepath.Join(control.Still.Config.DeployRoot, "core", "dis")
}
//go:embed all:control control.env
var resources embed.FS
func (control *Control) Stack(env environment.Environment) component.StackWithResources {
stt := component.MakeStack(control, env, component.StackWithResources{
Resources: resources,
ContextPath: "control",
EnvPath: "control.env",
EnvContext: map[string]string{
"DOCKER_NETWORK_NAME": control.Config.DockerNetworkName,
"HOST_RULE": control.Config.DefaultHostRule(),
"HTTPS_ENABLED": control.Config.HTTPSEnabledEnv(),
"CONFIG_PATH": control.Config.ConfigPath,
"DEPLOY_ROOT": control.Config.DeployRoot,
"GLOBAL_AUTHORIZED_KEYS_FILE": control.Config.GlobalAuthorizedKeysFile,
"SELF_OVERRIDES_FILE": control.Config.SelfOverridesFile,
"SELF_RESOLVER_BLOCK_FILE": control.Config.SelfResolverBlockFile,
},
CopyContextFiles: []string{bootstrap.Executable},
})
return stt
}
func (control Control) Context(parent component.InstallationContext) component.InstallationContext {
return component.InstallationContext{
bootstrap.Executable: control.Config.CurrentExecutable(control.Environment), // TODO: Does this make sense?
}
}