postgresql

package
v0.12.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	AddonName      = "miren-postgresql"
	BaseImage      = "oci.miren.cloud/postgres"
	DefaultVersion = "18"
)
View Source
const (
	ConfigStorage = "storage"
	ConfigShared  = "shared"
)

Variant configuration keys

Variables

This section is empty.

Functions

func Definition

func Definition() addon.AddonDefinition

Definition returns the addon definition for PostgreSQL.

func IsSharedVariant

func IsSharedVariant(variantName string) bool

IsSharedVariant returns true if the variant is a shared-server variant.

func RegisterDedicatedSaga

func RegisterDedicatedSaga(registry *saga.Registry, fw *addon.ProviderFramework, rc *resultCapture) error

RegisterDedicatedSaga registers the dedicated PostgreSQL provisioning saga.

func RegisterDeprovisionDedicatedSaga

func RegisterDeprovisionDedicatedSaga(registry *saga.Registry, fw *addon.ProviderFramework) error

RegisterDeprovisionDedicatedSaga registers the dedicated deprovisioning saga.

func RegisterDeprovisionSharedSaga

func RegisterDeprovisionSharedSaga(registry *saga.Registry, fw *addon.ProviderFramework) error

RegisterDeprovisionSharedSaga registers the shared deprovisioning saga.

func RegisterEnsureSharedServerSaga

func RegisterEnsureSharedServerSaga(registry *saga.Registry, fw *addon.ProviderFramework) error

RegisterEnsureSharedServerSaga registers the saga that creates the shared PostgreSQL server infrastructure (entity, pool, service).

func RegisterRotateDedicatedSaga added in v0.12.1

func RegisterRotateDedicatedSaga(registry *saga.Registry, fw *addon.ProviderFramework, rc *rotateCapture) error

RegisterRotateDedicatedSaga registers the dedicated PostgreSQL rotation saga.

func RegisterRotateSharedSuperuserSaga added in v0.12.1

func RegisterRotateSharedSuperuserSaga(registry *saga.Registry, fw *addon.ProviderFramework, rc *rotateCapture) error

RegisterRotateSharedSuperuserSaga registers the superuser rotation saga.

func RegisterRotateSharedUserSaga added in v0.12.1

func RegisterRotateSharedUserSaga(registry *saga.Registry, fw *addon.ProviderFramework, rc *rotateCapture) error

RegisterRotateSharedUserSaga registers the per-app user rotation saga.

func RegisterSharedSaga

func RegisterSharedSaga(registry *saga.Registry, fw *addon.ProviderFramework, rc *resultCapture) error

RegisterSharedSaga registers the shared PostgreSQL provisioning saga. This also registers the nested ensure-shared-server saga in the same registry.

func UndoAlterDedicatedUserPassword added in v0.12.1

func UndoAlterDedicatedUserPassword(ctx context.Context, in AlterDedicatedUserPasswordIn, out AlterDedicatedUserPasswordOut) error

func UndoAlterSharedUserPassword added in v0.12.1

func UndoAlterSharedUserPassword(ctx context.Context, in AlterSharedUserPasswordIn, out AlterSharedUserPasswordOut) error

func UndoAlterSuperuserPassword added in v0.12.1

func UndoAlterSuperuserPassword(ctx context.Context, in AlterSuperuserPasswordIn, out AlterSuperuserPasswordOut) error

func UndoBackfillSuperuserDiskName added in v0.12.1

func UndoBackfillSuperuserDiskName(ctx context.Context, in BackfillSuperuserDiskNameIn, out BackfillSuperuserDiskNameOut) error

func UndoBuildDedicatedRotationResult added in v0.12.1

func UndoBuildDedicatedRotationResult(ctx context.Context, in BuildDedicatedRotationResultIn, out BuildDedicatedRotationResultOut) error

func UndoBuildSharedResult

func UndoBuildSharedResult(ctx context.Context, in BuildSharedResultIn, out BuildSharedResultOut) error

func UndoBuildUserRotationResult added in v0.12.1

func UndoBuildUserRotationResult(ctx context.Context, in BuildUserRotationResultIn, out BuildUserRotationResultOut) error

func UndoCaptureDedicatedConnInfo added in v0.12.1

func UndoCaptureDedicatedConnInfo(ctx context.Context, in CaptureDedicatedConnInfoIn, out CaptureDedicatedConnInfoOut) error

func UndoCaptureOldUserPassword added in v0.12.1

func UndoCaptureOldUserPassword(ctx context.Context, in CaptureOldUserPasswordIn, out CaptureOldUserPasswordOut) error

func UndoCaptureSuperuserResult added in v0.12.1

