common

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: PostgreSQL Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const ResourceTypeEtcdCreds resource.Type = "common.etcd_creds"
View Source
const ResourceTypePatroniCluster resource.Type = "common.patroni_cluster"
View Source
const ResourceTypePatroniMember resource.Type = "common.patroni_member"
View Source
const ResourceTypePgBackRestConfig resource.Type = "common.pgbackrest_config"
View Source
const ResourceTypePgBackRestStanza resource.Type = "common.pgbackrest_stanza"
View Source
const ResourceTypePgServiceConf resource.Type = "common.pg_service_conf"
View Source
const ResourceTypePostgresCerts resource.Type = "common.postgres_certs"

Variables

This section is empty.

Functions

func EtcdCredsIdentifier

func EtcdCredsIdentifier(instanceID string) resource.Identifier

func PatroniClusterResourceIdentifier

func PatroniClusterResourceIdentifier(nodeName string) resource.Identifier

func PatroniMemberResourceIdentifier

func PatroniMemberResourceIdentifier(instanceID string) resource.Identifier

func PgBackRestConfigIdentifier

func PgBackRestConfigIdentifier(instanceID string, configType pgbackrest.ConfigType) resource.Identifier

func PgBackRestStanzaIdentifier

func PgBackRestStanzaIdentifier(nodeName string) resource.Identifier

func PgServiceConfResourceIdentifier

func PgServiceConfResourceIdentifier(instanceID string) resource.Identifier

func PostgresCertsIdentifier

func PostgresCertsIdentifier(instanceID string) resource.Identifier

func ReadResourceFile

func ReadResourceFile(fs afero.Fs, path string) ([]byte, error)

func RegisterResourceTypes

func RegisterResourceTypes(registry *resource.Registry)

Types

type EtcdCreds

type EtcdCreds struct {
	InstanceID string `json:"instance_id"`
	DatabaseID string `json:"database_id"`
	HostID     string `json:"host_id"`
	NodeName   string `json:"node_name"`
	ParentID   string `json:"parent_id"`
	OwnerUID   int    `json:"owner_uid"`
	OwnerGID   int    `json:"owner_gid"`
	Username   string `json:"username"`
	Password   string `json:"password"`
	CaCert     []byte `json:"ca_cert"`
	ClientCert []byte `json:"client_cert"`
	ClientKey  []byte `json:"client_key"`
}

func (*EtcdCreds) Create

func (c *EtcdCreds) Create(ctx context.Context, rc *resource.Context) error

func (*EtcdCreds) Delete

func (c *EtcdCreds) Delete(ctx context.Context, rc *resource.Context) error

func (*EtcdCreds) Dependencies

func (c *EtcdCreds) Dependencies() []resource.Identifier

func (*EtcdCreds) DiffIgnore

func (c *EtcdCreds) DiffIgnore() []string

func (*EtcdCreds) Executor

func (c *EtcdCreds) Executor() resource.Executor

func (*EtcdCreds) Identifier

func (c *EtcdCreds) Identifier() resource.Identifier

func (*EtcdCreds) Refresh

func (c *EtcdCreds) Refresh(ctx context.Context, rc *resource.Context) error

func (*EtcdCreds) ResourceVersion

func (c *EtcdCreds) ResourceVersion() string

func (*EtcdCreds) TypeDependencies

func (c *EtcdCreds) TypeDependencies() []resource.Type

func (*EtcdCreds) Update

func (c *EtcdCreds) Update(ctx context.Context, rc *resource.Context) error

type GenerateOptions

type GenerateOptions struct {
	// SystemAddresses are IPs, hostnames, or CIDR ranges that pgedge or
	// patroni_replicator connections will originate from.
	SystemAddresses []string
	// ExtraHbaEntries are orchestrator-specific entries to include in the
	// pg_hba.conf.
	ExtraHbaEntries []hba.Entry
	// EnableFastBasebackup enables basebackup's "fast" checkpoint option when
	// bootstrapping this instance from another existing instance.
	EnableFastBasebackup bool
}

type PatroniCluster

type PatroniCluster struct {
	DatabaseID string `json:"database_id"`
	NodeName   string `json:"node_name"`
}

func (*PatroniCluster) Create

func (p *PatroniCluster) Create(ctx context.Context, rc *resource.Context) error

func (*PatroniCluster) Delete

func (p *PatroniCluster) Delete(ctx context.Context, rc *resource.Context) error

func (*PatroniCluster) Dependencies

func (p *PatroniCluster) Dependencies() []resource.Identifier

func (*PatroniCluster) DiffIgnore

func (p *PatroniCluster) DiffIgnore() []string

func (*PatroniCluster) Executor

