config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloudLocked

func CloudLocked(c Cloud) map[string]bool

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

func RelayLocked(r Relay) map[string]bool

RelayLocked reports which relay fields are locked by the loaded YAML.

func SourcePathRef

func SourcePathRef(l *Loaded) *string

SourcePathRef returns a pointer to the config path for JSON, or nil.

func WebhookLocked

func WebhookLocked(w Webhook) map[string]bool

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.

func (*Loader) Get

func (l *Loader) Get() *Loaded

Get returns the cached Loaded, reading from disk on first call.

func (*Loader) Reload

func (l *Loader) Reload() *Loaded

Reload re-reads the config file from disk and replaces the cache. Always succeeds — IO errors are logged via the returned Loaded's SourcePath being empty (the same shape as "no file found").

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.

type Storage

type Storage struct {
	MaxMessages *int `yaml:"max_messages"` //nolint:tagliatelle // config.yml uses snake_case
}

Storage is the pinnable subset of the storage section.

type Webhook

type Webhook struct {
	URL     *string `yaml:"url"`
	Secret  *string `yaml:"secret"`
	Enabled *bool   `yaml:"enabled"`
}

Webhook is the pinnable subset of the webhook section.

Jump to

Keyboard shortcuts

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