config

package
v0.0.233 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 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"
	DefaultRegistrationEnabled                          = false
	DefaultNATSEnabled                                  = false
	DefaultAuthGitHubEnabled                            = false
	DefaultAuthGoogleEnabled                            = false
	DefaultAuthCustomEnabled                            = false
	DefaultLogLevel                                     = LogLevelInfo
	DefaultParallelLogParsers                           = 4
	DefaultPersistenceUploadsDriver                     = UploadsDriverFilesystem
	DefaultPersistenceUploadsFilesystemOptionsDirectory = "uploads/"
)

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"
	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"
	PersistenceUploadsDriverKey                     = "persistence.uploads.driver"
	PersistenceUploadsFilesystemOptionsDirectoryKey = "persistence.uploads.filesystem_options.directory"
	PersistenceUploadsS3OptionsBucketKey            = "persistence.uploads.s3_options.bucket"
	PersistenceUploadsS3OptionsRegionKey            = "persistence.uploads.s3_options.region"
	PersistenceUploadsS3OptionsEndpointKey          = "persistence.uploads.s3_options.endpoint"
	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"
	//nolint:golint,gosec
	AuthCustomClientSecretKey = "auth.custom.client_secret"
	//nolint:golint,gosec
	AuthCustomTokenURLKey = "auth.custom.token_url"
	AuthCustomUserURLKey  = "auth.custom.user_url"
	JWTSecretKey          = "jwt.secret"
	MapboxPublicTokenKey  = "mapbox.public_token"
	MapboxSecretTokenKey  = "mapbox.secret_token"
	NATSEnabledKey        = "nats.enabled"
	NATSURLKey            = "nats.url"
	NATSTokenKey          = "nats.token"
	LogLevelKey           = "log_level"
	ParallelLogParsersKey = "parallel_log_parsers"
)
View Source
var (
	ErrJWTSecretRequired          = errors.New("JWT secret is required")
	ErrBackendURLRequired         = errors.New("Backend 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")
	ErrNATSURLRequired            = errors.New("NATS URL is 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")
	ErrParallelLogParsersNotZero  = errors.New("Number of parallel log parsers must be greater than zero")
	ErrInvalidLogLevel            = errors.New("Invalid log level")
	ErrUploadsFSDirectoryRequired = errors.New("Filesystem uploads directory is required")
	ErrUploadsS3BucketRequired    = errors.New("S3 bucket is required")
	ErrUploadsS3RegionRequired    = errors.New("S3 region 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"`
	NATS               NATS         `json:"nats"`
	ParallelLogParsers uint         `json:"parallel_log_parsers" yaml:"parallel_log_parsers"`
	LogLevel           LogLevel     `json:"log_level" yaml:"log_level"`
}

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 FilesystemOptions added in v0.0.197

type FilesystemOptions struct {
	Directory string `json:"directory"`
}

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
	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 LogLevel added in v0.0.180

type LogLevel string
const (
	LogLevelDebug LogLevel = "debug"
	LogLevelInfo  LogLevel = "info"
	LogLevelWarn  LogLevel = "warn"
	LogLevelError LogLevel = "error"
)

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 NATS added in v0.0.174

type NATS struct {
	Enabled bool   `json:"enabled"`
	URL     string `json:"url"`
	Token   string `json:"token"`
}

type PProf

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

type Persistence

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

type Registration

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

type S3Options added in v0.0.197

type S3Options struct {
	Region   string `json:"region"`
	Bucket   string `json:"bucket"`
	Endpoint string `json:"endpoint"`
}

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"`
}

type Uploads added in v0.0.197

type Uploads struct {
	Driver            UploadsDriver     `json:"driver"`
	FilesystemOptions FilesystemOptions `json:"filesystem_options" yaml:"filesystem_options"`
	S3Options         S3Options         `json:"s3_options" yaml:"s3_options"`
}

type UploadsDriver added in v0.0.197

type UploadsDriver string
const (
	UploadsDriverFilesystem UploadsDriver = "filesystem"
	UploadsDriverS3         UploadsDriver = "s3"
)

Jump to

Keyboard shortcuts

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