infra

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConsulClient

func GetConsulClient(environment string) *api.Client

func NewConsulBackupExecutor

func NewConsulBackupExecutor(
	nodeID string,
	kv ConsulKV,
	encryptionKey []byte,
	backupDir string,
	uploader ...ConsulBackupUploader,
) *consulBackupExecutor

NewConsulBackupExecutor creates a backup executor for the Consul KV store. It exports all keys under every managed prefix, encrypts with AES-256-GCM, writes locally overwriting the same file, and optionally uploads to remote storage (e.g. R2).

func RestoreConsulBackup

func RestoreConsulBackup(path string, kv ConsulKV, encryptionKey []byte) error

RestoreConsulBackup reads an encrypted backup file and restores all KV pairs into Consul.

func RestoreConsulBackupFromBytes

func RestoreConsulBackupFromBytes(fileBytes []byte, kv ConsulKV, encryptionKey []byte) error

RestoreConsulBackupFromBytes restores all KV pairs into Consul from an in-memory backup.

func StartPeriodicConsulBackup

func StartPeriodicConsulBackup(ctx context.Context, exe *consulBackupExecutor, periodSeconds int) func()

StartPeriodicConsulBackup runs Execute on a ticker and returns a stop function.

Types

type ConsulBackupMeta

type ConsulBackupMeta struct {
	Algo            string `json:"algo"`
	NonceB64        string `json:"nonce_b64"`
	CreatedAt       string `json:"created_at"`
	EncryptionKeyID string `json:"encryption_key_id"`
}

type ConsulBackupUploader

type ConsulBackupUploader interface {
	Upload(ctx context.Context, filename string, data []byte) error
}

ConsulBackupUploader is the same interface as kvstore.BackupUploader — allows reuse of R2Uploader.

type ConsulKV

type ConsulKV interface {
	Put(kv *api.KVPair, options *api.WriteOptions) (*api.WriteMeta, error)
	Get(key string, options *api.QueryOptions) (*api.KVPair, *api.QueryMeta, error)
	Delete(key string, options *api.WriteOptions) (*api.WriteMeta, error)
	List(prefix string, options *api.QueryOptions) (api.KVPairs, *api.QueryMeta, error)
}

type TLSPEMs

type TLSPEMs struct {
	CertPEM []byte
	KeyPEM  []byte
	CAPEM   []byte
}

func LoadTLSPEMs

func LoadTLSPEMs(certB64, keyB64, caB64 string) (*TLSPEMs, error)

LoadTLSPEMs loads TLS material either from base64-encoded strings (cloud/production)

func (*TLSPEMs) TLSConfig

func (p *TLSPEMs) TLSConfig() (*tls.Config, error)

TLSConfig builds a *tls.Config from the loaded PEM material.

Jump to

Keyboard shortcuts

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