From 017eb3dcfa86d43212d4ffa0fef86415801e65ac Mon Sep 17 00:00:00 2001 From: Erhan Yakut Date: Sun, 19 Jul 2020 01:03:54 +0300 Subject: [PATCH] added email configuration --- internal/config/config.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/internal/config/config.go b/internal/config/config.go index 0c1b89f..ec77b96 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -23,6 +23,7 @@ var ( type Configuration struct { Server ServerConfiguration Database DatabaseConfiguration + Email EmailConfiguration } // ServerConfiguration is the required paramters to set up a server @@ -43,6 +44,15 @@ type DatabaseConfiguration struct { LogMode bool `default:"false"` } +// EmailConfiguration is the required paramters to send emails +type EmailConfiguration struct { + Host string `default:"smtp.passwall.io"` + Port string `default:"25"` + Username string `default:"hello@passwall.io"` + Password string `default:"password"` + From string `default:"hello@passwall.io"` +} + // SetupConfigDefaults ... func SetupConfigDefaults() (*Configuration, error) { @@ -114,6 +124,12 @@ func bindEnvs() { viper.BindEnv("database.port", "PW_DB_PORT") viper.BindEnv("database.logmode", "PW_DB_LOG_MODE") + viper.BindEnv("email.host", "PW_EMAIL_HOST") + viper.BindEnv("email.port", "PW_EMAIL_PORT") + viper.BindEnv("email.username", "PW_EMAIL_USERNAME") + viper.BindEnv("email.password", "PW_EMAIL_PASSWORD") + viper.BindEnv("email.from", "PW_EMAIL_FROM") + viper.BindEnv("backup.folder", "PW_BACKUP_FOLDER") viper.BindEnv("backup.rotation", "PW_BACKUP_ROTATION") viper.BindEnv("backup.period", "PW_BACKUP_PERIOD") @@ -138,6 +154,13 @@ func setDefaults() { viper.SetDefault("database.port", "5432") viper.SetDefault("database.logmode", false) + // Email defaults + viper.SetDefault("email.host", "smtp.passwall.io") + viper.SetDefault("email.port", "25") + viper.SetDefault("email.username", "hello@passwall.io") + viper.SetDefault("email.password", "password") + viper.SetDefault("email.from", "hello@passwall.io") + // Backup defaults viper.SetDefault("backup.folder", "./store/") viper.SetDefault("backup.rotation", 7)