config

package
v0.0.159 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigPath                  = "config.yaml"
	DefaultHTTPIPV4Host                = "0.0.0.0"
	DefaultHTTPIPV6Host                = "::"
	DefaultHTTPPort                    = 8080
	DefaultHTTPMetricsIPV4Host         = "127.0.0.1"
	DefaultHTTPMetricsIPV6Host         = "::1"
	DefaultHTTPMetricsPort             = 8081
	DefaultPersistenceDatabaseDriver   = DatabaseDriverSQLite
	DefaultPersistenceDatabaseDatabase = "rtz.db"
	DefaultPersistenceUploads          = "uploads/"
	DefaultRegistrationEnabled         = false
	DefaultRedisEnabled                = false
	DefaultAuthGitHubEnabled           = false
	DefaultAuthGoogleEnabled           = false
	DefaultAuthCustomEnabled           = false
)

Variables

View Source
var (
	ConfigFileKey                         = "config"
	HTTPIPV4HostKey                       = "http.ipv4_host"
	HTTPIPV6HostKey                       = "http.ipv6_host"
	HTTPPortKey                           = "http.port"
	HTTPTracingEnabledKey                 = "http.tracing.enabled"
	HTTPTracingOTLPEndKey                 = "http.tracing.otlp_endpoint"
	HTTPPProfEnabledKey                   = "http.pprof.enabled"
	HTTPTrustedProxiesKey                 = "http.trusted_proxies"
	HTTPMetricsEnabledKey                 = "http.metrics.enabled"
	HTTPMetricsIPV4HostKey                = "http.metrics.ipv4_host"
	HTTPMetricsIPV6HostKey                = "http.metrics.ipv6_host"
	HTTPMetricsPortKey                    = "http.metrics.port"
	HTTPCORSHostsKey                      = "http.cors_hosts"
	HTTPFrontendURLKey                    = "http.frontend_url"
	HTTPBackendURLKey                     = "http.backend_url"
	PersistenceDatabaseDriverKey          = "persistence.database.driver"
	PersistenceDatabaseDatabaseKey        = "persistence.database.database"
	PersistenceDatabaseUsernameKey        = "persistence.database.username"
	PersistenceDatabasePasswordKey        = "persistence.database.password"
	PersistenceDatabaseHostKey            = "persistence.database.host"
	PersistenceDatabasePortKey            = "persistence.database.port"
	PersistenceDatabaseExtraParametersKey = "persistence.database.extra_parameters"
	PersistenceUploadsKey                 = "persistence.uploads"
	RegistrationEnabledKey                = "registration.enabled"
	AuthGoogleEnabledKey                  = "auth.google.enabled"
	AuthGoogleClientIDKey                 = "auth.google.client_id"
	//nolint:golint,gosec
	AuthGoogleClientSecretKey = "auth.google.client_secret"
	AuthGitHubEnabledKey      = "auth.github.enabled"
	AuthGitHubClientIDKey     = "auth.github.client_id"
	//nolint:golint,gosec
	AuthGitHubClientSecretKey  = "auth.github.client_secret"
	AuthCustomEnabledKey       = "auth.custom.enabled"
	AuthCustomClientIDKey      = "auth.custom.client_id"
	AuthCustomClientSecretKey  = "auth.custom.client_secret"
	AuthCustomTokenURLKey      = "auth.custom.token_url"
	AuthCustomUserURLKey       = "auth.custom.user_url"
	JWTSecretKey               = "jwt.secret"
	MapboxPublicTokenKey       = "mapbox.public_token"
	MapboxSecretTokenKey       = "mapbox.secret_token"
	RedisEnabledKey            = "redis.enabled"
	RedisSentinelEnabledKey    = "redis.sentinel.enabled"
	RedisSentinelMasterNameKey = "redis.sentinel.master_name"
	RedisSentinelAddressesKey  = "redis.sentinel.addresses"
	RedisSentinelPasswordKey   = "redis.sentinel.password"
	RedisSentinelUsernameKey   = "redis.sentinel.username"
	RedisAddressKey            = "redis.address"
	RedisUsernameKey           = "redis.username"
	RedisPasswordKey           = "redis.password"
	RedisDatabaseKey           = "redis.database"
)
View Source
var (
	ErrJWTSecretRequired           = errors.New("JWT secret is required")
	ErrBackendURLRequired          = errors.New("Backend URL is required")
	ErrFrontendURLRequired         = errors.New("Frontend URL is required")
	ErrOTLPEndpointRequired        = errors.New("OTLP endpoint is required when tracing is enabled")
	ErrMapboxPublicTokenRequired   = errors.New("Mapbox public token is required")
	ErrMapboxSecretTokenRequired   = errors.New("Mapbox secret token is required")
	ErrDBHostRequired              = errors.New("Database host is required")
	ErrDBDatabaseRequired          = errors.New("Database name is required")
	ErrDatabaseDriverRequired      = errors.New("Database driver is required")
	ErrRedisHostRequired           = errors.New("Redis host is required")
	ErrRedisSentinelMasterRequired = errors.New("Redis Sentinel master is required")
	ErrRedisSentinelHostsRequired  = errors.New("Redis Sentinel hosts are required")
	ErrGitHubOAuthRequired         = errors.New("GitHub OAuth client ID and secret are required")
	ErrGoogleOAuthRequired         = errors.New("Google OAuth client ID and secret are required")
	ErrCustomOAuthRequired         = errors.New("Custom OAuth client ID and secret are required")
	ErrCustomTokenURLRequired      = errors.New("Custom OAuth token URL is required")
	ErrCustomUserURLRequired       = errors.New("Custom OAuth user URL is required")
)

