spec

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: GPL-2.0, GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package spec parses and validates the DB_SPECS environment variable: a whitespace-separated list of "host[:port]:dbname:user" tuples describing which PostgreSQL databases to dump and over which network coordinates.

This is the single validation path. There is no second (shell) implementation to drift from, and the rules here are the only thing that stands between operator-supplied config and a pg_dump/psql argv. Passwords are never part of the grammar: libpq resolves them from .pgpass keyed on host:port:dbname:user.

Index

Constants

View Source
const DefaultPort = 5432

DefaultPort is the PostgreSQL port assumed when a spec omits one.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBSpec

type DBSpec struct {
	Host    string
	DBName  string
	User    string
	Raw     string // original token, for error reporting and logs
	Invalid string // non-empty => why this spec is invalid
	Port    int
}

DBSpec is one validated host[:port]:dbname:user tuple. A spec with a non-empty Invalid field failed validation and must never be passed to pg_dump; the orchestrator reports it per-DB and skips it.

func ParseSpecs

func ParseSpecs(raw string) []DBSpec

ParseSpecs splits raw on whitespace and validates each tuple. Every token yields exactly one DBSpec (valid or Invalid); tokens are never dropped silently. Duplicate (host, port, dbname) keys keep the first occurrence and mark later ones Invalid. The returned slice preserves input order.

Jump to

Keyboard shortcuts

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