func UndoCaptureSuperuserResult(ctx context.Context, in CaptureSuperuserResultIn, out CaptureSuperuserResultOut) error

func UndoCreateSharedPool

func UndoCreateSharedPool(ctx context.Context, in CreateSharedPoolIn, out CreateSharedPoolOut) error

func UndoCreateSharedUser

func UndoCreateSharedUser(ctx context.Context, in CreateSharedUserIn, out CreateSharedUserOut) error

func UndoDecodeSharedAttrs

func UndoDecodeSharedAttrs(ctx context.Context, in DecodeSharedAttrsIn, out DecodeSharedAttrsOut) error

func UndoDropSharedUser

func UndoDropSharedUser(ctx context.Context, in DropSharedUserIn, out DropSharedUserOut) error

func UndoLoadDedicatedRotationState added in v0.12.1

func UndoLoadDedicatedRotationState(ctx context.Context, in LoadDedicatedRotationStateIn, out LoadDedicatedRotationStateOut) error

func UndoUpdateDedicatedEntity added in v0.12.1

func UndoUpdateDedicatedEntity(ctx context.Context, in UpdateDedicatedEntityIn, out UpdateDedicatedEntityOut) error

func UndoUpdateSuperuserEntity added in v0.12.1

func UndoUpdateSuperuserEntity(ctx context.Context, in UpdateSuperuserEntityIn, out UpdateSuperuserEntityOut) error

Types

type ActivateSharedServerIn

type ActivateSharedServerIn struct {
	ServerID          entity.Id
	PoolID            entity.Id
	ServiceID         entity.Id
	SuperuserPassword string
	DiskName          string
	ServiceHost       string
}

type ActivateSharedServerOut

type ActivateSharedServerOut struct {
	Activated bool
}

type AlterDedicatedUserPasswordIn added in v0.12.1

type AlterDedicatedUserPasswordIn struct {
	DedicatedServiceHost string `saga:"dedicatedservicehost"`
	DedicatedUser        string `saga:"dedicateduser"`
	DedicatedDatabase    string `saga:"dedicateddatabase"`
	DedicatedOldPassword string `saga:"dedicatedoldpassword"`
	DedicatedNewPassword string `saga:"dedicatednewpassword"`
}

type AlterDedicatedUserPasswordOut added in v0.12.1

type AlterDedicatedUserPasswordOut struct {
	// Edge producer: gate the entity update on the engine actually changing.
	DedicatedUserAltered bool `saga:"dedicated_user_altered"`
}

func AlterDedicatedUserPassword added in v0.12.1

type AlterSharedUserPasswordIn added in v0.12.1

type AlterSharedUserPasswordIn struct {
	SharedServiceHost       string `saga:"sharedservicehost"`
	SharedSuperuserPassword string `saga:"sharedsuperuserpassword"`
	SharedUserName          string `saga:"sharedusername"`
	UserNewPassword         string `saga:"usernewpassword"`
	UserOldPassword         string `saga:"useroldpassword"`
}

type AlterSharedUserPasswordOut added in v0.12.1

type AlterSharedUserPasswordOut struct {
	UserAltered bool
}

func AlterSharedUserPassword added in v0.12.1

func AlterSharedUserPassword(ctx context.Context, in AlterSharedUserPasswordIn) (AlterSharedUserPasswordOut, error)

type AlterSuperuserPasswordIn added in v0.12.1

type AlterSuperuserPasswordIn struct {
	SharedServiceHost       string `saga:"sharedservicehost"`
	SharedSuperuserPassword string `saga:"sharedsuperuserpassword"`
	SuperuserNewPassword    string `saga:"superusernewpassword"`

	DiskEnsured saga.Edge `saga:"superuser_disk_ensured"`
}

type AlterSuperuserPasswordOut added in v0.12.1

type AlterSuperuserPasswordOut struct {
	// Edge producer: gate the entity update on the engine actually changing.
	SuperuserAltered bool `saga:"superuser_altered"`
}

func AlterSuperuserPassword added in v0.12.1

func AlterSuperuserPassword(ctx context.Context, in AlterSuperuserPasswordIn) (AlterSuperuserPasswordOut, error)

type BackfillSuperuserDiskNameIn added in v0.12.1

type BackfillSuperuserDiskNameIn struct {
	SharedServerRef entity.Id `saga:"sharedserverref"`
}

type BackfillSuperuserDiskNameOut added in v0.12.1

type BackfillSuperuserDiskNameOut struct {
	// Edge producer: the disk name must be recorded before the password changes,
	// or the legacy password-derived name would be lost.
	SuperuserDiskEnsured bool `saga:"superuser_disk_ensured"`
}

