ivory

package
v0.0.0-...-30d1bac Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package ivory is a collection of resources that interact with IvorySQL or provide functionality that makes it easier for other resources to interact with IvorySQL.

Index

Examples

Constants

View Source
const (

	// SocketDirectory is where to bind and connect to UNIX sockets.
	SocketDirectory = "/tmp/postgres"

	// ReplicationUser is the IvorySQL role that will be created by Patroni
	// for streaming replication and for `pg_rewind`.
	ReplicationUser = "_ivoryrepl"
)
View Source
const (
	// IANAPortNumber is the port assigned to IvorySQL at the IANA.
	IANAPortNumber = 5432

	// IANAServiceName is the name of the IvorySQL protocol at the IANA.
	IANAServiceName = "ivorysql"
)

The protocol used by IvorySQL is registered with the Internet Assigned Numbers Authority (IANA). - https://www.iana.org/assignments/service-names-port-numbers

Variables

This section is empty.

Functions

func AdditionalConfigVolumeMount

func AdditionalConfigVolumeMount() corev1.VolumeMount

AdditionalConfigVolumeMount returns the name and mount path of the additional config files.

func ConfigDirectory

func ConfigDirectory(cluster *v1beta1.IvoryCluster) string

ConfigDirectory returns the absolute path to $IVYDATA for cluster. - https://www.ivorysql.org/docs/current/runtime-config-file-locations.html

func CreateDatabasesInIvorySQL

func CreateDatabasesInIvorySQL(
	ctx context.Context, exec Executor, databases []string,
) error

CreateDatabasesInIvorySQL calls exec to create databases that do not exist in IvorySQL.

func DataDirectory

func DataDirectory(cluster *v1beta1.IvoryCluster) string

DataDirectory returns the absolute path to the "data_directory" of cluster. - https://www.postgresql.org/docs/current/runtime-config-file-locations.html

func DataVolumeMount

func DataVolumeMount() corev1.VolumeMount

DataVolumeMount returns the name and mount path of the IvorySQL data volume.

func DownwardAPIVolumeMount

func DownwardAPIVolumeMount() corev1.VolumeMount

DownwardAPIVolumeMount returns the name and mount path of the DownwardAPI volume.

func Environment

func Environment(cluster *v1beta1.IvoryCluster) []corev1.EnvVar

Environment returns the environment variables required to invoke IvorySQL utilities.

func InstancePod

func InstancePod(ctx context.Context,
	inCluster *v1beta1.IvoryCluster,
	inInstanceSpec *v1beta1.IvoryInstanceSetSpec,
	inClusterCertificates, inClientCertificates *corev1.SecretProjection,
	inDataVolume, inWALVolume *corev1.PersistentVolumeClaim,
	inTablespaceVolumes []*corev1.PersistentVolumeClaim,
	outInstancePod *corev1.PodSpec,
)

InstancePod initializes outInstancePod with the database container and the volumes needed by IvorySQL.

func PodSecurityContext

func PodSecurityContext(cluster *v1beta1.IvoryCluster) *corev1.PodSecurityContext

PodSecurityContext returns a v1.PodSecurityContext for cluster that can write to PersistentVolumes.

func SetHugePages

func SetHugePages(cluster *v1beta1.IvoryCluster, pgParameters *Parameters)

This function looks for a valid huge_pages resource request. If it finds one, it sets the IvorySQL parameter "huge_pages" to "try". If it doesn't find one, it sets "huge_pages" to "off".

func TablespaceVolumeMount

func TablespaceVolumeMount(tablespaceName string) corev1.VolumeMount

TablespaceVolumeMount returns the name and mount path of the IvorySQL tablespace data volume.

func WALDirectory

func WALDirectory(
	cluster *v1beta1.IvoryCluster, instance *v1beta1.IvoryInstanceSetSpec,
) string

WALDirectory returns the absolute path to the directory where an instance stores its WAL files. - https://www.postgresql.org/docs/current/wal.html

func WALVolumeMount

func WALVolumeMount() corev1.VolumeMount

WALVolumeMount returns the name and mount path of the IvorySQL WAL volume.

func WriteUsersInIvorySQL

func WriteUsersInIvorySQL(
	ctx context.Context, exec Executor,
	users []v1beta1.IvoryUserSpec, verifiers map[string]string,
) error

WriteUsersInIvorySQL calls exec to create users that do not exist in IvorySQL. Once they exist, it updates their options and passwords and grants them access to their specified databases. The databases must already exist.

Types

type Executor

type Executor func(
	ctx context.Context, stdin io.Reader, stdout, stderr io.Writer, command ...string,
) error

Executor provides methods for calling "psql".

Example (ExecCmd)

This example demonstrates how Executor can work with exec.Cmd.

_ = Executor(func(
	ctx context.Context, stdin io.Reader, stdout, stderr io.Writer, command ...string,
) error {
	// #nosec G204 Nothing calls the function defined in this example.
	cmd := exec.CommandContext(ctx, command[0], command[1:]...)
	cmd.Stdin, cmd.Stdout, cmd.Stderr = stdin, stdout, stderr
	return cmd.Run()
})
Output:

