This commit is contained in:
parent
8e6f814ba4
commit
e317da1b66
6 changed files with 106 additions and 18 deletions
|
@ -3,6 +3,7 @@ package config
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"git.mstar.dev/mstar/goutils/other"
|
||||
|
@ -73,6 +74,13 @@ type ConfigStorage struct {
|
|||
MaxReconnectAttempts int `toml:"max_reconnect_attempts"`
|
||||
}
|
||||
|
||||
type ConfigTranscoder struct {
|
||||
SharedDirectory string `toml:"shared_directory"`
|
||||
Secret string `toml:"secret"`
|
||||
ServerAddress string `toml:"server_address"`
|
||||
ServerPort int `toml:"server_port"`
|
||||
}
|
||||
|
||||
type ConfigS3 struct {
|
||||
KeyId string `toml:"key_id"`
|
||||
Secret string `toml:"secret"`
|
||||
|
@ -143,6 +151,7 @@ type Config struct {
|
|||
Admin ConfigAdmin `toml:"admin"`
|
||||
Webauthn ConfigWebAuthn `toml:"webauthn"`
|
||||
Storage ConfigStorage `toml:"storage"`
|
||||
Transcoder ConfigTranscoder `toml:"transcoder"`
|
||||
Mail ConfigMail `toml:"mail"`
|
||||
Self ConfigSelf `toml:"self"`
|
||||
S3 ConfigS3 `toml:"s3"`
|
||||
|
@ -185,13 +194,15 @@ var defaultConfig Config = Config{
|
|||
Port: 5432,
|
||||
SslMode: other.IntoPointer("disable"),
|
||||
TimeZone: other.IntoPointer("Europe/Berlin"),
|
||||
RedisUrl: nil,
|
||||
MaxInMemoryCacheSize: 1e6, // 1 Megabyte
|
||||
MaxInMemoryCacheTTL: 5,
|
||||
MaxRedisCacheTTL: nil,
|
||||
EncryptionKey: "Encryption key for sensitive information. DO NOT CHANGE THIS AFTER SETUP",
|
||||
MaxReconnectAttempts: 3,
|
||||
},
|
||||
Transcoder: ConfigTranscoder{
|
||||
SharedDirectory: "/tmp/linstrom-transcoder",
|
||||
Secret: "The same secret as configured in the transcoder",
|
||||
ServerAddress: "127.0.0.1",
|
||||
ServerPort: 5594,
|
||||
},
|
||||
Mail: ConfigMail{
|
||||
Host: "localhost",
|
||||
Port: 587,
|
||||
|
@ -275,6 +286,18 @@ func (sc *ConfigStorage) BuildPostgresDSN() string {
|
|||
return dsn
|
||||
}
|
||||
|
||||
func (tc *ConfigTranscoder) Address() string {
|
||||
return fmt.Sprintf("%s:%d", tc.ServerAddress, tc.ServerPort)
|
||||
}
|
||||
|
||||
func (tc *ConfigTranscoder) InDir() string {
|
||||
return path.Join(tc.SharedDirectory, "input")
|
||||
}
|
||||
|
||||
func (tc *ConfigTranscoder) OutDir() string {
|
||||
return path.Join(tc.SharedDirectory, "output")
|
||||
}
|
||||
|
||||
func WriteDefaultConfig(toFile string) error {
|
||||
log.Trace().Caller().Send()
|
||||
log.Info().Str("config-file", toFile).Msg("Writing default config to file")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue