Help us shape the future of Go! Take the 2026 Go Developer Survey

load

package
v1.4.15 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package load applies verified bundles to fresh, started targets. Purpose: target preconditions. Inputs: loaded config. Outputs: refusal before writes. Constraints: Docker reads use the funnel; SQL identifiers are sanitized.

Index

Constants

View Source
const RestoreSkipMember = "db/restore.skip"

RestoreSkipMember is the bundle member that names the archive entry kinds to leave out.

Variables

This section is empty.

Functions

func Apply

func Apply(ctx context.Context, cfg *config.Config, r *portable.Reader, opts Options) ([]portable.Exemption, error)

func ApplyStorage

func ApplyStorage(ctx context.Context, r *portable.Reader, store *objstore.Client, skip bool) ([]portable.Exemption, error)

func ApplyUsers

func ApplyUsers(ctx context.Context, db *pgx.Conn, users []verify.User) error

func AuthPreflight

func AuthPreflight(ctx context.Context, db queryRower, bundleUsers int) error

AuthPreflight refuses a bundle with users when the target already holds auth users: the load would add to them and verification (which counts every target user) could never reach zero.

func Connect

func Connect(ctx context.Context, cfg *config.Config) (*pgx.Conn, error)

func Empty

func Empty(ctx context.Context, db *pgx.Conn, schemas []string, storage bool) error

func Image

func Image(ctx context.Context, cfg *config.Config) (string, error)

func SkipKinds added in v1.4.15

func SkipKinds(r *portable.Reader) ([]string, error)

SkipKinds reads the bundle's restore.skip member; a bundle without one skips nothing.

func SkipPlatformOwned added in v1.4.15

func SkipPlatformOwned(ctx context.Context, db queryRower, toc, source string) (string, error)

SkipPlatformOwned comments out of a pg_restore list the platform function public.uuidv7() when the bundle was written by nSelf and the target already has that function, so a round trip does not refuse its own platform function (E519 in TypeFunctionCollisions). Bundles from any other source keep the line, so a foreign public.uuidv7() is still refused; a target without the function keeps the line too and gets the function from the dump.

func Started

func Started(ctx context.Context, dir string) error

func StorageCollisions added in v1.4.15

func StorageCollisions(ctx context.Context, m portable.Manifest, store lister, skip bool) error

StorageCollisions refuses, before the first write, a bundle whose objects would replace objects the target store already holds (D-0723): the load is an unconditional PUT and verification compares against the bundle, so an overwrite would otherwise pass. Keys are compared in the store's canonical form, because a PUT to "a//b" replaces "a/b" without listing differently; a key with no canonical form, or two bundle keys that share one, are refused. A bucket the target does not have yet is empty. Errors name no key.

func StoragePreflight

func StoragePreflight(m portable.Manifest, store *objstore.Client, skip bool) error

func Store

func Store(cfg *config.Config) (*objstore.Client, error)

func SystemTable

func SystemTable(schema, name string, storage bool) bool

func TryLock

func TryLock(ctx context.Context, db queryRower) error

TryLock takes the import lock on db without waiting.

func TypeFunctionCollisions

func TypeFunctionCollisions(ctx context.Context, db queryRower, toc string, schemas []string) error

Types

type Options

type Options struct {
	SkipStorage bool
	// Progress, when set, records whether the target was written and the last finished step.
	Progress *Progress
}

type Progress

type Progress struct {
	Wrote bool
	Step  string
}

Progress tells the caller whether Apply changed the target. Wrote is set immediately before the first statement that can change it (the compat or pre-data one-shot), so any error with Wrote false left the target untouched.

Jump to

Keyboard shortcuts

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