func BackfillSuperuserDiskName added in v0.12.1

type BuildDedicatedResultIn

type BuildDedicatedResultIn struct {
	ServiceHost  string
	Username     string
	Password     string
	DatabaseName string
	ServerID     entity.Id
}

type BuildDedicatedResultOut

type BuildDedicatedResultOut struct {
	Done bool
}

type BuildDedicatedRotationResultIn added in v0.12.1

type BuildDedicatedRotationResultIn struct {
	DedicatedServiceHost string `saga:"dedicatedservicehost"`
	DedicatedUser        string `saga:"dedicateduser"`
	DedicatedDatabase    string `saga:"dedicateddatabase"`
	DedicatedNewPassword string `saga:"dedicatednewpassword"`
}

type BuildDedicatedRotationResultOut added in v0.12.1

type BuildDedicatedRotationResultOut struct {
	Done bool
}

func BuildDedicatedRotationResult added in v0.12.1

type BuildSharedResultIn

type BuildSharedResultIn struct {
	ServerID           entity.Id
	ServiceHost        string
	SharedDatabaseName string
	SharedUsername     string
	SharedPassword     string
}

type BuildSharedResultOut

type BuildSharedResultOut struct {
	Done bool
}

type BuildUserRotationResultIn added in v0.12.1

type BuildUserRotationResultIn struct {
	SharedServiceHost string `saga:"sharedservicehost"`
	SharedUserName    string `saga:"sharedusername"`
	SharedDbName      string `saga:"shareddbname"`
	UserNewPassword   string `saga:"usernewpassword"`
}

type BuildUserRotationResultOut added in v0.12.1

type BuildUserRotationResultOut struct {
	Done bool
}

func BuildUserRotationResult added in v0.12.1

func BuildUserRotationResult(ctx context.Context, in BuildUserRotationResultIn) (BuildUserRotationResultOut, error)

type CaptureDedicatedConnInfoIn added in v0.12.1

type CaptureDedicatedConnInfoIn struct {
	AssocEntity *entity.Entity `saga:"assocentity"`
}

type CaptureDedicatedConnInfoOut added in v0.12.1

type CaptureDedicatedConnInfoOut struct {
	DedicatedUser     string `saga:"dedicateduser"`
	DedicatedDatabase string `saga:"dedicateddatabase"`
}

func CaptureDedicatedConnInfo added in v0.12.1

func CaptureDedicatedConnInfo(ctx context.Context, in CaptureDedicatedConnInfoIn) (CaptureDedicatedConnInfoOut, error)

CaptureDedicatedConnInfo resolves the role name and database to connect to. Provisioning records both on the association attrs (see BuildDedicatedResult), so they read straight off the entity — no dependency on a deployed app. Associations created before those attrs existed fall back to the app's active ConfigVersion, the authoritative record of what the app connects as. The password is never read here: the durable current password lives on the server entity (see LoadDedicatedRotationState), which survives even a retry that already redeployed the app onto the new secret.

type CaptureOldUserPasswordIn added in v0.12.1

type CaptureOldUserPasswordIn struct {
	AssocEntity *entity.Entity `saga:"assocentity"`
}

type CaptureOldUserPasswordOut added in v0.12.1

type CaptureOldUserPasswordOut struct {
	UserOldPassword string `saga:"useroldpassword"`
}

func CaptureOldUserPassword added in v0.12.1

func CaptureOldUserPassword(ctx context.Context, in CaptureOldUserPasswordIn) (CaptureOldUserPasswordOut, error)

type CaptureSuperuserResultIn added in v0.12.1

type CaptureSuperuserResultIn struct {
	Recorded saga.Edge `saga:"superuser_altered"`
}

type CaptureSuperuserResultOut added in v0.12.1

type CaptureSuperuserResultOut struct {
	Done bool
}

func CaptureSuperuserResult added in v0.12.1

func CaptureSuperuserResult(ctx context.Context, in CaptureSuperuserResultIn) (CaptureSuperuserResultOut, error)

CaptureSuperuserResult records a non-nil, empty result: rotating the superuser touches no consumer variables, so there is nothing to redeploy.

type CleanupSharedServerIn

type CleanupSharedServerIn struct {
	SharedServerRef  entity.Id
	SharedServiceRef entity.Id
	SharedPoolRef    entity.Id
	SharedDiskName   string
	RemainingCount   int64
}

type CleanupSharedServerOut

type CleanupSharedServerOut struct {
	CleanedUp bool
}

type CreateDedicatedPoolIn

