requires

package
v1.4.13 Latest Latest
Warning

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

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

Documentation

Overview

Package requires checks a plugin's requires.postgres_extensions against the project's Postgres before the plugin is downloaded (P7-ADOPT-06).

Purpose: a plugin such as claw needs the `vector` extension; on a cluster without it the install used to fail deep inside the plugin's boot migrations. Check refuses up front with E507 and the fix, installing nothing. Inputs: the project config, the extension names from the manifest, a Probe (nil selects the Docker probe). Outputs: nil, or an *errs.CLIError E507. A custom image whose contents are unknown yields only an E508 warning on Stderr. A database that is running but cannot be queried is a plain error, never a false "missing". Constraints: read-only (never creates or enables an extension); extension names are validated against nameRE and are never placed in SQL: the probe lists pg_available_extensions and the comparison happens here.

Index

Constants

This section is empty.

Variables

View Source
var Stderr io.Writer = os.Stderr

Stderr receives the E508 warning. Tests replace it.

Functions

func Check

func Check(ctx context.Context, cfg *config.Config, exts []string, probe Probe) error

Check returns nil when every extension in exts is available, or an E507 error naming each missing one. An empty exts returns nil without a probe.

Types

type Probe

type Probe interface {
	// Running reports whether the project's postgres container is running.
	Running(ctx context.Context) (bool, error)
	// Available returns the extension names the running server can create.
	Available(ctx context.Context) (map[string]bool, error)
}

Probe reports on the live cluster.

var DefaultProbe Probe

DefaultProbe replaces the Docker probe when Check gets a nil Probe. It is a test seam and stays nil in production.

func DockerProbe

func DockerProbe(cfg *config.Config) Probe

DockerProbe returns the default probe for cfg; the integration test uses it against a container it started.

Jump to

Keyboard shortcuts

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