config

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEnvPrefix    = "APP_"
	DefaultEnvDelimiter = "__"
)

Variables

This section is empty.

Functions

func ResetActive

func ResetActive()

ResetActive clears the globally active runtime config.

func SetActive

func SetActive(cfg *Config)

SetActive stores runtime config for cross-package access during app bootstrap.

Types

type AdminConfig

type AdminConfig struct {
	BasePath      string           `koanf:"base_path" json:"base_path" yaml:"base_path"`
	Title         string           `koanf:"title" json:"title" yaml:"title"`
	DefaultLocale string           `koanf:"default_locale" json:"default_locale" yaml:"default_locale"`
	PublicAPI     bool             `koanf:"public_api" json:"public_api" yaml:"public_api"`
	APIPrefix     string           `koanf:"api_prefix" json:"api_prefix" yaml:"api_prefix"`
	APIVersion    string           `koanf:"api_version" json:"api_version" yaml:"api_version"`
	Debug         AdminDebugConfig `koanf:"debug" json:"debug" yaml:"debug"`
}

type AdminDebugConfig

type AdminDebugConfig struct {
	EnableSlog bool `koanf:"enable_slog" json:"enable_slog" yaml:"enable_slog"`
}

type AppConfig

type AppConfig struct {
	Name string `koanf:"name" json:"name" yaml:"name"`
	Env  string `koanf:"env" json:"env" yaml:"env"`
}

type AuthConfig

type AuthConfig struct {
	AdminID       string `koanf:"admin_id" json:"admin_id" yaml:"admin_id"`
	AdminEmail    string `koanf:"admin_email" json:"admin_email" yaml:"admin_email"`
	AdminRole     string `koanf:"admin_role" json:"admin_role" yaml:"admin_role"`
	AdminPassword string `koanf:"admin_password" json:"admin_password" yaml:"admin_password"`
	SigningKey    string `koanf:"signing_key" json:"signing_key" yaml:"signing_key"`
	ContextKey    string `koanf:"context_key" json:"context_key" yaml:"context_key"`
}

type Config

type Config struct {
	App       AppConfig       `koanf:"app" json:"app" yaml:"app"`
	Server    ServerConfig    `koanf:"server" json:"server" yaml:"server"`
	Admin     AdminConfig     `koanf:"admin" json:"admin" yaml:"admin"`
	Auth      AuthConfig      `koanf:"auth" json:"auth" yaml:"auth"`
	Features  FeatureConfig   `koanf:"features" json:"features" yaml:"features"`
	Runtime   RuntimeConfig   `koanf:"runtime" json:"runtime" yaml:"runtime"`
	Storage   StorageConfig   `koanf:"storage" json:"storage" yaml:"storage"`
	Email     EmailConfig     `koanf:"email" json:"email" yaml:"email"`
	Signer    SignerConfig    `koanf:"signer" json:"signer" yaml:"signer"`
	Services  ServicesConfig  `koanf:"services" json:"services" yaml:"services"`
	Google    GoogleConfig    `koanf:"google" json:"google" yaml:"google"`
	Public    PublicConfig    `koanf:"public" json:"public" yaml:"public"`
	Databases DatabasesConfig `koanf:"databases" json:"databases" yaml:"databases"`
	Network   NetworkConfig   `koanf:"network" json:"network" yaml:"network"`

	ConfigPath string `koanf:"-" json:"-" yaml:"-"`
}

Config defines runtime configuration for the e-sign example application.

func Active

func Active() Config

Active returns the currently active runtime config, or defaults when unset.

func Defaults

func Defaults() *Config

func Load

func Load(ctx context.Context, paths ...string) (*Config, *goconfig.Container[*Config], error)

Load resolves config from defaults, optional files, and environment overrides.

func (Config) Validate

func (c Config) Validate() error

type DatabasesConfig

type DatabasesConfig struct {
	ESignDSN   string `koanf:"esign_dsn" json:"esign_dsn" yaml:"esign_dsn"`
	ContentDSN string `koanf:"content_dsn" json:"content_dsn" yaml:"content_dsn"`
}

type EmailConfig

type EmailConfig struct {
	Transport string          `koanf:"transport" json:"transport" yaml:"transport"`
	SMTP      EmailSMTPConfig `koanf:"smtp" json:"smtp" yaml:"smtp"`
}

type EmailSMTPConfig

type EmailSMTPConfig struct {
	Host            string `koanf:"host" json:"host" yaml:"host"`
	Port            int    `koanf:"port" json:"port" yaml:"port"`
	Username        string `koanf:"username" json:"username" yaml:"username"`
	Password        string `koanf:"password" json:"password" yaml:"password"`
	FromName        string `koanf:"from_name" json:"from_name" yaml:"from_name"`
	FromAddress     string `koanf:"from_address" json:"from_address" yaml:"from_address"`
	TimeoutSeconds  int    `koanf:"timeout_seconds" json:"timeout_seconds" yaml:"timeout_seconds"`
	DisableSTARTTLS bool   `koanf:"disable_starttls" json:"disable_starttls" yaml:"disable_starttls"`
	InsecureTLS     bool   `koanf:"insecure_tls" json:"insecure_tls" yaml:"insecure_tls"`
}