func (p *PatroniCluster) Executor() resource.Executor

func (*PatroniCluster) Identifier

func (p *PatroniCluster) Identifier() resource.Identifier

func (*PatroniCluster) Refresh

func (p *PatroniCluster) Refresh(ctx context.Context, rc *resource.Context) error

func (*PatroniCluster) ResourceVersion

func (p *PatroniCluster) ResourceVersion() string

func (*PatroniCluster) TypeDependencies

func (p *PatroniCluster) TypeDependencies() []resource.Type

func (*PatroniCluster) Update

func (p *PatroniCluster) Update(ctx context.Context, rc *resource.Context) error

type PatroniConfig

type PatroniConfig struct {
	InstanceID string                  `json:"instance_id"`
	HostID     string                  `json:"host_id"`
	NodeName   string                  `json:"node_name"`
	Generator  *PatroniConfigGenerator `json:"generator"`
	ParentID   string                  `json:"parent_id"`
	OwnerUID   int                     `json:"owner_uid"`
	OwnerGID   int                     `json:"owner_gid"`
}

func (*PatroniConfig) Create

func (c *PatroniConfig) Create(
	ctx context.Context,
	rc *resource.Context,
	systemAddresses []string,
	extraHbaEntries []hba.Entry,
) error

func (*PatroniConfig) Delete

func (c *PatroniConfig) Delete(ctx context.Context, rc *resource.Context) error

func (*PatroniConfig) Dependencies

func (c *PatroniConfig) Dependencies() []resource.Identifier

func (*PatroniConfig) Refresh

func (c *PatroniConfig) Refresh(ctx context.Context, rc *resource.Context) error

func (*PatroniConfig) TypeDependencies

func (c *PatroniConfig) TypeDependencies() []resource.Type

type PatroniConfigGenerator

type PatroniConfigGenerator struct {
	// ArchiveCommand sets the Postgres archive command parameter.
	ArchiveCommand string `json:"archive_command,omitempty"`
	// ClusterSize is the number of nodes in the Spock cluster. This is used for
	// the tunable Postgres parameters.
	ClusterSize int `json:"cluster_size"`
	// CPUs is the number of CPUs allocated for this instance. This is used for
	// the tunable Postgres parameters.
	CPUs float64 `json:"cpus,omitempty"`
	// DatabaseID is the Database's ID.
	DatabaseID string `json:"database_id"`
	// DataDir is the Postgres data directory.
	DataDir string `json:"data_dir"`
	// EtcdCertsDir is the Etcd certificates directory.
	EtcdCertsDir string `json:"etcd_certs_dir"`
	// FQDN is the fully-qualified domain name for this instance. This name must
	// be reachable by sibling instances within the Spock node.
	FQDN string `json:"fqdn"`
	// InstanceID is this instance's ID.
	InstanceID string `json:"instance_id"`
	// LogType sets the Patroni log type.
	LogType patroni.LogType `json:"log_type"`
	// MemoryBytes is the amount of memory that is allocated for this instance.
	// This is used for the tunable Postgres parameters.
	MemoryBytes uint64 `json:"memory_bytes,omitempty"`
	// NodeName is the Spock node name.
	NodeName string `json:"node_name"`
	// NodeOrdinal is the ordinal part of the Spock node name, e.g. for 'n1'
	// this would be '1'. This is used to configure the Snowflake and LOLOR
	// extensions.
	NodeOrdinal int `json:"node_ordinal"`
	// OrchestratorParameters are additional parameters to be provided by the
	// orchestrator implementation.
	OrchestratorParameters map[string]any `json:"orchestrator_parameters,omitempty"`
	// PatroniAllowlist is a user-specified list of addresses, hostnames, or
	// CIDR ranges to include in the allowlist for Patroni's REST API.
	PatroniAllowlist []string `json:"patroni_allowlist"`
	// PatroniPort is the port that Patroni will listen on.
	PatroniPort int `json:"patroni_port"`
	// PostgresCertsDir is the Postgres certificates directory.
	PostgresCertsDir string `json:"postgres_certs_dir"`
	// PostgresPort is the port that Postgres will listen on.
	PostgresPort int `json:"postgres_port"`
	// RestoreCommand is an alternate command to use to bootstrap this instance.
	RestoreCommand string `json:"restore_command"`
	// SpecParameters are user-specified Postgres parameters that are included
	// in the database spec.
	SpecParameters map[string]any `json:"spec_parameters,omitempty"`
	// TenantID is an optional tenant ID that is associated with this instance.
	TenantID *string `json:"tenant_id,omitempty"`
}

func (*PatroniConfigGenerator) Generate

