2021-03-09 08:05:07 +00:00
|
|
|
package config
|
|
|
|
|
2021-03-21 20:38:37 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/jackc/pgx/v4"
|
2021-05-06 09:12:18 +00:00
|
|
|
"github.com/rs/zerolog"
|
2021-03-21 20:38:37 +00:00
|
|
|
)
|
2021-03-09 08:05:07 +00:00
|
|
|
|
|
|
|
type Environment string
|
|
|
|
|
|
|
|
const (
|
|
|
|
Live Environment = "live"
|
|
|
|
Beta = "beta"
|
|
|
|
Dev = "dev"
|
|
|
|
)
|
|
|
|
|
|
|
|
type HMNConfig struct {
|
2021-06-22 09:50:40 +00:00
|
|
|
Env Environment
|
|
|
|
Addr string
|
2021-06-24 13:10:44 +00:00
|
|
|
PrivateAddr string
|
2021-06-22 09:50:40 +00:00
|
|
|
BaseUrl string
|
|
|
|
LogLevel zerolog.Level
|
|
|
|
Postgres PostgresConfig
|
|
|
|
Auth AuthConfig
|
2021-08-08 20:05:52 +00:00
|
|
|
Email EmailConfig
|
2021-06-22 09:50:40 +00:00
|
|
|
DigitalOcean DigitalOceanConfig
|
2021-08-06 23:23:51 +00:00
|
|
|
Discord DiscordConfig
|
2021-08-28 10:40:13 +00:00
|
|
|
EpisodeGuide EpisodeGuide
|
2021-03-09 08:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type PostgresConfig struct {
|
|
|
|
User string
|
|
|
|
Password string
|
|
|
|
Hostname string
|
|
|
|
Port int
|
|
|
|
DbName string
|
2021-03-21 20:38:37 +00:00
|
|
|
LogLevel pgx.LogLevel
|
2021-04-06 06:10:15 +00:00
|
|
|
MinConn int32
|
|
|
|
MaxConn int32
|
2021-03-09 08:05:07 +00:00
|
|
|
}
|
|
|
|
|
2021-03-27 21:10:11 +00:00
|
|
|
type AuthConfig struct {
|
|
|
|
CookieDomain string
|
|
|
|
CookieSecure bool
|
|
|
|
}
|
|
|
|
|
2021-06-22 09:50:40 +00:00
|
|
|
type DigitalOceanConfig struct {
|
|
|
|
AssetsSpacesKey string
|
|
|
|
AssetsSpacesSecret string
|
|
|
|
AssetsSpacesRegion string
|
|
|
|
AssetsSpacesEndpoint string
|
|
|
|
AssetsSpacesBucket string
|
|
|
|
AssetsPathPrefix string
|
|
|
|
AssetsPublicUrlRoot string
|
|
|
|
}
|
|
|
|
|
2021-08-08 20:05:52 +00:00
|
|
|
type EmailConfig struct {
|
|
|
|
ServerAddress string
|
|
|
|
ServerPort int
|
|
|
|
FromAddress string
|
|
|
|
FromAddressPassword string
|
|
|
|
FromName string
|
|
|
|
OverrideRecipientEmail string
|
|
|
|
}
|
|
|
|
|
2021-08-06 23:23:51 +00:00
|
|
|
type DiscordConfig struct {
|
|
|
|
BotToken string
|
|
|
|
BotUserID string
|
|
|
|
|
2021-08-16 04:40:56 +00:00
|
|
|
OAuthClientID string
|
|
|
|
OAuthClientSecret string
|
|
|
|
|
|
|
|
GuildID string
|
|
|
|
MemberRoleID string
|
2021-08-06 23:23:51 +00:00
|
|
|
ShowcaseChannelID string
|
|
|
|
LibraryChannelID string
|
|
|
|
}
|
|
|
|
|
2021-08-28 10:40:13 +00:00
|
|
|
type EpisodeGuide struct {
|
|
|
|
CineraOutputPath string
|
|
|
|
Projects map[string]string // NOTE(asaf): Maps from slugs to default episode guide topic
|
|
|
|
}
|
|
|
|
|
2021-09-06 00:00:25 +00:00
|
|
|
func init() {
|
|
|
|
if Config.EpisodeGuide.Projects == nil {
|
|
|
|
Config.EpisodeGuide.Projects = make(map[string]string)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-09 08:05:07 +00:00
|
|
|
func (info PostgresConfig) DSN() string {
|
|
|
|
return fmt.Sprintf("user=%s password=%s host=%s port=%d dbname=%s", info.User, info.Password, info.Hostname, info.Port, info.DbName)
|
|
|
|
}
|