Documentation
¶
Overview ¶
Package config contains the configuration data structure and the relative helpers
Index ¶
- Variables
- func DecryptEncryptionKeyFile(encryptionKeyFile, identityFile string) (string, error)
- func IsValidCompressionAlgorithm(algorithm string) bool
- func ValidateCompressionSettings(algorithm string, minSize, maxSize int64) error
- type BaseRepositoryClientConfig
- type BaseServerConfig
- type ClientConfig
- type CompressionPolicy
- type Data
- type EmptyDecodedEncryptionKeyError
- type RetentionPolicy
- type S3Configuration
- type ServerConfig
- type SourceConfig
- type TLSConfig
- type Tier1Config
- type Tier2Config
- type WALPrefetchConfig
- type WalRepositoryClientConfig
- type WalServerConfig
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidCompressionAlgorithm = errors.New("invalid compression algorithm")
ErrInvalidCompressionAlgorithm is returned when an unsupported compression algorithm is configured.
var ErrInvalidCompressionSizeRange = errors.New("invalid compression size range")
ErrInvalidCompressionSizeRange is returned when the configured compression size bounds exclude every file.
var ErrMissingTier2Configuration = errors.New(
"tier2 is disabled, s3 configuration is missing")
ErrMissingTier2Configuration is raised when no tier2 backend has been configured.
Functions ¶
func DecryptEncryptionKeyFile ¶
DecryptEncryptionKeyFile decrypts an Age-encrypted encryption key file using the provided Age identity file.
The permissions of the identity file are not checked: a CSI driver decides them and cannot yet apply the pod fsGroup to them (https://github.com/kubernetes-sigs/secrets-store-csi-driver/pull/1841).
func IsValidCompressionAlgorithm ¶
IsValidCompressionAlgorithm returns true when the passed algorithm is a supported Kopia compression algorithm. The list matches the compressors registered by Kopia, plus the special value "none" that explicitly disables compression. It must be kept in sync with the CompressionAlgorithm enum in the operator CRD types.
func ValidateCompressionSettings ¶
ValidateCompressionSettings checks a compression algorithm together with its size bounds. An empty algorithm is valid and means the Kopia default (inherited) policy is left untouched. The size bounds are validated even when no algorithm is set, because they are applied independently of it.
It is shared by CompressionPolicy's own Validate and the server config's client_validate/server_validate call sites.
Types ¶
type BaseRepositoryClientConfig ¶
type BaseRepositoryClientConfig struct {
// URL is the base URL where the Tier 1 Kopia API server should be reached
URL string `json:"url" mapstructure:"url"`
// URL is the base URL where the Tier 2 Kopia API server should be reached
Tier2URL string `json:"tier2_url" mapstructure:"tier2_url"`
// ServerCertPath is the path to the PEM file with the CA certificate(s)
// the Kopia server certificate must chain to. It is passed to
// `kopia repository connect server` via --server-cert-ca-file.
ServerCertPath string `json:"server_cert_path" mapstructure:"server_cert_path"`
// ClientCertPath is the path to the client public key
ClientCertPath string `json:"client_cert_path" mapstructure:"client_cert_path"`
// ClientKeyPath is the path to the client private key
ClientKeyPath string `json:"client_key_path" mapstructure:"client_key_path"`
}
BaseRepositoryClientConfig is the configuration of the Kopia repository to be used to upload the data directory.
func (*BaseRepositoryClientConfig) Validate ¶
func (c *BaseRepositoryClientConfig) Validate() error
Validate implements a custom validation function for BaseRepositoryClientConfig.
type BaseServerConfig ¶
type BaseServerConfig struct {
// CacheDirectory is the directory of the Kopia cache
CacheDirectory string `mapstructure:"cache"`
// RepositoryDirectory is the directory where the Kopia repository is stored.
RepositoryDirectory string `mapstructure:"repository"`
// ListenAddress is the address where we should listen to
ListenAddress string `mapstructure:"listen_address"`
}
BaseServerConfig is the configuration that will be used for the kopia server.
func (*BaseServerConfig) Validate ¶
func (c *BaseServerConfig) Validate() error
Validate implements a custom validation function for BaseServerConfig.
type ClientConfig ¶
type ClientConfig struct {
// ClusterName is the name of the PostgreSQL cluster.
// This must match the hostname portion of the client certificate's Common Name
// (format: userName@clusterName).
ClusterName string `json:"cluster_name" mapstructure:"cluster_name"`
// Base is the configuration of the target Base repository
Base BaseRepositoryClientConfig `json:"base" mapstructure:"base"`
// Wal is the configuration of the Wal repository
Wal WalRepositoryClientConfig `json:"wal" mapstructure:"wal"`
}
ClientConfig is the configuration of the Klio client.
func (*ClientConfig) Validate ¶
func (c *ClientConfig) Validate() error
Validate implements a custom validation function for ClientConfig.
type CompressionPolicy ¶
type CompressionPolicy struct {
// Algorithm is the name of the Kopia compression algorithm to use.
// The special value "none" disables compression.
Algorithm string `json:"algorithm,omitempty" mapstructure:"algorithm"`
// MinSize is the minimum file size, in bytes, to attempt compression for.
// Files smaller than this are stored uncompressed. Zero means no minimum.
MinSize int64 `json:"min_size,omitempty" mapstructure:"min_size"`
// MaxSize is the maximum file size, in bytes, to attempt compression for.
// Files larger than this are stored uncompressed. Zero means no maximum.
MaxSize int64 `json:"max_size,omitempty" mapstructure:"max_size"`
}
CompressionPolicy configures the Kopia compression policy applied to base backup data.
func (*CompressionPolicy) Validate ¶
func (c *CompressionPolicy) Validate() error
Validate checks that the configured compression algorithm is supported and that the size bounds are consistent. A nil policy is considered valid and means the Kopia default (inherited) policy is left untouched.
type Data ¶
type Data struct {
// Source is the configuration of the database we should collect WALs for.
// This is only needed for the WAL pusher.
Source SourceConfig `json:"source" mapstructure:"source"`
// Client is the configuration of the Klio client
Client ClientConfig `json:"client" mapstructure:"client"`
// Tier1RetentionPolicy is the retention policy to be applied to tier1.
Tier1RetentionPolicy *RetentionPolicy `json:"tier1_retention,omitempty" mapstructure:"tier1_retention"`
// Tier2RetentionPolicy is the retention policy to be applied to tier2.
Tier2RetentionPolicy *RetentionPolicy `json:"tier2_retention,omitempty" mapstructure:"tier2_retention"`
// Tier1CompressionPolicy is the compression policy to be applied to tier1.
Tier1CompressionPolicy *CompressionPolicy `json:"tier1_compression,omitempty" mapstructure:"tier1_compression"`
// Tier2CompressionPolicy is the compression policy to be applied to tier2.
Tier2CompressionPolicy *CompressionPolicy `json:"tier2_compression,omitempty" mapstructure:"tier2_compression"`
// Tier1Enabled records whether the client archives base backups and WAL
// to tier1. False on read-only clients, which do not write to tier1 but
// may still restore from it when Client.Wal.Address is set. Not consulted
// on the restore path: tier1 restore eligibility is derived from
// Client.Wal.Address presence alone.
Tier1Enabled bool `json:"tier1_enabled,omitempty" mapstructure:"tier1_enabled"`
// Tier2BackupEnabled records the user's intent to push base backups
// and WAL files to tier2. It gates the backup path only.
Tier2BackupEnabled bool `json:"tier2_backup_enabled,omitempty" mapstructure:"tier2_backup_enabled"`
// Tier2RecoveryEnabled records the user's intent to use tier2 as a
// recovery source. Restore must check this flag before falling back
// to tier2: address presence alone is not sufficient, because the
// operator populates Client.Wal.Tier2Address whenever tier2 is
// enabled for backup OR recovery.
Tier2RecoveryEnabled bool `json:"tier2_recovery_enabled,omitempty" mapstructure:"tier2_recovery_enabled"`
// WALPrefetch is the WAL prefetching configuration.
WALPrefetch WALPrefetchConfig `json:"wal_prefetch" mapstructure:"wal_prefetch"`
}
Data is the configuration.
This struct is used to generate a secret in the Kubernetes cluster, so its serialization must be stable.
func DecodeYAML ¶
DecodeYAML decodes YAML data into a Data struct using mapstructure. This ensures consistent behavior with Viper by respecting mapstructure tags.
func NewFromFile ¶
NewFromFile loads the configuration from a YAML file at the given path.
func (*Data) SetDefaults ¶
func (d *Data) SetDefaults()
SetDefaults sets the default values of the configuration.
type EmptyDecodedEncryptionKeyError ¶
type EmptyDecodedEncryptionKeyError struct {
// contains filtered or unexported fields
}
EmptyDecodedEncryptionKeyError is raised when the encryption key file exists but contains no key after decoding.
func (*EmptyDecodedEncryptionKeyError) Error ¶
func (e *EmptyDecodedEncryptionKeyError) Error() string
type RetentionPolicy ¶
type RetentionPolicy struct {
// Latest is the number of latest backups to keep. Zero disables
// retention: every backup is kept, the same as leaving this policy unset.
Latest *int32 `json:"latest,omitempty" mapstructure:"latest"`
}
RetentionPolicy defines how many backups we should keep.
type S3Configuration ¶
type S3Configuration struct {
// Enabled is true when S3 is enabled
Enabled bool `json:"enabled" mapstructure:"enabled"`
// BucketName is the name of the bucket
BucketName string `json:"bucket_name" mapstructure:"bucket_name"`
// Endpoint is the AWS endpoint to be used
Endpoint string `json:"endpoint" mapstructure:"endpoint"`
// Region is the AWS region to be used.
Region string `json:"region" mapstructure:"region"`
// Prefix is the path within the bucket under which all Klio objects
// are stored, allowing a single bucket to be shared across multiple deployments.
Prefix string `json:"prefix" mapstructure:"prefix"`
// AccessKeyID is the access key ID
AccessKeyID string `json:"access_key_id" mapstructure:"access_key_id"`
// SecretAccessKey is the secret access key
SecretAccessKey string `json:"secret_access_key" mapstructure:"secret_access_key"`
// SessionToken is the session token
SessionToken string `json:"session_token" mapstructure:"session_token"`
// CustomCABundleFile is the file where we should read the custom CA bundle
CustomCABundleFile string `json:"custom_ca_bundle_file" mapstructure:"custom_ca_bundle_file"`
}
S3Configuration is the configuration to a S3 defined tier 2.
func (*S3Configuration) Validate ¶
func (c *S3Configuration) Validate() error
Validate implements a custom validation function for S3Configuration.
type ServerConfig ¶
type ServerConfig struct {
// TLS is the TLS configuration of the base and of the WAL
// server
TLS TLSConfig `mapstructure:"tls"`
// Tier1Config is the Tier 1 configuration
Tier1 Tier1Config `mapstructure:"tier1"`
// Tier2Config is the Tier 2 configuration
Tier2 Tier2Config `mapstructure:"tier2"`
// QueueDirectory is the directory where the persistent queue
// messages will be stored.
QueueDirectory string `mapstructure:"queue_directory"`
}
ServerConfig is the configuration of the Klio server.
func (*ServerConfig) RequireTier1 ¶
func (c *ServerConfig) RequireTier1() error
RequireTier1 checks if the configuration settings for tier1 are correctly set.
func (*ServerConfig) RequireTier2 ¶
func (c *ServerConfig) RequireTier2() error
RequireTier2 checks if the configuration settings for tier2 are correctly set.
func (*ServerConfig) Validate ¶
func (c *ServerConfig) Validate() error
Validate implements a custom validation function for ClientConfig.
type SourceConfig ¶
type SourceConfig struct {
// DSN is the database service we should get the WALs from
DSN string `json:"dsn" mapstructure:"dsn"`
// StandardDSN is the database service name to be used for a standard
// database connection
StandardDSN string `json:"standard_dsn" mapstructure:"standard_dsn"`
// Slot is the name of the replication slot to be used
Slot string `json:"slot" mapstructure:"slot"`
// BufferSize is the maximum size in bytes of the in-memory WAL buffer before
// triggering an automatic flush
BufferSize int `json:"buffer_size" mapstructure:"buffer_size"`
}
SourceConfig is the configuration of the WAL receiver.
func (*SourceConfig) SetDefaults ¶
func (s *SourceConfig) SetDefaults()
SetDefaults sets the default values of the configuration.
func (*SourceConfig) Validate ¶
func (s *SourceConfig) Validate() error
Validate implements a custom validation function for SourceConfig.
type TLSConfig ¶
type TLSConfig struct {
// TLSCert is the path to the server public key
TLSCert string `json:"tls_cert" mapstructure:"cert"`
// TLSKey is the path to the server private key
TLSKey string `json:"tls_key" mapstructure:"key"`
// ClientCACertFile is the file containing the CA certificate to be used
// to verify client certificates
ClientCACertFile string `json:"client_ca_cert" mapstructure:"client_ca_cert"`
}
TLSConfig is the TLS configuration of the server.
type Tier1Config ¶
type Tier1Config struct {
// EncryptionKeyFile is the path to the file containing the encryption
// key used to operate on the Kopia repository and on the WAL directory.
// When IdentityFile is set, this file is Age-encrypted and will be
// decrypted at startup. Otherwise it is read as plaintext.
EncryptionKeyFile string `mapstructure:"encryption_key_file"`
// IdentityFile is the path to the Age identity file used to decrypt
// the encryption key file. When empty, EncryptionKeyFile is read as
// plaintext.
IdentityFile string `mapstructure:"identity_file"`
// EncryptionKey is the encryption key loaded from EncryptionKeyFile at startup.
// Populated by LoadEncryptionKey; not read from configuration.
EncryptionKey string `mapstructure:"-"`
// Base is the configuration of the Base server
Base BaseServerConfig `mapstructure:"base"`
// Wal is the configuration of the Wal server
Wal WalServerConfig `mapstructure:"wal"`
// Compression is the repository-wide (global) compression policy applied
// to base backups stored on tier1. When empty, the Kopia default (no
// compression) is left untouched.
Compression CompressionPolicy `mapstructure:"compression"`
}
Tier1Config is the configuration of tier 1.
func (*Tier1Config) LoadEncryptionKey ¶
func (c *Tier1Config) LoadEncryptionKey() error
LoadEncryptionKey reads and decrypts the encryption key from EncryptionKeyFile and populates the EncryptionKey field. Must be called at startup before any component accesses EncryptionKey.
func (*Tier1Config) Validate ¶
func (c *Tier1Config) Validate() error
Validate implements a custom validation function for Tier1Config.
type Tier2Config ¶
type Tier2Config struct {
// EncryptionKeyFile is the path to the file containing the encryption key.
// When IdentityFile is set, this file is Age-encrypted and will be
// decrypted at startup. Otherwise it is read as plaintext.
EncryptionKeyFile string `mapstructure:"encryption_key_file"`
// IdentityFile is the path to the Age identity file used to decrypt
// the encryption key file. When empty, EncryptionKeyFile is read as
// plaintext.
IdentityFile string `mapstructure:"identity_file"`
// EncryptionKey is the encryption key loaded from EncryptionKeyFile at startup.
// Populated by LoadEncryptionKey; not read from configuration.
EncryptionKey string `mapstructure:"-"`
// BaseListenAddress is the address where the tier2 base server will listen
BaseListenAddress string `mapstructure:"base_listen_address"`
// WALListenAddress is the address where the tier2 wal server will listen
WALListenAddress string `mapstructure:"wal_listen_address"`
// CacheDirectory is the directory of the Kopia cache
CacheDirectory string `mapstructure:"cache"`
// Compression is the repository-wide (global) compression policy applied
// to base backups stored on tier2. When empty, the Kopia default (no
// compression) is left untouched.
Compression CompressionPolicy `mapstructure:"compression"`
// S3 contains the configuration parameters for an S3-based tier 2
S3 S3Configuration `json:"s3" mapstructure:"s3"`
}
Tier2Config is the configuration of tier 2.
func (*Tier2Config) LoadEncryptionKey ¶
func (c *Tier2Config) LoadEncryptionKey() error
LoadEncryptionKey reads and decrypts the encryption key from EncryptionKeyFile and populates the EncryptionKey field. Must be called at startup before any component accesses EncryptionKey.
func (*Tier2Config) Validate ¶
func (c *Tier2Config) Validate() error
Validate implements a custom validation function for Tier2Config.
type WALPrefetchConfig ¶
type WALPrefetchConfig struct {
// Count is the number of WAL files to prefetch ahead during recovery.
Count int `json:"count" mapstructure:"count"`
// MaxConcurrentDownloads is the maximum number of concurrent WAL downloads.
MaxConcurrentDownloads int `json:"max_concurrent_downloads" mapstructure:"max_concurrent_downloads"`
}
WALPrefetchConfig configures WAL prefetching during recovery.
type WalRepositoryClientConfig ¶
type WalRepositoryClientConfig struct {
// Address of the Tier 1 Klio server
Address string `json:"address" mapstructure:"address"`
// Address of the Tier 2 Klio server
Tier2Address string `json:"tier2_address" mapstructure:"tier2_address"`
// ServerCertPath is the path to the PEM file with the CA certificate(s)
// the Klio server certificate must chain to. It is used to verify the
// server for WAL streaming (gRPC RootCAs).
ServerCertPath string `json:"server_cert_path" mapstructure:"server_cert_path"`
// ClientCertPath is the path to the client public key
ClientCertPath string `json:"client_cert_path" mapstructure:"client_cert_path"`
// ClientKeyPath is the path to the client private key
ClientKeyPath string `json:"client_key_path" mapstructure:"client_key_path"`
}
WalRepositoryClientConfig is the configuration of the Klio repository where WALs should be uploaded.
func (*WalRepositoryClientConfig) Validate ¶
func (c *WalRepositoryClientConfig) Validate() error
Validate implements a custom validation function for WalRepositoryClientConfig.
type WalServerConfig ¶
type WalServerConfig struct {
// ListenAddress is the listening address
ListenAddress string `json:"listen_address" mapstructure:"listen_address"`
// WALPath is the path where the WALs should be stored
WALPath string `json:"path" mapstructure:"path"`
}
WalServerConfig is the configuration of the Klio server.
func (*WalServerConfig) Validate ¶
func (c *WalServerConfig) Validate() error
Validate implements a custom validation function for WalServerConfig.