wip
This commit is contained in:
31
config/config.go
Normal file
31
config/config.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"gitlab.com/etke.cc/go/env"
|
||||
)
|
||||
|
||||
const prefix = "postmoogle"
|
||||
|
||||
// New config
|
||||
func New() *Config {
|
||||
env.SetPrefix(prefix)
|
||||
cfg := &Config{
|
||||
Homeserver: env.String("homeserver", defaultConfig.Homeserver),
|
||||
Login: env.String("login", defaultConfig.Login),
|
||||
Password: env.String("password", defaultConfig.Password),
|
||||
Domain: env.String("domain", defaultConfig.Domain),
|
||||
Port: env.String("port", defaultConfig.Port),
|
||||
NoEncryption: env.Bool("noencryption"),
|
||||
Sentry: Sentry{
|
||||
DSN: env.String("sentry.dsn", defaultConfig.Sentry.DSN),
|
||||
SampleRate: env.Int("sentry.rate", defaultConfig.Sentry.SampleRate),
|
||||
},
|
||||
LogLevel: env.String("loglevel", defaultConfig.LogLevel),
|
||||
DB: DB{
|
||||
DSN: env.String("db.dsn", defaultConfig.DB.DSN),
|
||||
Dialect: env.String("db.dialect", defaultConfig.DB.Dialect),
|
||||
},
|
||||
}
|
||||
|
||||
return cfg
|
||||
}
|
||||
15
config/defaults.go
Normal file
15
config/defaults.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package config
|
||||
|
||||
var defaultConfig = &Config{
|
||||
LogLevel: "INFO",
|
||||
Domain: "localhost",
|
||||
Port: "25",
|
||||
Prefix: "!pm",
|
||||
DB: DB{
|
||||
DSN: "/tmp/postmoogle.db",
|
||||
Dialect: "sqlite3",
|
||||
},
|
||||
Sentry: Sentry{
|
||||
SampleRate: 20,
|
||||
},
|
||||
}
|
||||
41
config/types.go
Normal file
41
config/types.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package config
|
||||
|
||||
// Config of Postmoogle
|
||||
type Config struct {
|
||||
// Homeserver url
|
||||
Homeserver string
|
||||
// Login is a MXID localpart (scheduler - OK, @scheduler:example.com - wrong)
|
||||
Login string
|
||||
// Password for login/password auth only
|
||||
Password string
|
||||
// Domain for SMTP
|
||||
Domain string
|
||||
// Port for SMTP
|
||||
Port string
|
||||
// RoomID of the admin room
|
||||
LogLevel string
|
||||
// NoEncryption disabled encryption support
|
||||
NoEncryption bool
|
||||
// Prefix for commands
|
||||
Prefix string
|
||||
|
||||
// DB config
|
||||
DB DB
|
||||
|
||||
// Sentry config
|
||||
Sentry Sentry
|
||||
}
|
||||
|
||||
// DB config
|
||||
type DB struct {
|
||||
// DSN is a database connection string
|
||||
DSN string
|
||||
// Dialect of database, one of sqlite3, postgres
|
||||
Dialect string
|
||||
}
|
||||
|
||||
// Sentry config
|
||||
type Sentry struct {
|
||||
DSN string
|
||||
SampleRate int
|
||||
}
|
||||
Reference in New Issue
Block a user