Documentation
¶
Overview ¶
Package postgres is the production controlplane.Database adapter, backed by Postgres running in the cluster (ADR-0012). It implements the deploy-record seam (ADR-0007): the durable history of releases and the rollback handles, independent of cluster state. Schema changes are applied by embedded goose migrations on startup, gated to single-minor-step upgrades (ADR-0013).
It uses the pgx driver through the standard database/sql interface (not pgxpool, not the maintenance-mode lib/pq), so one *sql.DB serves both the migrations and the app. It lives under controlplane/ (not controlplane/internal) so cmd/burrowd and the managed module can wire it; it is licensed Apache-2.0 (LICENSING.md, ADR-0033).
Index ¶
- type Store
- func (s *Store) Addon(ctx context.Context, name string) (controlplane.AddonInfo, error)
- func (s *Store) Addons(ctx context.Context) ([]controlplane.AddonInfo, error)
- func (s *Store) AppEnv(ctx context.Context, app string) (map[string]string, error)
- func (s *Store) AppendAudit(ctx context.Context, e controlplane.AuditEntry) error
- func (s *Store) Audit(ctx context.Context, filter controlplane.AuditFilter) ([]controlplane.AuditEntry, error)
- func (s *Store) Close() error
- func (s *Store) CreateEnvironment(ctx context.Context, name, namespace string) error
- func (s *Store) DeleteAddon(ctx context.Context, name string) error
- func (s *Store) DeleteReleases(ctx context.Context, app string) error
- func (s *Store) GetBackup(ctx context.Context, id string) (controlplane.Backup, error)
- func (s *Store) GetEnvironment(ctx context.Context, name string) (controlplane.Environment, error)
- func (s *Store) LatestRelease(ctx context.Context, app string) (controlplane.Release, error)
- func (s *Store) ListBackups(ctx context.Context, app string) ([]controlplane.Backup, error)
- func (s *Store) ListEnvironments(ctx context.Context) ([]controlplane.Environment, error)
- func (s *Store) Migrate(ctx context.Context, appVersion string) error
- func (s *Store) Policy(ctx context.Context) (controlplane.Policy, error)
- func (s *Store) Provider(ctx context.Context, name string) (controlplane.Provider, error)
- func (s *Store) Providers(ctx context.Context) ([]controlplane.Provider, error)
- func (s *Store) RecordBackup(ctx context.Context, b controlplane.Backup) error
- func (s *Store) Release(ctx context.Context, id string) (controlplane.Release, error)
- func (s *Store) Releases(ctx context.Context, app string) ([]controlplane.Release, error)
- func (s *Store) SaveAddon(ctx context.Context, a controlplane.AddonInfo) error
- func (s *Store) SaveProvider(ctx context.Context, p controlplane.Provider) error
- func (s *Store) SaveRelease(ctx context.Context, r controlplane.Release) error
- func (s *Store) SetAppEnv(ctx context.Context, app, key, value string) error
- func (s *Store) SetBackupStatus(ctx context.Context, id string, status controlplane.BackupStatus, ...) error
- func (s *Store) SetGuardrail(ctx context.Context, code controlplane.GuardrailCode, ...) error
- func (s *Store) UnsetAppEnv(ctx context.Context, app, key string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a Postgres-backed controlplane.Database.
func Open ¶
Open connects to the database at dsn and verifies the connection. The caller closes the Store with Close. It does not apply the schema; call Migrate for that.
func (*Store) Addon ¶
Addon returns the add-on with the given name, or ErrNotFound. The returned info has Ready false — readiness is probed live, never read from the registry.
func (*Store) Addons ¶
Addons returns all registered add-ons, name order. Each row has Ready false — readiness is a live property, probed by the caller, not stored.
func (*Store) AppEnv ¶
AppEnv returns the non-secret environment store for app (ADR-0028). An app with no env yields an empty map and no error.
func (*Store) AppendAudit ¶
func (s *Store) AppendAudit(ctx context.Context, e controlplane.AuditEntry) error
AppendAudit appends one audit row (ADR-0027). The log is append-only: there is only this INSERT and the Audit SELECT — no update or delete path. The store assigns id.
func (*Store) Audit ¶
func (s *Store) Audit(ctx context.Context, filter controlplane.AuditFilter) ([]controlplane.AuditEntry, error)
Audit returns audit rows matching filter, newest first, capped by filter.Limit (a default when unset). The filter clauses are optional and ANDed; an empty filter returns the latest rows up to the cap.
func (*Store) CreateEnvironment ¶ added in v0.7.0
CreateEnvironment registers a named environment mapping name to namespace (ADR-0035 phase 2). The name is the primary key, so a duplicate is rejected: the INSERT ... ON CONFLICT DO NOTHING affects no rows, which is reported as an ErrInvalid-wrapped duplicate error.
func (*Store) DeleteAddon ¶
DeleteAddon removes the add-on row with the given name, or ErrNotFound if no such row exists.
func (*Store) DeleteReleases ¶
DeleteReleases removes every release record for app. Deleting the releases of an app that has none is a no-op (no RowsAffected check) — absence is fine.
func (*Store) GetEnvironment ¶ added in v0.7.0
func (s *Store) GetEnvironment(ctx context.Context, name string) (controlplane.Environment, error)
GetEnvironment returns the registered environment with the given name, or ErrNotFound.
func (*Store) LatestRelease ¶
func (*Store) ListBackups ¶
ListBackups returns recorded backups, newest first. An empty app lists every app's backups; a non-empty app restricts to that app. No matches yields an empty slice and no error.
func (*Store) ListEnvironments ¶ added in v0.7.0
func (s *Store) ListEnvironments(ctx context.Context) ([]controlplane.Environment, error)
ListEnvironments returns the registered environments ordered by name (ADR-0035 phase 2). The synthesized `default` environment is not stored here; the engine prepends it.
func (*Store) Migrate ¶
Migrate brings the database schema up to date and records appVersion as the version that last migrated it. It first enforces the single-minor-step upgrade gate (ADR-0013): if the database was last migrated by a different version, the upgrade must be exactly one minor step forward within the same major, or Migrate refuses before changing anything. Migrations are applied under a Postgres advisory lock, so concurrent control-plane replicas do not race. Migrate is safe to call on every startup; with no pending migrations it only re-stamps the version.
func (*Store) Policy ¶
Policy returns the current guardrail policy: the built-in defaults with any stored guardrail dispositions overlaid (ADR-0020). An empty table yields DefaultPolicy.
func (*Store) RecordBackup ¶
RecordBackup persists a new backup row (ADR-0032). burrowd records it pending before starting the backup Job, then SetBackupStatus moves it to completed/failed when the Job finishes. An existing row with the same id is overwritten. The row names the app, the on-PVC path, and the status — never a credential.
func (*Store) SaveAddon ¶
SaveAddon upserts an add-on in the registry by name (ADR-0025). It records the non-secret registry entry — type, mode, backend, where it lives, and the capabilities it serves. Ready is a live property of the cluster and is never persisted; it is probed at list time.
func (*Store) SaveProvider ¶
SaveProvider upserts a provider in the registry by name (ADR-0023). It records only the non-secret registry entry; the token lives in the burrow-credentials Secret.
func (*Store) SaveRelease ¶
func (*Store) SetBackupStatus ¶
func (s *Store) SetBackupStatus(ctx context.Context, id string, status controlplane.BackupStatus, sizeBytes int64) error
SetBackupStatus updates a recorded backup's status and size (the Job-finished transition). Setting the status of an unknown backup id returns ErrNotFound.
func (*Store) SetGuardrail ¶
func (s *Store) SetGuardrail(ctx context.Context, code controlplane.GuardrailCode, disp controlplane.Disposition) error
SetGuardrail upserts one guardrail's disposition.