Functions

func RegisterFlags

func RegisterFlags(cmd *cobra.Command)

Types

type Auth

type Auth struct {
	Google Google `json:"google"`
	GitHub GitHub `json:"github"`
	Custom Custom `json:"custom"`
}

type Config

type Config struct {
	HTTP         HTTP         `json:"http"`
	Persistence  Persistence  `json:"persistence"`
	Registration Registration `json:"registration"`
	Auth         Auth         `json:"auth"`
	JWT          JWT          `json:"jwt"`
	Mapbox       Mapbox       `json:"mapbox"`
	Redis        Redis        `json:"redis"`
}

func LoadConfig

func LoadConfig(cmd *cobra.Command) (*Config, error)

func (*Config) Validate

func (c *Config) Validate() error

type Custom added in v0.0.158

type Custom struct {
	Enabled      bool   `json:"enabled"`
	ClientID     string `json:"client_id" yaml:"client_id"`
	ClientSecret string `json:"client_secret" yaml:"client_secret"`
	TokenURL     string `json:"token_url" yaml:"token_url"`
	UserURL      string `json:"user_url" yaml:"user_url"`
}

type Database added in v0.0.139

type Database struct {
	Driver          DatabaseDriver `json:"driver"`
	Database        string         `json:"database"`
	Username        string         `json:"username"`
	Password        string         `json:"password"`
	Host            string         `json:"host"`
	Port            uint16         `json:"port"`
	ExtraParameters string         `json:"extra_perimeters" yaml:"extra_perimeters"`
}

type DatabaseDriver added in v0.0.139

type DatabaseDriver string
const (
	DatabaseDriverSQLite   DatabaseDriver = "sqlite"
	DatabaseDriverMySQL    DatabaseDriver = "mysql"
	DatabaseDriverPostgres DatabaseDriver = "postgres"
)

type GitHub

type GitHub struct {
	Enabled      bool   `json:"enabled"`
	ClientID     string `json:"client_id" yaml:"client_id"`
	ClientSecret string `json:"client_secret" yaml:"client_secret"`
}

type Google

type Google struct {
	Enabled      bool   `json:"enabled"`
	ClientID     string `json:"client_id" yaml:"client_id"`
	ClientSecret string `json:"client_secret" yaml:"client_secret"`
}

type HTTP

type HTTP struct {
	HTTPListener
	Tracing
	FrontendURL    string   `json:"frontend_url" yaml:"frontend_url"`
	BackendURL     string   `json:"backend_url" yaml:"backend_url"`
	PProf          PProf    `json:"pprof"`
	TrustedProxies []string `json:"trusted_proxies" yaml:"trusted_proxies"`
	Metrics        Metrics  `json:"metrics"`
	CORSHosts      []string `json:"cors_hosts" yaml:"cors_hosts"`
}

type HTTPListener

type HTTPListener struct {
	IPV4Host string `json:"ipv4_host" yaml:"ipv4_host"`
	IPV6Host string `json:"ipv6_host" yaml:"ipv6_host"`
	Port     uint16 `json:"port"`
}

type JWT

type JWT struct {
	Secret string `json:"secret"`
}

type Mapbox

type Mapbox struct {
	SecretToken string `json:"secret_token" yaml:"secret_token"`
	PublicToken string `json:"public_token" yaml:"public_token"`
}

type Metrics

type Metrics struct {
	HTTPListener
	Enabled bool `json:"enabled"`
}

type PProf

type PProf struct {
	Enabled bool `json:"enabled"`
}

type Persistence

type Persistence struct {
	Database Database `json:"database"`
	Uploads  string   `json:"uploads"`
}

type Redis added in v0.0.143

type Redis struct {
	Enabled  bool     `json:"enabled"`
	Sentinel Sentinel `json:"sentinel"`
	Address  string   `json:"address"`
	Username string   `json:"username"`
	Password string   `json:"password"`
	Database int      `json:"database"`
}

type Registration

type Registration struct {
	Enabled bool `json:"enabled"`
}

type Sentinel added in v0.0.155

type Sentinel struct {
	Enabled    bool     `json:"enabled"`
	MasterName string   `json:"master_name" yaml:"master_name"`
	Addresses  []string `json:"addresses"`
	Password   string   `json:"password"`
	Username   string   `json:"username"`
}

type Tracing

type Tracing struct {
	Enabled      bool   `json:"enabled"`
	OTLPEndpoint string `json:"otlp_endpoint" yaml:"otlp_endpoint"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL