diff --git a/database/main.go b/database/main.go index ca3688f..17f22a4 100644 --- a/database/main.go +++ b/database/main.go @@ -9,11 +9,11 @@ import ( // Database struct to read from config type Database struct { - DB *gorm.DB `toml:"-"` - Connection string `toml:"connection"` - Debug bool `toml:"debug"` - Testdata bool `toml:"testdata"` - LogLevel logger.LogLevel `toml:"log_level"` + DB *gorm.DB `config:"-" toml:"-"` + Connection string `config:"connection" toml:"connection"` + Debug bool `config:"debug" toml:"debug"` + Testdata bool `config:"testdata" toml:"testdata"` + LogLevel logger.LogLevel `config:"log_level" toml:"log_level"` migrations map[string]*gormigrate.Migration migrationTestdata map[string]*gormigrate.Migration } diff --git a/file/json_test.go b/file/json_test.go index e515bbe..a9d1a70 100644 --- a/file/json_test.go +++ b/file/json_test.go @@ -12,7 +12,7 @@ func TestReadJSON(t *testing.T) { assert := assert.New(t) a := struct { - Text string `toml:"text"` + Text string `config:"text" toml:"text"` }{} err := ReadJSON("testfiles/donoexists", &a) diff --git a/file/toml_test.go b/file/toml_test.go index 2385903..d561a4c 100644 --- a/file/toml_test.go +++ b/file/toml_test.go @@ -27,7 +27,7 @@ func TestReadTOML(t *testing.T) { assert := assert.New(t) a := struct { - Text string `toml:"text"` + Text string `config:"text" toml:"text"` }{} err := ReadTOML("testfiles/donoexists", &a) @@ -45,7 +45,7 @@ func TestSaveTOML(t *testing.T) { assert := assert.New(t) type to struct { - Value int `toml:"v"` + Value int `config:"v" toml:"v"` } toSave := to{Value: 3} diff --git a/mailer/main.go b/mailer/main.go index 3a5681c..b8fc0bf 100644 --- a/mailer/main.go +++ b/mailer/main.go @@ -6,13 +6,13 @@ import ( // Service to send mail type Service struct { - SMTPHost string `toml:"smtp_host"` - SMTPPort int `toml:"smtp_port"` - SMTPUsername string `toml:"smtp_username"` - SMTPPassword string `toml:"smtp_password"` - SMTPSSL bool `toml:"smtp_ssl"` - Dailer *mail.Dialer `toml:"-"` - From string `toml:"from"` + SMTPHost string `config:"smtp_host" toml:"smtp_host"` + SMTPPort int `config:"smtp_port" toml:"smtp_port"` + SMTPUsername string `config:"smtp_username" toml:"smtp_username"` + SMTPPassword string `config:"smtp_password" toml:"smtp_password"` + SMTPSSL bool `config:"smtp_ssl" toml:"smtp_ssl"` + Dailer *mail.Dialer `config:"-" toml:"-"` + From string `config:"from" toml:"from"` } // Ping mailer diff --git a/web/file/createfs.go b/web/file/createfs.go index 6af0ef1..8909612 100644 --- a/web/file/createfs.go +++ b/web/file/createfs.go @@ -29,16 +29,16 @@ func (t *fsType) UnmarshalText(input []byte) error { // FSInfo is a TOML structure storing access information about a file store. type FSInfo struct { - FSType fsType `toml:"type"` + FSType fsType `config:"type" toml:"type"` // file system - Root string `toml:",omitempty"` + Root string `config:",omitempty" toml:",omitempty"` // s3 - Endpoint string `toml:",omitempty"` - Secure bool `toml:",omitempty"` - ID string `toml:",omitempty"` - Secret string `toml:",omitempty"` - Bucket string `toml:",omitempty"` - Location string `toml:",omitempty"` + Endpoint string `config:",omitempty" toml:",omitempty"` + Secure bool `config:",omitempty" toml:",omitempty"` + ID string `config:",omitempty" toml:",omitempty"` + Secret string `config:",omitempty" toml:",omitempty"` + Bucket string `config:",omitempty" toml:",omitempty"` + Location string `config:",omitempty" toml:",omitempty"` } // Create creates a file store from the information provided. diff --git a/web/main.go b/web/main.go index 13610ca..5b632c8 100644 --- a/web/main.go +++ b/web/main.go @@ -27,23 +27,23 @@ import ( // A Service stores configuration of a server. type Service struct { // config - Listen string `toml:"listen"` - AccessLog bool `toml:"access_log"` - WebrootIndexDisable bool `toml:"webroot_index_disable"` - Webroot string `toml:"webroot"` - WebrootFS http.FileSystem `toml:"-"` + Listen string `config:"listen" toml:"listen"` + AccessLog bool `config:"access_log" toml:"access_log"` + WebrootIndexDisable bool `config:"webroot_index_disable" toml:"webroot_index_disable"` + Webroot string `config:"webroot" toml:"webroot"` + WebrootFS http.FileSystem `config:"-" toml:"-"` ACME struct { - Enable bool `toml:"enable"` - Domains []string `toml:"domains"` - Cache string `toml:"cache"` - } `toml:"acme"` + Enable bool `config:"enable" toml:"enable"` + Domains []string `config:"domains" toml:"domains"` + Cache string `config: "cache" toml:"cache"` + } `config:"acme" toml:"acme"` Session struct { - Name string `toml:"name"` - Secret string `toml:"secret"` - } `toml:"session"` + Name string `config:"name" toml:"name"` + Secret string `config: "secret" toml:"secret"` + } `config:"session" toml:"session"` // internal - DB *gorm.DB `toml:"-"` - Mailer *mailer.Service `toml:"-"` + DB *gorm.DB `config:"-" toml:"-"` + Mailer *mailer.Service `config:"-" toml:"-"` log *zap.Logger modules []ModuleRegisterFunc