Documentation
¶
Overview ¶
Package config loads optional user configuration from YAML at `$XDG_CONFIG_HOME/mailtrap-local/config.yml` (override path with MAILTRAP_LOCAL_CONFIG). Sections are pinned: any key present here overrides the equivalent DB row, and the dialog renders the field read-only.
Sections:
storage:
max_messages: 500 # 0 = unlimited; default 500
cloud:
api_token: ${MAILTRAP_API_TOKEN}
sandbox_id: 12345
mirror_enabled: true
relay:
host: smtp.example.com
port: 587
username: user
password: ${SMTP_PASSWORD}
auth: plain
tls: auto
auto_relay_enabled: false
override_from: noreply@example.com
return_path: bounces@example.com
webhook:
url: https://hooks.example.com/inbox
secret: ${WEBHOOK_SECRET}
enabled: true
`${VAR}` references resolve to the named environment variable. Unset vars resolve to nil (treated the same as omitting the key).
Index ¶
- func CloudLocked(c Cloud) map[string]bool
- func OverlayCloud(c *store.CloudConnection, cfg Cloud)
- func OverlayRelay(c *store.RelayConnection, cfg Relay)
- func OverlayWebhook(c *store.WebhookConnection, cfg Webhook)
- func RelayLocked(r Relay) map[string]bool
- func SourcePathRef(l *Loaded) *string
- func WebhookLocked(w Webhook) map[string]bool
- type Cloud
- type Loaded
- type Loader
- type Relay
- type Storage
- type Webhook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloudLocked ¶
CloudLocked reports which cloud fields are locked by the loaded YAML.
func OverlayCloud ¶
func OverlayCloud(c *store.CloudConnection, cfg Cloud)
OverlayCloud applies YAML cloud settings onto a DB row (config wins).
func OverlayRelay ¶
func OverlayRelay(c *store.RelayConnection, cfg Relay)
OverlayRelay applies YAML relay settings onto a DB row (config wins).
func OverlayWebhook ¶
func OverlayWebhook(c *store.WebhookConnection, cfg Webhook)
OverlayWebhook applies YAML webhook settings onto a DB row (config wins).
func RelayLocked ¶
RelayLocked reports which relay fields are locked by the loaded YAML.
func SourcePathRef ¶
SourcePathRef returns a pointer to the config path for JSON, or nil.
func WebhookLocked ¶
WebhookLocked reports which webhook fields are locked by the loaded YAML.
Types ¶
type Cloud ¶
type Cloud struct {
APIToken *string `yaml:"api_token"` //nolint:tagliatelle // config.yml uses snake_case
SandboxID *int64 `yaml:"sandbox_id"` //nolint:tagliatelle // config.yml uses snake_case
MirrorEnabled *bool `yaml:"mirror_enabled"` //nolint:tagliatelle // config.yml uses snake_case
}
Cloud is the pinnable subset of the cloud section.
type Loaded ¶
type Loaded struct {
Storage Storage
Cloud Cloud
Relay Relay
Webhook Webhook
SourcePath string // empty if no file was found
}
Loaded is the parsed config + the resolved file path (nil if no file was found at the resolved location).
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader is the cached config holder. Use Get/Reload from handlers.
func NewLoader ¶
func NewLoader() *Loader
NewLoader creates an empty loader; call Reload to read from disk.
type Relay ¶
type Relay struct {
Host *string `yaml:"host"`
Port *int `yaml:"port"`
Username *string `yaml:"username"`
Password *string `yaml:"password"`
Auth *string `yaml:"auth"`
TLS *string `yaml:"tls"`
AutoRelayEnabled *bool `yaml:"auto_relay_enabled"` //nolint:tagliatelle // config.yml uses snake_case
OverrideFrom *string `yaml:"override_from"` //nolint:tagliatelle // config.yml uses snake_case
ReturnPath *string `yaml:"return_path"` //nolint:tagliatelle // config.yml uses snake_case
}
Relay is the pinnable subset of the relay section.