type CreateDedicatedPoolIn struct {
	ServerName    string
	AppName       string
	DatabaseName  string
	Username      string
	Password      string
	VariantConfig map[string]string
}

type CreateDedicatedPoolOut

type CreateDedicatedPoolOut struct {
	PoolID entity.Id
}

type CreatePostgresServerIn

type CreatePostgresServerIn struct {
	ServerName  string
	VariantName string
	Password    string
}

type CreatePostgresServerOut

type CreatePostgresServerOut struct {
	ServerID entity.Id
}

type CreateSharedDatabaseIn

type CreateSharedDatabaseIn struct {
	ServiceHost        string
	SuperuserPassword  string
	SharedDatabaseName string
	SharedUsername     string
}

type CreateSharedDatabaseOut

type CreateSharedDatabaseOut struct {
	DatabaseCreated bool
}

type CreateSharedPoolIn

type CreateSharedPoolIn struct {
	SuperuserPassword string
	DiskName          string
	VariantConfig     map[string]string
}

type CreateSharedPoolOut

type CreateSharedPoolOut struct {
	PoolID entity.Id
}

type CreateSharedServerEntityIn

type CreateSharedServerEntityIn struct {
	SuperuserPassword string
	DiskName          string
	VariantConfig     map[string]string
}

type CreateSharedServerEntityOut

type CreateSharedServerEntityOut struct {
	ServerID entity.Id
}

type CreateSharedUserIn

type CreateSharedUserIn struct {
	ServiceHost             string
	SuperuserPassword       string
	GeneratedSharedUsername string
	SharedPassword          string
}

type CreateSharedUserOut

type CreateSharedUserOut struct {
	SharedUsername string
}

type DecodeDedicatedAttrsIn

type DecodeDedicatedAttrsIn struct {
	AssocEntity *entity.Entity `saga:"assocentity"`
}

type DecodeDedicatedAttrsOut

type DecodeDedicatedAttrsOut struct {
	DedicatedServerID entity.Id `saga:"dedicatedserverid"`
}

type DecodeSharedAttrsIn

type DecodeSharedAttrsIn struct {
	AssocEntity *entity.Entity `saga:"assocentity"`
}

type DecodeSharedAttrsOut

type DecodeSharedAttrsOut struct {
	SharedServerRef entity.Id
	SharedDbName    string
	SharedUserName  string
}

type DeleteDedicatedServerEntityIn

type DeleteDedicatedServerEntityIn struct {
	DedicatedServerID   entity.Id
	DedicatedServerName string

	// PoolCleanedUp forces this action to run after DeleteDedicatedPool,
	// ensuring the server entity is deleted last.
	PoolCleanedUp saga.Edge `saga:"dedicated_pool_deleted"`
}

type DeleteDedicatedServerEntityOut

type DeleteDedicatedServerEntityOut struct {
	ServerDeleted bool
}

type DropSharedDatabaseIn

type DropSharedDatabaseIn struct {
	SharedServiceHost       string
	SharedSuperuserPassword string
	SharedDbName            string
	ConnectionsTerminated   bool
}

type DropSharedDatabaseOut

type DropSharedDatabaseOut struct {
	DatabaseDropped bool
}

type DropSharedUserIn

type DropSharedUserIn struct {
	SharedServiceHost       string
	SharedSuperuserPassword string
	SharedUserName          string
	ConnectionsTerminated   bool
}

type DropSharedUserOut

type DropSharedUserOut struct {
	UserDropped bool
}

type FindOrCreateSharedServerIn

type FindOrCreateSharedServerIn struct {
	AppName       string
	VariantConfig map[string]string
}

type FindOrCreateSharedServerOut

type FindOrCreateSharedServerOut struct {
	ServerID          entity.Id
	SuperuserPassword string
	ServiceHost       string
}

type GenerateCredentialsIn

type GenerateCredentialsIn struct {
	AppName string
}

type GenerateCredentialsOut

type GenerateCredentialsOut struct {
	Password     string
	DatabaseName string
	Username     string
	ServiceName  string
	ServerName   string
}

type GenerateSharedCredentialsIn

type GenerateSharedCredentialsIn struct {
	AppName string
}

type GenerateSharedCredentialsOut

type GenerateSharedCredentialsOut struct {
	SharedPassword          string
	SharedDatabaseName      string
	GeneratedSharedUsername string
}

type LoadDedicatedRotationStateIn added in v0.12.1

type LoadDedicatedRotationStateIn struct {
	DedicatedServerID entity.Id `saga:"dedicatedserverid"`
}

type LoadDedicatedRotationStateOut added in v0.12.1

