-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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:"[email protected]"` | ||
Password string `default:"password"` | ||
From string `default:"[email protected]"` | ||
} | ||
|
||
// 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", "[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) | ||
|