wisski-cloud-distillery/internal/dis/component/sql/sql.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.2 KiB
Go

package sql
import (
"embed"
"path/filepath"
"time"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/lazy"
)
type SQL struct {
component.Base
ServerURL string // upstream server url
PollInterval time.Duration // duration to wait for during wait
lazyNetwork lazy.Lazy[string]
}
var (
_ component.Backupable = (*SQL)(nil)
_ component.Snapshotable = (*SQL)(nil)
_ component.Installable = (*SQL)(nil)
)
func (sql *SQL) Path() string {
return filepath.Join(sql.Still.Config.DeployRoot, "core", "sql")
}
func (*SQL) Context(parent component.InstallationContext) component.InstallationContext {
return parent
}
//go:embed all:sql
//go:embed sql.env
var resources embed.FS
func (sql *SQL) Stack(env environment.Environment) component.StackWithResources {
return component.MakeStack(sql, env, component.StackWithResources{
Resources: resources,
ContextPath: "sql",
EnvPath: "sql.env",
EnvContext: map[string]string{
"DOCKER_NETWORK_NAME": sql.Config.DockerNetworkName,
"HTTPS_ENABLED": sql.Config.HTTPSEnabledEnv(),
},
MakeDirsPerm: environment.DefaultDirPerm,
MakeDirs: []string{
"data",
"imports",
},
})
}