config

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(cfg Config) (*gorm.DB, error)

Connect opens and configures the database described by cfg.

func NewDatabaseConnection

func NewDatabaseConnection(cfg Config) *gorm.DB

NewDatabaseConnection is kept for source compatibility. New applications should use Connect so startup errors can be returned to the caller.

Types

type AdminConfig

type AdminConfig struct {
	Enabled   *bool  `json:"enabled"`
	SecretKey string `json:"secret_key"`
}

type AuthConfig

type AuthConfig struct {
	Enabled  *bool  `json:"enabled"`
	Provider string `json:"provider"`
	Domain   string `json:"domain"`
}

type Config

type Config struct {
	Prod          bool                       `json:"prod"`
	AppName       string                     `json:"app_name"`
	AuthDomain    string                     `json:"auth_domain"`
	Languages     []string                   `json:"languages"`
	Domains       []string                   `json:"domains"`
	Auth          AuthConfig                 `json:"auth"`
	RBAC          RBACConfig                 `json:"rbac"`
	Admin         AdminConfig                `json:"admin"`
	Servers       []ServerConfig             `json:"servers"`
	Database      DatabaseConfig             `json:"database"`
	Observability ObservabilityConfig        `json:"observability"`
	Logging       LoggingConfig              `json:"logging"`
	Plugins       map[string]json.RawMessage `json:"plugins,omitempty"`
	// contains filtered or unexported fields
}

func LoadConfiguration

func LoadConfiguration(file string) Config

func Read

func Read(file string) (Config, error)

Read loads and validates a runtime configuration without terminating the process.

func (Config) AdminAddress

func (c Config) AdminAddress() string

func (Config) AdminEnabled

func (c Config) AdminEnabled() bool

func (Config) AuthBaseURL

func (c Config) AuthBaseURL() string

func (Config) AuthEnabled

func (c Config) AuthEnabled() bool

func (Config) AuthProvider

func (c Config) AuthProvider() string

func (Config) AutoMigrateEnabled

func (c Config) AutoMigrateEnabled() bool

func (Config) Decode added in v0.7.1

func (c Config) Decode(target any) error

Decode unmarshals the already loaded and environment-expanded source config into an application-owned structure. It does not read the file again.

func (Config) PluginConfig added in v0.2.0

func (c Config) PluginConfig(name string) json.RawMessage

func (Config) PublicAddress

func (c Config) PublicAddress() string

func (Config) RBACEnabled

func (c Config) RBACEnabled() bool

func (Config) SourcePath added in v0.7.1

func (c Config) SourcePath() string

SourcePath returns the path used to load this runtime configuration.

func (Config) UploadAddress

func (c Config) UploadAddress() string

func (Config) Validate

func (c Config) Validate() error

type DatabaseConfig

type DatabaseConfig struct {
	Driver                 string `json:"driver"`
	Host                   string `json:"host"`
	User                   string `json:"user"`
	Password               string `json:"password"`
	DbName                 string `json:"dbname"`
	Port                   int    `json:"port"`
	Charset                string `json:"charset"`
	SSLMode                string `json:"sslmode"`
	TimeZone               string `json:"timezone"`
	MaxOpenConns           int    `json:"max_open_conns"`
	MaxIdleConns           int    `json:"max_idle_conns"`
	ConnMaxLifetimeSeconds int    `json:"conn_max_lifetime_seconds"`
	ConnMaxIdleTimeSeconds int    `json:"conn_max_idle_time_seconds"`
	AutoMigrate            *bool  `json:"auto_migrate"`
	MigrationsDir          string `json:"migrations_dir"`
	MigrationsTable        string `json:"migrations_table"`
}

type LoggingConfig

type LoggingConfig struct {
	Level       string `json:"level"`
	FileEnabled bool   `json:"file_enabled"`
	FileDir     string `json:"file_dir"`
}

func (LoggingConfig) WithDefaults

func (cfg LoggingConfig) WithDefaults() LoggingConfig

type ObservabilityConfig

type ObservabilityConfig struct {
	Namespace         string  `json:"namespace"`
	TraceExporter     string  `json:"trace_exporter"`
	MetricsExporter   string  `json:"metrics_exporter"`
	TraceOTLPEndpoint string  `json:"trace_otlp_endpoint"`
	TraceSampleRatio  float64 `json:"trace_sample_ratio"`

	// derived by WithDefaults — not in JSON
	ServiceName       string `json:"service_name"`
	ServiceVersion    string `json:"service_version"`
	Environment       string `json:"environment"`
	TraceOTLPInsecure bool
}

func (ObservabilityConfig) WithDefaults

func (cfg ObservabilityConfig) WithDefaults(appVersion, appName string, prod bool) ObservabilityConfig

type RBACConfig

type RBACConfig struct {
	Enabled          *bool    `json:"enabled"`
	DefaultRole      string   `json:"default_role"`
	AdminIdentityIDs []string `json:"admin_identity_ids"`
}

type ServerConfig

type ServerConfig struct {
	Name string `json:"name"`
	Host string `json:"host"`
	Port int    `json:"port"`
}

Jump to

Keyboard shortcuts

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