maddy/default.go
fox.cpp 6e17ecab31 Change default file locations (#35)
* Change default files location as described in #27

* config: Change default config file name
2019-04-08 19:57:21 +03:00

49 lines
1 KiB
Go

package maddy
import (
"database/sql"
"fmt"
"path/filepath"
"github.com/emersion/maddy/config"
"github.com/emersion/maddy/module"
)
var defaultDriver = "sqlite3"
var defaultDsn string
func createDefaultStorage(globals *config.Map, _ string) (module.Module, error) {
driverSupported := false
for _, driver := range sql.Drivers() {
if driver == defaultDriver {
driverSupported = true
}
}
if !driverSupported {
return nil, fmt.Errorf("maddy is not compiled with %s support", defaultDriver)
}
return NewSQLStorage("sql", "default")
}
func defaultStorageConfig(globals *config.Map, name string) config.Node {
return config.Node{
Name: "sql",
Args: []string{name},
Children: []config.Node{
{
Name: "driver",
Args: []string{defaultDriver},
},
{
Name: "dsn",
Args: []string{filepath.Join(StateDirectory(globals.Values), "maddy.db")},
},
},
}
}
func createDefaultRemoteDelivery(_ *config.Map, name string) (module.Module, error) {
return Dummy{instName: name}, nil
}