database

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package database is CSF's own database: the PostgreSQL container a host provisions and owns when it is given no other, so CSF's state lives with CSF and never in another project's database.

It is an docker.OwnedService: a pinned image, a named volume for the data, a port probed once and published on 127.0.0.1 only, and a password generated once, all recorded in <state>/database.json, mode 0600. What is PostgreSQL's alone lives here: the image, the credentials, the health check, the backup directory pg_dump writes into, and the csfpg settings a host opens its pool with.

Index

Constants

View Source
const (
	// RecordFile is the record under the state directory, mode 0600.
	RecordFile = "database.json"
	// BackupDirectory is where backups are written, under the state directory.
	BackupDirectory = "backups"
	// ContainerBackupDirectory is where the backup directory is mounted inside
	// the container, so pg_dump writes its file there.
	ContainerBackupDirectory = "/backups"
	// Image is the pinned PostgreSQL image, by digest.
	Image = "postgres:18.4-alpine3.24@sha256:9a8afca54e7861fd90fab5fdf4c42477a6b1cb7d293595148e674e0a3181de15"
	// User and Name are the role and database CSF's schema lives in.
	User = "csf"
	Name = "csf"
)

Variables

This section is empty.

Functions

func NewOwnedDatabase

func NewOwnedDatabase(state string, backupUser string, options ...docker.OwnedServiceOption) (*docker.OwnedService[Access], error)

NewOwnedDatabase is the database the state directory owns, its backups written as backupUser (user:group).

func Settings

func Settings(record Record) csfpg.Settings

Settings is the csfpg configuration the record names.

Types

type Access

type Access struct {
	User     string `json:"user"`
	Database string `json:"database"`
	Password string `json:"password"`
	// BackupDirectory is the host path mounted at [ContainerBackupDirectory].
	BackupDirectory string `json:"backup_directory"`
	// BackupUser is the user:group pg_dump runs as, so backups belong to the
	// host's user.
	BackupUser string `json:"backup_user"`
}

Access is the database's own part of its record: how to log in, and where and as whom backups are written.

type Record

type Record = docker.OwnedRecord[Access]

Record is <state>/database.json.

func DecodeRecord

func DecodeRecord(path string, content []byte) (Record, error)

DecodeRecord decodes database.json in its current or previous shape and requires every field the host acts on, so a missing backup directory is an error naming the file and the fix, never an empty path.

Jump to

Keyboard shortcuts

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