func (p *PatroniConfigGenerator) Generate(
	etcdHosts []string,
	etcdCreds *EtcdCreds,
	opts GenerateOptions,
) *patroni.Config

type PatroniConfigGeneratorOptions

type PatroniConfigGeneratorOptions struct {
	// Instance is the instance spec for this instance.
	Instance *database.InstanceSpec
	// HostCPUs is the total number of CPUs available on the host. This is used for
	// the tunable Postgres parameters.
	HostCPUs float64
	// HostMemoryBytes is the total amount of memory available on the host. This
	// is used for the tunable Postgres parameters.
	HostMemoryBytes uint64
	// FQDN is the fully-qualified domain name for this instance. This name must
	// be reachable by sibling instances within the Spock node.
	FQDN string
	// LogType sets the Patroni log type.
	LogType patroni.LogType
	// OrchestratorParameters are additional parameters to be provided by the
	// orchestrator implementation.
	OrchestratorParameters map[string]any
	// PatroniPort is the port that Patroni will listen on.
	PatroniPort int
	// PostgresPort is the port that Postgres will listen on.
	PostgresPort int
	// Paths is used to compute the paths of directories and executables.
	Paths database.InstancePaths
}

type PatroniMember

type PatroniMember struct {
	DatabaseID string `json:"database_id"`
	NodeName   string `json:"node_name"`
	InstanceID string `json:"instance_id"`
}

func (*PatroniMember) Create

func (p *PatroniMember) Create(ctx context.Context, rc *resource.Context) error

func (*PatroniMember) Delete

func (p *PatroniMember) Delete(ctx context.Context, rc *resource.Context) error

func (*PatroniMember) Dependencies

func (p *PatroniMember) Dependencies() []resource.Identifier

func (*PatroniMember) DiffIgnore

func (p *PatroniMember) DiffIgnore() []string

func (*PatroniMember) Executor

func (p *PatroniMember) Executor() resource.Executor

func (*PatroniMember) Identifier

func (p *PatroniMember) Identifier() resource.Identifier

func (*PatroniMember) Refresh

func (p *PatroniMember) Refresh(ctx context.Context, rc *resource.Context) error

func (*PatroniMember) ResourceVersion

func (p *PatroniMember) ResourceVersion() string

func (*PatroniMember) TypeDependencies

func (p *PatroniMember) TypeDependencies() []resource.Type

func (*PatroniMember) Update

func (p *PatroniMember) Update(ctx context.Context, rc *resource.Context) error

type PgBackRestConfig

type PgBackRestConfig struct {
	InstanceID   string                   `json:"instance_id"`
	HostID       string                   `json:"host_id"`
	DatabaseID   string                   `json:"database_id"`
	NodeName     string                   `json:"node_name"`
	Repositories []*pgbackrest.Repository `json:"repositories"`
	ParentID     string                   `json:"parent_id"`
	Type         pgbackrest.ConfigType    `json:"type"`
	OwnerUID     int                      `json:"owner_uid"`
	OwnerGID     int                      `json:"owner_gid"`
	Paths        database.InstancePaths   `json:"paths"`
	Port         int                      `json:"port"`
}

func (*PgBackRestConfig) BaseName

func (c *PgBackRestConfig) BaseName() string

func (*PgBackRestConfig) Create

func (c *PgBackRestConfig) Create(ctx context.Context, rc *resource.Context) error

func (*PgBackRestConfig) Delete

func (c *PgBackRestConfig) Delete(ctx context.Context, rc *resource.Context) error

func (*PgBackRestConfig) Dependencies

func (c *PgBackRestConfig) Dependencies() []resource.Identifier

func (*PgBackRestConfig) DiffIgnore

func (c *PgBackRestConfig) DiffIgnore() []string

func (*PgBackRestConfig) Executor

func (c *PgBackRestConfig) Executor() resource.Executor

func (*PgBackRestConfig) HostPath

func (c *PgBackRestConfig) HostPath(rc *resource.Context) (string, error)

func (*PgBackRestConfig) Identifier

func (c *PgBackRestConfig) Identifier() resource.Identifier

func (*PgBackRestConfig) Refresh

func (c *PgBackRestConfig) Refresh(ctx context.Context, rc *resource.Context) error

func (*PgBackRestConfig) ResourceVersion

func (c *PgBackRestConfig) ResourceVersion() string

func (*PgBackRestConfig) TypeDependencies

func (c *PgBackRestConfig) TypeDependencies() []resource.Type

func (*PgBackRestConfig) Update

func (c *PgBackRestConfig) Update(ctx context.Context, rc *resource.Context) error

type PgBackRestStanza

type PgBackRestStanza struct {
	DatabaseID string `json:"database_id"`
	NodeName   string `json:"node_name"`
}

