config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config loads and validates ditto.yaml configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Source Source `mapstructure:"source"`
	Dump   Dump   `mapstructure:"dump"`

	CopyTTLSeconds int          `mapstructure:"copy_ttl_seconds"`
	PortPoolStart  int          `mapstructure:"port_pool_start"`
	PortPoolEnd    int          `mapstructure:"port_pool_end"`
	WarmPoolSize   int          `mapstructure:"warm_pool_size"` // 0 = disabled (default)
	CopyImage      string       `mapstructure:"copy_image"`     // optional Docker image override
	DockerHost     string       `mapstructure:"docker_host"`    // optional Docker-compatible daemon host override
	Server         ServerConfig `mapstructure:"server"`
	Obfuscation    Obfuscation  `mapstructure:"obfuscation"`
}

Config is the top-level configuration structure, mirroring ditto.yaml.

func Load

func Load(path string) (*Config, error)

Load reads and validates the config file at path. Environment variables with the prefix DITTO_ override config file values (e.g. DITTO_SOURCE_HOST overrides source.host, DITTO_SOURCE_URL overrides source.url).

type Dump

type Dump struct {
	Schedule       string `mapstructure:"schedule"`
	Path           string `mapstructure:"path"`
	SchemaPath     string `mapstructure:"schema_path"`     // optional: path for a schema-only (DDL) dump; empty = disabled
	StaleThreshold int    `mapstructure:"stale_threshold"` // seconds
	ClientImage    string `mapstructure:"client_image"`    // optional helper image override for dump operations
}

Dump controls the dump scheduler.

type Obfuscation

type Obfuscation struct {
	Rules []ObfuscationRule `mapstructure:"rules"`
}

Obfuscation holds post-restore PII scrubbing rules applied to every copy.

type ObfuscationRule

type ObfuscationRule struct {
	Table    string `mapstructure:"table"`
	Column   string `mapstructure:"column"`
	Strategy string `mapstructure:"strategy"`  // nullify | redact | mask | hash | replace
	With     string `mapstructure:"with"`      // redact: replacement text (default "[redacted]")
	MaskChar string `mapstructure:"mask_char"` // mask: character to use (default "*")
	KeepLast int    `mapstructure:"keep_last"` // mask: preserve trailing N characters
	Type     string `mapstructure:"type"`      // replace: data type — email | name | phone | ip | url | uuid
}

ObfuscationRule describes how a single table column should be scrubbed. Strategies: nullify, redact, mask, hash, replace.

type ServerConfig

type ServerConfig struct {
	Addr        string `mapstructure:"addr"`         // listen address, default ":8080"
	Token       string `mapstructure:"token"`        // plaintext Bearer token (dev only)
	TokenSecret string `mapstructure:"token_secret"` // secret reference: env:VAR, file:/path, or arn:aws:...
}

ServerConfig holds HTTP server and authentication settings for ditto serve.

type Source

type Source struct {
	URL            string `mapstructure:"url"` // DSN alternative to individual fields
	Engine         string `mapstructure:"engine"`
	Host           string `mapstructure:"host"`
	Port           int    `mapstructure:"port"`
	Database       string `mapstructure:"database"`
	User           string `mapstructure:"user"`
	Password       string `mapstructure:"password"`        // plain password (dev only)
	PasswordSecret string `mapstructure:"password_secret"` // secret reference: env:VAR, file:/path, or arn:aws:...
}

Source holds connection parameters for the RDS source database.

Jump to

Keyboard shortcuts

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