postgres

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PostgresUsername = "postgres"
	PostgresPassword = "postgres"
)

IMPORTANT: Having non-static passwords would make Magic not works as the Container allocation currently does not contain service driver data.

This means that instruction calling would break if we added back password and username changing.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresDriver

type PostgresDriver struct {
	Image     string   `json:"image"`
	Databases []string `json:"databases"`
}

func NewDriver

func NewDriver(image string) *PostgresDriver

Create a new PostgreSQL service driver.

It currently supports PostgreSQL 18.

func (*PostgresDriver) ClearTables

func (pd *PostgresDriver) ClearTables(container mconfig.ContainerInformation) error

Clear all tables in all databases (keeps table schema alive, just removes the content of all tables)

func (*PostgresDriver) CreateContainer

func (pd *PostgresDriver) CreateContainer(ctx context.Context, c *client.Client, a mconfig.ContainerAllocation) (string, error)

Should create a new container for the database or use the existing one (returns container id + error in case one happened)

func (*PostgresDriver) DropTables

func (pd *PostgresDriver) DropTables(container mconfig.ContainerInformation) error

Drop all tables in all databases (actually deletes all of your tables)

func (*PostgresDriver) GetImage

func (pd *PostgresDriver) GetImage() string

func (*PostgresDriver) GetRequiredPortAmount

func (pd *PostgresDriver) GetRequiredPortAmount() int

func (*PostgresDriver) GetUniqueId

func (pd *PostgresDriver) GetUniqueId() string

A unique identifier for the database driver. This is appended to the container name to make sure we know it's the container from the driver.

func (*PostgresDriver) HandleInstruction

func (pd *PostgresDriver) HandleInstruction(ctx context.Context, c *client.Client, container mconfig.ContainerInformation, instruction mconfig.Instruction) error

Handles the instructions for PostgreSQL. Supports the following instructions currently: - Clear tables - Drop tables

func (*PostgresDriver) Host

Get hostname of the database container created by the driver as a EnvironmentValue for your config.

func (*PostgresDriver) Initialize

func (pd *PostgresDriver) Initialize(ctx context.Context, c *client.Client, container mconfig.ContainerInformation) error

Initialize the internal container with a script (for example)

func (*PostgresDriver) IsHealthy

func (pd *PostgresDriver) IsHealthy(ctx context.Context, c *client.Client, container mconfig.ContainerInformation) (bool, error)

Check for postgres health

func (*PostgresDriver) Load

func (pd *PostgresDriver) Load(data string) (mconfig.ServiceDriver, error)

func (*PostgresDriver) NewDatabase

func (pd *PostgresDriver) NewDatabase(name string) *PostgresDriver

func (*PostgresDriver) Password

func (pd *PostgresDriver) Password() mconfig.EnvironmentValue

Get the password for the user of the databases in this driver as a EnvironmentValue for your config.

func (*PostgresDriver) Port

Get the port of the database container created by the driver as a EnvironmentValue for your config.

func (*PostgresDriver) Save

func (pd *PostgresDriver) Save() (string, error)

func (*PostgresDriver) Username

func (pd *PostgresDriver) Username() mconfig.EnvironmentValue

Get the username of the databases in this driver as a EnvironmentValue for your config.

Jump to

Keyboard shortcuts

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