Add PostgreSQL support (#23)
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
b6f23d4bd5
commit
47c8a8ace9
10 changed files with 216 additions and 9 deletions
12
config.go
12
config.go
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
// Config to store JSON configuration
|
||||
type Config struct {
|
||||
DatabaseConfig `json:"database"`
|
||||
TwitterConfig `json:"twitter"`
|
||||
TelegramConfig `json:"telegram"`
|
||||
APIConfig `json:"api"`
|
||||
|
|
@ -18,6 +19,12 @@ type Config struct {
|
|||
BrowserAddress string `json:"browser_address"`
|
||||
}
|
||||
|
||||
// DatabaseConfig to store database configuration
|
||||
type DatabaseConfig struct {
|
||||
Type string `json:"type"`
|
||||
DSN string `json:"dsn"`
|
||||
}
|
||||
|
||||
// TwitterConfig to store Twitter API secrets
|
||||
type TwitterConfig struct {
|
||||
ConsumerKey string `json:"consumer_key"`
|
||||
|
|
@ -96,6 +103,11 @@ func (c *Config) HasURLs() bool {
|
|||
return len(c.URLs) > 0
|
||||
}
|
||||
|
||||
// HasDatabase returns true when database has been configured
|
||||
func (c *Config) HasDatabase() bool {
|
||||
return c.DatabaseConfig.Type != "" && c.DatabaseConfig.DSN != ""
|
||||
}
|
||||
|
||||
// HasAmazon returns true when Amazon has been configured
|
||||
func (c *Config) HasAmazon() bool {
|
||||
var hasKeys, hasSearches, hasMarketplaces bool
|
||||
|
|
|
|||
Reference in a new issue