Skip to content

Commit

Permalink
added email configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
yakuter committed Jul 18, 2020
1 parent c37dea2 commit 017eb3d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (
type Configuration struct {
Server ServerConfiguration
Database DatabaseConfiguration
Email EmailConfiguration
}

// ServerConfiguration is the required paramters to set up a server
Expand All @@ -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:"[email protected]"`
Password string `default:"password"`
From string `default:"[email protected]"`
}

// SetupConfigDefaults ...
func SetupConfigDefaults() (*Configuration, error) {

Expand Down Expand Up @@ -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")
Expand All @@ -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", "[email protected]")
viper.SetDefault("email.password", "password")
viper.SetDefault("email.from", "[email protected]")

// Backup defaults
viper.SetDefault("backup.folder", "./store/")
viper.SetDefault("backup.rotation", 7)
Expand Down

0 comments on commit 017eb3d

Please sign in to comment.