type LoadDedicatedRotationStateOut struct {
	DedicatedServiceHost string `saga:"dedicatedservicehost"`
	DedicatedOldPassword string `saga:"dedicatedoldpassword"`
}

func LoadDedicatedRotationState added in v0.12.1

type LookupDedicatedServerIn

type LookupDedicatedServerIn struct {
	DedicatedServerID entity.Id
}

type LookupDedicatedServerOut

type LookupDedicatedServerOut struct {
	DedicatedServiceID  entity.Id
	DedicatedPoolID     entity.Id
	DedicatedServerName string
}

type LookupSharedServerIn

type LookupSharedServerIn struct {
	SharedServerRef entity.Id
}

type LookupSharedServerOut

type LookupSharedServerOut struct {
	SharedSuperuserPassword string
	SharedDiskName          string
	SharedServiceRef        entity.Id
	SharedPoolRef           entity.Id
	SharedAssocCount        int64
	SharedServiceHost       string
}

type Provider

type Provider struct {
	dbsaga.BaseProvider
}

Provider implements the AddonProvider interface for PostgreSQL.

func NewProvider

func NewProvider(fw *addon.ProviderFramework) *Provider

NewProvider creates a new PostgreSQL addon provider.

func (*Provider) Deprovision

func (p *Provider) Deprovision(ctx context.Context, assoc addon.AddonAssociation) error

func (*Provider) Provision

func (p *Provider) Provision(ctx context.Context, app addon.App, variant addon.Variant) (*addon.ProvisionResult, error)

func (*Provider) RotateCredential added in v0.12.1

func (p *Provider) RotateCredential(ctx context.Context, assoc addon.AddonAssociation, credential, newSecret string) (*addon.RotationResult, error)

RotateCredential implements addon.CredentialRotator for PostgreSQL. Shared servers expose two independently-rotatable credentials:

  • "" / "user" — the association's per-app database user. Rotated live with ALTER USER; the new password flows to the consuming app, which is redeployed. (Class A: no restart, no disk coupling.)
  • "superuser" — the shared server's admin password. Rotated live with ALTER ROLE and recorded on the server entity. Apps never receive it, so no consumer is redeployed. (Class C: safe now that the data disk name is decoupled from this password.)

Dedicated servers have a single credential: the app's own role, which is the instance's bootstrap superuser (POSTGRES_USER) and the value consumers embed. It rotates live with ALTER ROLE — the pool never relaunches, since the env password only seeds initdb — and the new secret both flows to the app and is recorded on the server entity. (Class A + entity update.)

type TerminateConnectionsIn

type TerminateConnectionsIn struct {
	SharedServiceHost       string
	SharedSuperuserPassword string
	SharedDbName            string
}

type TerminateConnectionsOut

type TerminateConnectionsOut struct {
	ConnectionsTerminated bool
}

type UpdateDedicatedEntityIn added in v0.12.1

type UpdateDedicatedEntityIn struct {
	DedicatedServerID    entity.Id `saga:"dedicatedserverid"`
	DedicatedNewPassword string    `saga:"dedicatednewpassword"`
	DedicatedOldPassword string    `saga:"dedicatedoldpassword"`

	Altered saga.Edge `saga:"dedicated_user_altered"`
}

type UpdateDedicatedEntityOut added in v0.12.1

type UpdateDedicatedEntityOut struct {
	DedicatedRecorded bool
}

func UpdateDedicatedEntity added in v0.12.1

func UpdateDedicatedEntity(ctx context.Context, in UpdateDedicatedEntityIn) (UpdateDedicatedEntityOut, error)

type UpdateDedicatedServerIn

type UpdateDedicatedServerIn struct {
	ServerID    entity.Id
	PoolID      entity.Id
	ServiceID   entity.Id
	ServiceHost string
	VariantName string
	Password    string
}

type UpdateDedicatedServerOut

type UpdateDedicatedServerOut struct {
	Updated bool
}

type UpdateSuperuserEntityIn added in v0.12.1

type UpdateSuperuserEntityIn struct {
	SharedServerRef         entity.Id `saga:"sharedserverref"`
	SuperuserNewPassword    string    `saga:"superusernewpassword"`
	SharedSuperuserPassword string    `saga:"sharedsuperuserpassword"`

	Altered saga.Edge `saga:"superuser_altered"`
}

type UpdateSuperuserEntityOut added in v0.12.1

type UpdateSuperuserEntityOut struct {
	SuperuserRecorded bool
}

func UpdateSuperuserEntity added in v0.12.1

func UpdateSuperuserEntity(ctx context.Context, in UpdateSuperuserEntityIn) (UpdateSuperuserEntityOut, error)

Jump to

Keyboard shortcuts

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