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 ¶
- Constants
- func AdditionalConfigVolumeMount() corev1.VolumeMount
- func ConfigDirectory(cluster *v1beta1.IvoryCluster) string
- func CreateDatabasesInIvorySQL(ctx context.Context, exec Executor, databases []string) error
- func DataDirectory(cluster *v1beta1.IvoryCluster) string
- func DataVolumeMount() corev1.VolumeMount
- func DownwardAPIVolumeMount() corev1.VolumeMount
- func Environment(cluster *v1beta1.IvoryCluster) []corev1.EnvVar
- func InstancePod(ctx context.Context, inCluster *v1beta1.IvoryCluster, ...)
- func PodSecurityContext(cluster *v1beta1.IvoryCluster) *corev1.PodSecurityContext
- func SetHugePages(cluster *v1beta1.IvoryCluster, pgParameters *Parameters)
- func TablespaceVolumeMount(tablespaceName string) corev1.VolumeMount
- func WALDirectory(cluster *v1beta1.IvoryCluster, instance *v1beta1.IvoryInstanceSetSpec) string
- func WALVolumeMount() corev1.VolumeMount
- func WriteUsersInIvorySQL(ctx context.Context, exec Executor, users []v1beta1.IvoryUserSpec, ...) error
- type Executor
- func (exec Executor) Exec(ctx context.Context, sql io.Reader, variables map[string]string) (string, string, error)
- func (exec Executor) ExecInAllDatabases(ctx context.Context, sql string, variables map[string]string) (string, string, error)
- func (exec Executor) ExecInDatabasesFromQuery(ctx context.Context, databases, sql string, variables map[string]string) (string, string, error)
- type HBAs
- type HostBasedAuthentication
- func (hba *HostBasedAuthentication) AllDatabases() *HostBasedAuthentication
- func (hba *HostBasedAuthentication) AllNetworks() *HostBasedAuthentication
- func (hba *HostBasedAuthentication) AllUsers() *HostBasedAuthentication
- func (hba *HostBasedAuthentication) Database(name string) *HostBasedAuthentication
- func (hba *HostBasedAuthentication) Local() *HostBasedAuthentication
- func (hba *HostBasedAuthentication) Method(name string) *HostBasedAuthentication
- func (hba *HostBasedAuthentication) Network(block string) *HostBasedAuthentication
- func (hba *HostBasedAuthentication) NoSSL() *HostBasedAuthentication
- func (hba *HostBasedAuthentication) Options(opts map[string]string) *HostBasedAuthentication
- func (hba *HostBasedAuthentication) Replication() *HostBasedAuthentication
- func (hba *HostBasedAuthentication) Role(name string) *HostBasedAuthentication
- func (hba *HostBasedAuthentication) SameNetwork() *HostBasedAuthentication
- func (hba HostBasedAuthentication) String() string
- func (hba *HostBasedAuthentication) TCP() *HostBasedAuthentication
- func (hba *HostBasedAuthentication) TLS() *HostBasedAuthentication
- func (hba *HostBasedAuthentication) User(name string) *HostBasedAuthentication
- type ParameterSet
- func (ps *ParameterSet) Add(name, value string)
- func (ps ParameterSet) AsMap() map[string]string
- func (ps *ParameterSet) DeepCopy() (out *ParameterSet)
- func (ps ParameterSet) Get(name string) (string, bool)
- func (ps ParameterSet) Has(name string) bool
- func (ps ParameterSet) Value(name string) string
- type Parameters
Examples ¶
Constants ¶
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" )
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 ¶
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.
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 ¶
func (hba *HostBasedAuthentication) AllNetworks() *HostBasedAuthentication
AllNetworks makes hba match connection attempts made from any IP address.
func (*HostBasedAuthentication) AllUsers ¶
func (hba *HostBasedAuthentication) AllUsers() *HostBasedAuthentication
AllUsers makes hba match connections made by any user.
func (*HostBasedAuthentication) Database ¶
func (hba *HostBasedAuthentication) Database(name string) *HostBasedAuthentication
Database makes hba match connections made to a specific database.
func (*HostBasedAuthentication) Local ¶
func (hba *HostBasedAuthentication) Local() *HostBasedAuthentication
Local makes hba match connection attempts using Unix-domain sockets.
func (*HostBasedAuthentication) Method ¶
func (hba *HostBasedAuthentication) Method(name string) *HostBasedAuthentication
Method specifies the authentication method to use when a connection matches hba.
func (*HostBasedAuthentication) Network ¶
func (hba *HostBasedAuthentication) Network(block string) *HostBasedAuthentication
Network makes hba match connection attempts from a block of IP addresses in CIDR notation.
func (*HostBasedAuthentication) NoSSL ¶
func (hba *HostBasedAuthentication) NoSSL() *HostBasedAuthentication
NoSSL makes hba match connection attempts made over TCP/IP without SSL.
func (*HostBasedAuthentication) Options ¶
func (hba *HostBasedAuthentication) Options(opts map[string]string) *HostBasedAuthentication
Options specifies any options for the authentication method.
func (*HostBasedAuthentication) Replication ¶
func (hba *HostBasedAuthentication) Replication() *HostBasedAuthentication
Replication makes hba match physical replication connections.
func (*HostBasedAuthentication) Role ¶
func (hba *HostBasedAuthentication) Role(name string) *HostBasedAuthentication
Role makes hba match connections by users that are members of a specific role.
func (*HostBasedAuthentication) SameNetwork ¶
func (hba *HostBasedAuthentication) SameNetwork() *HostBasedAuthentication
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 ¶
func (hba *HostBasedAuthentication) TCP() *HostBasedAuthentication
TCP makes hba match connection attempts made using TCP/IP, with or without SSL.
func (*HostBasedAuthentication) TLS ¶
func (hba *HostBasedAuthentication) TLS() *HostBasedAuthentication
TLS makes hba match connection attempts made using TCP/IP with TLS.
func (*HostBasedAuthentication) User ¶
func (hba *HostBasedAuthentication) User(name string) *HostBasedAuthentication
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.