func (Executor) Exec

func (exec Executor) Exec(
	ctx context.Context, sql io.Reader, variables map[string]string,
) (string, string, error)

Exec uses "psql" to execute sql. The sql statement(s) are passed via stdin and may contain psql variables that are assigned from the variables map. - https://www.ivorysql.org/docs/current/app-psql.html#APP-PSQL-VARIABLES

func (Executor) ExecInAllDatabases

func (exec Executor) ExecInAllDatabases(
	ctx context.Context, sql string, variables map[string]string,
) (string, string, error)

ExecInAllDatabases uses "bash" and "psql" to execute sql in every database that allows connections, including templates. The sql command(s) may contain psql variables that are assigned from the variables map. - https://www.ivorysql.org/docs/current/app-psql.html#APP-PSQL-VARIABLES

func (Executor) ExecInDatabasesFromQuery

func (exec Executor) ExecInDatabasesFromQuery(
	ctx context.Context, databases, sql string, variables map[string]string,
) (string, string, error)

ExecInDatabasesFromQuery uses "bash" and "psql" to execute sql in every database returned by the databases query. The sql statement(s) may contain psql variables that are assigned from the variables map. - https://www.ivorysql.org/docs/current/app-psql.html#APP-PSQL-VARIABLES

type HBAs

type HBAs struct{ Mandatory, Default []HostBasedAuthentication }

HBAs is a pairing of HostBasedAuthentication records.

func NewHBAs

func NewHBAs() HBAs

NewHBAs returns HostBasedAuthentication records required by this package.

type HostBasedAuthentication

type HostBasedAuthentication struct {
	// contains filtered or unexported fields
}

HostBasedAuthentication represents a single record for pg_hba.conf. - https://www.ivorysql.org/docs/current/auth-pg-hba-conf.html

func NewHBA

func NewHBA() *HostBasedAuthentication

NewHBA returns an HBA record that matches all databases, networks, and users.

func (*HostBasedAuthentication) AllDatabases

func (hba *HostBasedAuthentication) AllDatabases() *HostBasedAuthentication

AllDatabases makes hba match connections made to any database.

func (*HostBasedAuthentication) AllNetworks

AllNetworks makes hba match connection attempts made from any IP address.

func (*HostBasedAuthentication) AllUsers

AllUsers makes hba match connections made by any user.

func (*HostBasedAuthentication) Database

Database makes hba match connections made to a specific database.

func (*HostBasedAuthentication) Local

Local makes hba match connection attempts using Unix-domain sockets.

func (*HostBasedAuthentication) Method

Method specifies the authentication method to use when a connection matches hba.

func (*HostBasedAuthentication) Network

Network makes hba match connection attempts from a block of IP addresses in CIDR notation.

func (*HostBasedAuthentication) NoSSL

NoSSL makes hba match connection attempts made over TCP/IP without SSL.

func (*HostBasedAuthentication) Options

Options specifies any options for the authentication method.

func (*HostBasedAuthentication) Replication

Replication makes hba match physical replication connections.

func (*HostBasedAuthentication) Role

Role makes hba match connections by users that are members of a specific role.

func (*HostBasedAuthentication) SameNetwork

SameNetwork makes hba match connection attempts from IP addresses in any subnet to which the server is directly connected.

func (HostBasedAuthentication) String

func (hba HostBasedAuthentication) String() string

String returns hba formatted for the pg_hba.conf file without a newline.

func (*HostBasedAuthentication) TCP

TCP makes hba match connection attempts made using TCP/IP, with or without SSL.

func (*HostBasedAuthentication) TLS

TLS makes hba match connection attempts made using TCP/IP with TLS.

func (*HostBasedAuthentication) User

User makes hba match connections by a specific user.

type ParameterSet

type ParameterSet struct {
	// contains filtered or unexported fields
}

ParameterSet is a collection of IvorySQL parameters. - https://www.ivorysql.org/docs/current/config-setting.html

func NewParameterSet

func NewParameterSet() *ParameterSet

NewParameterSet returns an empty ParameterSet.

func (*ParameterSet) Add

func (ps *ParameterSet) Add(name, value string)

Add sets parameter name to value.

func (ParameterSet) AsMap

func (ps ParameterSet) AsMap() map[string]string

AsMap returns a copy of ps as a map.

func (*ParameterSet) DeepCopy

func (ps *ParameterSet) DeepCopy() (out *ParameterSet)

DeepCopy returns a copy of ps.

func (ParameterSet) Get

func (ps ParameterSet) Get(name string) (string, bool)

Get returns the value of parameter name and whether or not it was present in ps.

func (ParameterSet) Has

func (ps ParameterSet) Has(name string) bool

Has returns whether or not parameter name is present in ps.

func (ParameterSet) Value

func (ps ParameterSet) Value(name string) string

Value returns empty string or the value of parameter name if it is present in ps.

type Parameters

type Parameters struct{ Mandatory, Default *ParameterSet }

Parameters is a pairing of ParameterSets.

func NewParameters

func NewParameters() Parameters

NewParameters returns ParameterSets required by this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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