config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config provides configuration management for imapsync.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSrcServerRequired = errors.New("source server is required")
	ErrSrcUserRequired   = errors.New("source user is required")
	ErrSrcPassRequired   = errors.New("source password is required")
	ErrDstServerRequired = errors.New("destination server is required")
	ErrDstUserRequired   = errors.New("destination user is required")
	ErrDstPassRequired   = errors.New("destination password is required")
)

Sentinel errors returned by Config.validate. Callers can match on these with errors.Is to distinguish missing fields from other failures.

Functions

This section is empty.

Types

type Config

type Config struct {
	Src       Credentials        `json:"src"        yaml:"src"`
	Dst       Credentials        `json:"dst"        yaml:"dst"`
	Map       []DirectoryMapping `json:"map"        yaml:"map"`
	RateLimit RateLimit          `json:"rate_limit" yaml:"rate_limit"`
	Workers   int                `json:"-"          yaml:"-"`
}

Config holds the entire configuration for the application.

func New

func New(c *cli.Command) (*Config, error)

New loads configuration from the file specified in CLI context. It automatically detects the format (JSON or YAML) based on file extension. Supported extensions: .json, .yaml, .yml It returns an error if the file cannot be read or contains invalid data.

type Credentials

type Credentials struct {
	Label  string `json:"label"  yaml:"label"`  // Human-readable label for the server
	Server string `json:"server" yaml:"server"` // Server address (host:port)
	User   string `json:"user"   yaml:"user"`   // Username
	Pass   string `json:"pass"   yaml:"pass"`   // Password
}

Credentials holds IMAP connection data.

type DirectoryMapping

type DirectoryMapping struct {
	Source      string `json:"src" yaml:"src"` // Source folder name
	Destination string `json:"dst" yaml:"dst"` // Destination folder name
}

DirectoryMapping holds source and destination folder names.

type RateLimit added in v1.1.0

type RateLimit struct {
	DownBPS        int `json:"down_bps"        yaml:"down_bps"`
	UpBPS          int `json:"up_bps"          yaml:"up_bps"`
	MaxConnections int `json:"max_connections" yaml:"max_connections"`
}

RateLimit caps client-side throughput. Zero values mean "unlimited" and the corresponding limiter is not constructed at all.

MaxConnections caps the simultaneous IMAP sessions per side. Many providers enforce this server-side (Gmail = 15) — exceeding it earns a temporary ban.

Jump to

Keyboard shortcuts

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