type FeatureConfig

type FeatureConfig struct {
	ESign       bool `koanf:"esign" json:"esign" yaml:"esign"`
	ESignGoogle bool `koanf:"esign_google" json:"esign_google" yaml:"esign_google"`
	Activity    bool `koanf:"activity" json:"activity" yaml:"activity"`
}

type GoogleConfig

type GoogleConfig struct {
	ProviderMode          string `koanf:"provider_mode" json:"provider_mode" yaml:"provider_mode"`
	ClientID              string `koanf:"client_id" json:"client_id" yaml:"client_id"`
	ClientSecret          string `koanf:"client_secret" json:"client_secret" yaml:"client_secret"`
	OAuthRedirectURI      string `koanf:"oauth_redirect_uri" json:"oauth_redirect_uri" yaml:"oauth_redirect_uri"`
	TokenEndpoint         string `koanf:"token_endpoint" json:"token_endpoint" yaml:"token_endpoint"`
	RevokeEndpoint        string `koanf:"revoke_endpoint" json:"revoke_endpoint" yaml:"revoke_endpoint"`
	DriveBaseURL          string `koanf:"drive_base_url" json:"drive_base_url" yaml:"drive_base_url"`
	UserInfoEndpoint      string `koanf:"userinfo_endpoint" json:"userinfo_endpoint" yaml:"userinfo_endpoint"`
	HealthEndpoint        string `koanf:"health_endpoint" json:"health_endpoint" yaml:"health_endpoint"`
	HTTPTimeoutSeconds    int    `koanf:"http_timeout_seconds" json:"http_timeout_seconds" yaml:"http_timeout_seconds"`
	CredentialActiveKeyID string `koanf:"credential_active_key_id" json:"credential_active_key_id" yaml:"credential_active_key_id"`
	CredentialActiveKey   string `koanf:"credential_active_key" json:"credential_active_key" yaml:"credential_active_key"`
	CredentialKeysJSON    string `koanf:"credential_keys_json" json:"credential_keys_json" yaml:"credential_keys_json"`
}

type NetworkConfig

type NetworkConfig struct {
	RateLimitTrustProxyHeaders bool `koanf:"rate_limit_trust_proxy_headers" json:"rate_limit_trust_proxy_headers" yaml:"rate_limit_trust_proxy_headers"`
}

type PublicConfig

type PublicConfig struct {
	BaseURL string `koanf:"base_url" json:"base_url" yaml:"base_url"`
}

type RuntimeConfig

type RuntimeConfig struct {
	Profile       string `koanf:"profile" json:"profile" yaml:"profile"`
	StartupPolicy string `koanf:"startup_policy" json:"startup_policy" yaml:"startup_policy"`
	StrictStartup bool   `koanf:"strict_startup" json:"strict_startup" yaml:"strict_startup"`
}

type ServerConfig

type ServerConfig struct {
	Address string `koanf:"address" json:"address" yaml:"address"`
}

type ServicesConfig

type ServicesConfig struct {
	ModuleEnabled         bool   `koanf:"module_enabled" json:"module_enabled" yaml:"module_enabled"`
	EncryptionKey         string `koanf:"encryption_key" json:"encryption_key" yaml:"encryption_key"`
	CallbackPublicBaseURL string `koanf:"callback_public_base_url" json:"callback_public_base_url" yaml:"callback_public_base_url"`
}

type SignerConfig

type SignerConfig struct {
	UploadSigningKey             string `koanf:"upload_signing_key" json:"upload_signing_key" yaml:"upload_signing_key"`
	UploadTTLSeconds             int    `koanf:"upload_ttl_seconds" json:"upload_ttl_seconds" yaml:"upload_ttl_seconds"`
	ProfileTTLDays               int    `koanf:"profile_ttl_days" json:"profile_ttl_days" yaml:"profile_ttl_days"`
	ProfilePersistDrawnSignature bool   `koanf:"profile_persist_drawn_signature" json:"profile_persist_drawn_signature" yaml:"profile_persist_drawn_signature"`
	ProfileMode                  string `koanf:"profile_mode" json:"profile_mode" yaml:"profile_mode"`
}

type StorageConfig

type StorageConfig struct {
	EncryptionAlgorithm string `koanf:"encryption_algorithm" json:"encryption_algorithm" yaml:"encryption_algorithm"`
}

Jump to

Keyboard shortcuts

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