container

package
v3.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ContainerName = "pgit-local"

ContainerName is the name of the shared pgit local container

View Source
const DefaultImage = "ghcr.io/imgajeed76/pg-xpatch:latest"

DefaultImage is the pg-xpatch Docker image

View Source
const DefaultPassword = "pgit"

DefaultPassword is the default password for the local PostgreSQL container

View Source
const DefaultPort = 5433

DefaultPort is the default PostgreSQL port for the local container

View Source
const VolumeName = "pgit-data"

VolumeName is the named Docker volume for persistent PostgreSQL data Named volumes are used instead of bind mounts for cross-platform compatibility: - Work identically on Linux, macOS, and Windows - No UID/GID permission issues (Docker manages this) - No filesystem compatibility issues (NFS, NTFS, etc.) - Survive container removal (docker rm)

Variables

This section is empty.

Functions

func CheckForUpdate

func CheckForUpdate(runtime Runtime) (bool, string, string)

CheckForUpdate checks if a newer pg-xpatch image is available Returns (updateAvailable, currentDigest, remoteDigest)

func ContainerExists

func ContainerExists(runtime Runtime) bool

ContainerExists checks if the pgit-local container exists (running or stopped)

func ContainerHasNamedVolume

func ContainerHasNamedVolume(runtime Runtime) bool

ContainerHasNamedVolume checks if the container uses the named pgit-data volume

func DropDatabase

func DropDatabase(runtime Runtime, database string) error

DropDatabase drops a database, terminating any active connections first

func EnsureDatabase

func EnsureDatabase(runtime Runtime, database string) error

EnsureDatabase creates the database if it doesn't exist

func FindAvailablePort

func FindAvailablePort(startPort int) int

FindAvailablePort finds an available port starting from the given port

func GetContainerAnonymousVolume

func GetContainerAnonymousVolume(runtime Runtime) string

GetContainerAnonymousVolume returns the anonymous volume ID used by the container for /var/lib/postgresql/data, or empty string if using named volume or not found

func GetContainerImageDigest

func GetContainerImageDigest(runtime Runtime) string

GetContainerImageDigest returns the image digest (sha256) of the running container

func GetContainerLogs

func GetContainerLogs(runtime Runtime, tail int) (string, error)

GetContainerLogs returns the container logs

func GetContainerPort

func GetContainerPort(runtime Runtime) (int, error)

GetContainerPort returns the host port mapped to PostgreSQL (5432)

func GetLocalImageDigest

func GetLocalImageDigest(runtime Runtime) string

GetLocalImageDigest returns the repo digest of the locally cached image This is the manifest digest that can be compared with the registry

func GetRemoteImageDigest

func GetRemoteImageDigest() string

GetRemoteImageDigest fetches the latest image digest from the registry Returns empty string if unable to fetch (network error, etc.)

func GetRuntimeVersion

func GetRuntimeVersion(runtime Runtime) (string, error)

GetRuntimeVersion returns the version of the container runtime

func GetVolumeInfo

func GetVolumeInfo(runtime Runtime) (mountpoint string, size string, err error)

GetVolumeInfo returns information about the pgit data volume

func IsContainerRunning

func IsContainerRunning(runtime Runtime) bool

IsContainerRunning checks if the pgit-local container is running

func IsPortAvailable

func IsPortAvailable(port int) bool

IsPortAvailable checks if a port is available

func LocalConnectionURL

func LocalConnectionURL(port int, database string) string

LocalConnectionURL returns the connection URL for the local container

func MigrateToNamedVolume

func MigrateToNamedVolume(runtime Runtime, progressFn func(stage string)) error

MigrateToNamedVolume migrates data from an anonymous volume to the named pgit-data volume This is used to upgrade legacy containers that used anonymous volumes

func PullLatestImage

func PullLatestImage(runtime Runtime) error

PullLatestImage pulls the latest pg-xpatch image

func RemoveContainer

func RemoveContainer(runtime Runtime) error

RemoveContainer removes the pgit-local container

func RemoveVolume

func RemoveVolume(runtime Runtime) error

RemoveVolume removes the pgit data volume (WARNING: destroys all data!)

func StartContainer

func StartContainer(runtime Runtime, port int) error

StartContainer starts the pgit-local container

func StopContainer

func StopContainer(runtime Runtime) error

StopContainer stops the pgit-local container

func UpdateContainer

func UpdateContainer(runtime Runtime, progressFn func(stage string)) error

UpdateContainer updates the container to use the latest image This requires recreating the container (data is preserved in volume)

func VolumeExists

func VolumeExists(runtime Runtime) bool

VolumeExists checks if the pgit data volume exists

func WaitForPostgres

func WaitForPostgres(runtime Runtime, maxAttempts int) error

WaitForPostgres waits for PostgreSQL to be ready in the container

Types

type Runtime

type Runtime string

Runtime represents a container runtime (Docker or Podman)

const (
	RuntimeDocker Runtime = "docker"
	RuntimePodman Runtime = "podman"
	RuntimeNone   Runtime = ""
)

func DetectRuntime

func DetectRuntime() Runtime

DetectRuntime finds an available container runtime

Jump to

Keyboard shortcuts

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