func (*PgBackRestStanza) Create

func (p *PgBackRestStanza) Create(ctx context.Context, rc *resource.Context) error

func (*PgBackRestStanza) Delete

func (p *PgBackRestStanza) Delete(ctx context.Context, rc *resource.Context) error

func (*PgBackRestStanza) Dependencies

func (p *PgBackRestStanza) Dependencies() []resource.Identifier

func (*PgBackRestStanza) DiffIgnore

func (p *PgBackRestStanza) DiffIgnore() []string

func (*PgBackRestStanza) Executor

func (p *PgBackRestStanza) Executor() resource.Executor

func (*PgBackRestStanza) Identifier

func (p *PgBackRestStanza) Identifier() resource.Identifier

func (*PgBackRestStanza) Refresh

func (p *PgBackRestStanza) Refresh(ctx context.Context, rc *resource.Context) error

func (*PgBackRestStanza) ResourceVersion

func (p *PgBackRestStanza) ResourceVersion() string

func (*PgBackRestStanza) TypeDependencies

func (p *PgBackRestStanza) TypeDependencies() []resource.Type

func (*PgBackRestStanza) Update

func (p *PgBackRestStanza) Update(ctx context.Context, rc *resource.Context) error

type PgServiceConf

type PgServiceConf struct {
	ParentID   string   `json:"parent_id"`
	HostID     string   `json:"host_id"`
	InstanceID string   `json:"instance_id"`
	NodeNames  []string `json:"node_names"`
	OwnerUID   int      `json:"owner_uid"`
	OwnerGID   int      `json:"owner_gid"`
}

func (*PgServiceConf) Create

func (p *PgServiceConf) Create(ctx context.Context, rc *resource.Context) error

func (*PgServiceConf) Delete

func (p *PgServiceConf) Delete(ctx context.Context, rc *resource.Context) error

func (*PgServiceConf) Dependencies

func (p *PgServiceConf) Dependencies() []resource.Identifier

func (*PgServiceConf) DiffIgnore

func (p *PgServiceConf) DiffIgnore() []string

func (*PgServiceConf) Executor

func (p *PgServiceConf) Executor() resource.Executor

func (*PgServiceConf) Identifier

func (p *PgServiceConf) Identifier() resource.Identifier

func (*PgServiceConf) Refresh

func (p *PgServiceConf) Refresh(ctx context.Context, rc *resource.Context) error

func (*PgServiceConf) ResourceVersion

func (p *PgServiceConf) ResourceVersion() string

func (*PgServiceConf) TypeDependencies

func (p *PgServiceConf) TypeDependencies() []resource.Type

func (*PgServiceConf) Update

func (p *PgServiceConf) Update(ctx context.Context, rc *resource.Context) error

type PostgresCerts

type PostgresCerts struct {
	InstanceID        string   `json:"instance_id"`
	HostID            string   `json:"host_id"`
	InstanceAddresses []string `json:"instance_addresses"`
	ParentID          string   `json:"parent_id"`
	OwnerUID          int      `json:"owner_uid"`
	OwnerGID          int      `json:"owner_gid"`
	CaCert            []byte   `json:"ca_cert"`
	ServerCert        []byte   `json:"server_cert"`
	ServerKey         []byte   `json:"server_key"`
	SuperuserCert     []byte   `json:"superuser_cert"`
	SuperuserKey      []byte   `json:"superuser_key"`
	ReplicationCert   []byte   `json:"replication_cert"`
	ReplicationKey    []byte   `json:"replication_key"`
}

func (*PostgresCerts) Create

func (c *PostgresCerts) Create(ctx context.Context, rc *resource.Context) error

func (*PostgresCerts) Delete

func (c *PostgresCerts) Delete(ctx context.Context, rc *resource.Context) error

func (*PostgresCerts) Dependencies

func (c *PostgresCerts) Dependencies() []resource.Identifier

func (*PostgresCerts) DiffIgnore

func (c *PostgresCerts) DiffIgnore() []string

func (*PostgresCerts) Executor

func (c *PostgresCerts) Executor() resource.Executor

func (*PostgresCerts) Identifier

func (c *PostgresCerts) Identifier() resource.Identifier

func (*PostgresCerts) Refresh

func (c *PostgresCerts) Refresh(ctx context.Context, rc *resource.Context) error

func (*PostgresCerts) ResourceVersion

func (c *PostgresCerts) ResourceVersion() string

func (*PostgresCerts) TypeDependencies

func (c *PostgresCerts) TypeDependencies() []resource.Type

func (*PostgresCerts) Update

func (c *PostgresCerts) Update(ctx context.Context, rc *resource.Context) error

Jump to

Keyboard shortcuts

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