2024-06-06 01:40:56 -04:00
|
|
|
package main
|
|
|
|
|
2024-06-06 17:01:16 -04:00
|
|
|
//TODO move flag declarations here
|
|
|
|
|
2024-06-06 01:40:56 -04:00
|
|
|
const (
|
|
|
|
ViperAPIPort string = "api.port"
|
|
|
|
FlagAPIPort string = "api-port"
|
|
|
|
DefaultAPIPort int = 1312
|
|
|
|
DescriptionAPIPort string = "API server port"
|
|
|
|
|
|
|
|
ViperAPIKey string = "api.key"
|
|
|
|
FlagAPIKey string = "api-key"
|
|
|
|
DefaultAPIKey string = "bottin"
|
|
|
|
DescriptionAPIKey string = "API server key. Leave empty for no key auth (not recommended)"
|
|
|
|
|
|
|
|
ViperDBDatabase string = "db.database"
|
|
|
|
FlagDBDatabase string = "db-database"
|
|
|
|
DefaultDBDatabase string = "bottin"
|
|
|
|
DescriptionDBDatabase string = "Postgres database"
|
|
|
|
|
2024-06-06 17:01:16 -04:00
|
|
|
ViperDBSSLMode string = "db.sslmode"
|
|
|
|
FlagDBSSLMode string = "db-sslmode"
|
|
|
|
DefaultDBSSLMode string = "prefer"
|
|
|
|
DescriptionDBSSLMode string = "Postgres sslmode"
|
|
|
|
|
2024-06-06 01:40:56 -04:00
|
|
|
ViperDBHost string = "db.host"
|
|
|
|
FlagDBHost string = "db-host"
|
|
|
|
DefaultDBHost string = "db"
|
|
|
|
DescriptionDBHost string = "Postgres host"
|
|
|
|
|
|
|
|
ViperDBPassword string = "db.password"
|
|
|
|
FlagDBPassword string = "db-password"
|
|
|
|
DefaultDBPassword string = "bottin"
|
|
|
|
DescriptionDBPassword string = "Postgres password"
|
|
|
|
|
|
|
|
ViperDBPort string = "db.port"
|
|
|
|
FlagDBPort string = "db-port"
|
|
|
|
DefaultDBPort int = 5432
|
|
|
|
DescriptionDBPort string = "Postgres port"
|
|
|
|
|
|
|
|
ViperDBUser string = "db.user"
|
|
|
|
FlagDBUser string = "db-user"
|
|
|
|
DefaultDBUser string = "bottin"
|
|
|
|
DescriptionDBUser string = "Postgres user"
|
|
|
|
|
2024-06-06 17:01:16 -04:00
|
|
|
ViperWebUser string = "web.user"
|
|
|
|
FlagWebUser string = "web-user"
|
|
|
|
DefaultWebUser string = "bottin"
|
|
|
|
DescriptionWebUser string = "Web client basic auth user"
|
|
|
|
|
|
|
|
ViperWebPassword string = "web.password"
|
|
|
|
FlagWebPassword string = "web-password"
|
|
|
|
DefaultWebPassword string = "bottin"
|
|
|
|
DescriptionWebPassword string = "Web client basic auth password"
|
|
|
|
|
|
|
|
ViperWebPort string = "web.port"
|
|
|
|
FlagWebPort string = "web-port"
|
|
|
|
DefaultWebPort int = 2312
|
|
|
|
DescriptionWebPort string = "Web client port"
|
|
|
|
|
|
|
|
ViperWebAPIHost string = "api.host"
|
|
|
|
FlagWebAPIHost string = "api-host"
|
|
|
|
DefaultWebAPIHost string = "api"
|
|
|
|
DescriptionWebAPIHost string = "Target API server host"
|
|
|
|
|
|
|
|
ViperWebAPIKey string = "api.key"
|
|
|
|
FlagWebAPIKey string = "api-key"
|
|
|
|
DefaultWebAPIKey string = "bottin"
|
|
|
|
DescriptionWebAPIKey string = "Target API server key"
|
|
|
|
|
|
|
|
ViperWebAPIPort string = "api.port"
|
|
|
|
FlagWebAPIPort string = "api-port"
|
|
|
|
DefaultWebAPIPort int = 1312
|
|
|
|
DescriptionWebAPIPort string = "Target API server port"
|
|
|
|
|
|
|
|
ViperWebAPIProtocol string = "api.protocol"
|
|
|
|
FlagWebAPIProtocol string = "api-protocol"
|
|
|
|
DefaultWebAPIProtocol string = "http"
|
|
|
|
DescriptionWebAPIProtocol string = "Target API server protocol (http/https)"
|
2024-06-06 01:40:56 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
API struct {
|
|
|
|
Port int `yaml:"port"`
|
|
|
|
Key string `yaml:"key"`
|
|
|
|
} `yaml:"api"`
|
|
|
|
DB struct {
|
|
|
|
Database string `yaml:"database"`
|
|
|
|
Host string `yaml:"host"`
|
|
|
|
SSLMode string `yaml:"sslmode"`
|
|
|
|
Password string `yaml:"password"`
|
|
|
|
Port int `yaml:"port"`
|
|
|
|
User string `yaml:"user"`
|
|
|
|
} `yaml:"db"`
|
|
|
|
Web struct {
|
|
|
|
User string `yaml:"user"`
|
|
|
|
Password string `yaml:"password"`
|
|
|
|
Port int `yaml:"port"`
|
|
|
|
API struct {
|
|
|
|
Host string `yaml:"host"`
|
|
|
|
Key string `yaml:"key"`
|
|
|
|
Port int `yaml:"port"`
|
|
|
|
Protocol string `yaml:"protocol"`
|
|
|
|
} `yaml:"api"`
|
|
|
|
} `yaml:"web"`
|
|
|
|
}
|
2024-06-06 17:01:16 -04:00
|
|
|
|
|
|
|
// DefaultConfig returns a Config filled with the default values from the
|
|
|
|
// `Default*` constants defined in this file.
|
|
|
|
func DefaultConfig() (cfg Config) {
|
|
|
|
cfg.API.Port = DefaultAPIPort
|
|
|
|
cfg.API.Key = DefaultAPIKey
|
|
|
|
cfg.DB.Database = DefaultDBDatabase
|
|
|
|
cfg.DB.Host = DefaultDBHost
|
|
|
|
cfg.DB.SSLMode = DefaultDBSSLMode
|
|
|
|
cfg.DB.Password = DefaultDBPassword
|
|
|
|
cfg.DB.Port = DefaultDBPort
|
|
|
|
cfg.DB.User = DefaultDBUser
|
|
|
|
cfg.Web.User = DefaultWebUser
|
|
|
|
cfg.Web.Password = DefaultWebPassword
|
|
|
|
cfg.Web.Port = DefaultWebPort
|
|
|
|
cfg.Web.API.Host = DefaultWebAPIHost
|
|
|
|
cfg.Web.API.Key = DefaultWebAPIKey
|
|
|
|
cfg.Web.API.Port = DefaultWebAPIPort
|
|
|
|
cfg.Web.API.Protocol = DefaultWebAPIProtocol
|
|
|
|
return
|
|
|
|
}
|