Documentation
¶
Overview ¶
Package pgctl runs Postgres-side operations (seeding, readiness) through the runtime driver — pgbranch never touches data files from the host.
Index ¶
- func Seed(ctx context.Context, d runtime.Driver, s SeedSpec) error
- func SeedDump(ctx context.Context, d runtime.Driver, s SeedDumpSpec) error
- func StartSourcePG(t *testing.T, ctx context.Context) (host string, port int, networkName string, hostConn string)
- func StartSourcePGVersion(t *testing.T, ctx context.Context, major string) (host string, port int, networkName string, hostConn string)
- type SeedDumpSpec
- type SeedSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Seed ¶
Seed runs pg_basebackup into the source volume. The helper runs as the in-image postgres user (uid 999) so file ownership matches branch containers. Data lands in <volume>/data because pg_basebackup insists on creating the target dir itself with 0700; the volume root is first chowned to uid 999 so it can. Requires REPLICATION privilege on the source (superuser works).
func SeedDump ¶ added in v0.3.0
SeedDump builds the source volume from a logical dump: initdb a fresh cluster, then pg_dump | psql from the remote — all inside one helper container running as the in-image postgres user (uid 999), so file ownership matches branch containers. Unlike Seed it needs only a normal user on the remote (no REPLICATION privilege), which makes managed providers usable as sources. The helper image's major version must be >= the remote server's (pg_dump cannot dump newer servers) and branches run the cluster initdb produced, i.e. the helper image's version.
func StartSourcePG ¶
func StartSourcePG(t *testing.T, ctx context.Context) (host string, port int, networkName string, hostConn string)
StartSourcePG starts a "production" postgres:17 on a dedicated docker network and returns its in-network host, port, network name, and a host connection string. It is a shared integration-test helper (lives in a non-test file so other packages' tests can import it).
func StartSourcePGVersion ¶
func StartSourcePGVersion(t *testing.T, ctx context.Context, major string) (host string, port int, networkName string, hostConn string)
StartSourcePGVersion is StartSourcePG for an arbitrary Postgres major (image postgres:<major>), used by the version-matrix integration test.
Types ¶
type SeedDumpSpec ¶ added in v0.3.0
type SeedDumpSpec struct {
SeedSpec
Database string // remote database to dump ("" = postgres)
Schemas []string // schemas to dump (empty = the whole database)
}
SeedDumpSpec seeds a source with pg_dump instead of pg_basebackup: a logical copy for managed Postgres (Supabase, Neon, RDS, Cloud SQL) where physical replication connections are not allowed.
type SeedSpec ¶
type SeedSpec struct {
Image string // postgres image matching the source's major version
// Volume is the seed target: a volume name, or — with MountKind
// MountHostPath (zfs backend) — the dataset's absolute mountpoint.
Volume string
MountKind runtime.MountKind
Network string // docker network from which the source is reachable ("" = bridge)
Host string
Port int
User string
Password string
}