config

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config loads configuration with precedence defaults < YAML < GITDR_* env. Secrets never come from YAML, only env or a mounted file by path, and are wrapped in redact.Secret so they can't leak into logs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureConfig

type AzureConfig struct {
	Account          string        `yaml:"account"`
	Container        string        `yaml:"container"`
	Endpoint         string        `yaml:"endpoint"`
	ConnectionString redact.Secret `yaml:"-"`
}

AzureConfig configures the Azure Blob backend. The connection string is a secret (env only); real Azure uses DefaultAzureCredential with account/endpoint.

type BackupConfig

type BackupConfig struct {
	Concurrency int  `yaml:"concurrency"` // parallel repos; default 4
	Resume      bool `yaml:"resume"`      // skip repos already backed up for the run date
	LFS         bool `yaml:"lfs"`         // fetch Git LFS objects; default true
}

BackupConfig configures fan-out across repositories.

type Config

type Config struct {
	Source      SourceConfig      `yaml:"source"`
	Destination DestinationConfig `yaml:"destination"`
	Backup      BackupConfig      `yaml:"backup"`
	Manifest    ManifestConfig    `yaml:"manifest"`
	Metrics     MetricsConfig     `yaml:"metrics"`
	Encryption  EncryptionConfig  `yaml:"encryption"`
	WORM        WORMConfig        `yaml:"worm"`
	Log         LogConfig         `yaml:"log"`
}

Config is the full gitdr configuration.

func Default

func Default() *Config

Default returns the built-in default configuration.

func Load

func Load(path string) (*Config, error)

Load reads config from path (may be empty for "defaults + env only"), then applies environment overrides.

func (*Config) EncryptionKeyMaterial

func (c *Config) EncryptionKeyMaterial() ([]byte, error)

EncryptionKeyMaterial returns the raw encryption key material (from env) when encryption is enabled, or nil when disabled. The crypto package parses/validates it.

func (*Config) ResolveGitHubPrivateKey

func (c *Config) ResolveGitHubPrivateKey() ([]byte, error)

ResolveGitHubPrivateKey returns the GitHub App private key PEM from env (preferred) or the configured file path.

func (*Config) ResolveManifestPublicKey

func (c *Config) ResolveManifestPublicKey() ([]byte, error)

ResolveManifestPublicKey returns the manifest public key from the configured path.

func (*Config) ResolveManifestSigningKey

func (c *Config) ResolveManifestSigningKey() ([]byte, error)

ResolveManifestSigningKey returns the manifest signing key from env (preferred) or the configured file path.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks structural validity. Credential presence is checked by the source and destination constructors at the point of use.

type DestinationConfig

type DestinationConfig struct {
	Type      string          `yaml:"type"` // "s3" (AWS + S3-compatible) | "gcs" | "azure"
	S3        S3Config        `yaml:"s3"`
	GCS       GCSConfig       `yaml:"gcs"`
	Azure     AzureConfig     `yaml:"azure"`
	Retention RetentionConfig `yaml:"retention"`
}

DestinationConfig configures the storage destination.

type EncryptionConfig

type EncryptionConfig struct {
	Enabled bool          `yaml:"enabled"`
	Key     redact.Secret `yaml:"-"`
}

EncryptionConfig configures optional client-side envelope encryption. The key is a 32-byte AES-256 KEK supplied via env (GITDR_ENCRYPTION_KEY), never YAML.

type GCSConfig

type GCSConfig struct {
	Bucket   string `yaml:"bucket"`
	Endpoint string `yaml:"endpoint"` // empty = real GCS; set for an emulator
}

GCSConfig configures the Google Cloud Storage backend.

type GitHubConfig

type GitHubConfig struct {
	AppID          int64         `yaml:"appID"`
	InstallationID int64         `yaml:"installationID"`
	PrivateKeyPath string        `yaml:"privateKeyPath"`
	PrivateKey     redact.Secret `yaml:"-"` // injected from env only; never from YAML
}

GitHubConfig holds GitHub App installation credentials. The private key itself is supplied via env (GITDR_GITHUB_APP_PRIVATE_KEY) or a file at PrivateKeyPath.

type GitLabConfig

type GitLabConfig struct {
	Token redact.Secret `yaml:"-"`
}

GitLabConfig holds the GitLab read-scoped access token (env only; never YAML).

type LogConfig

type LogConfig struct {
	Level  string `yaml:"level"`  // debug|info|warn|error
	Format string `yaml:"format"` // json|text
}

LogConfig configures structured logging.

type ManifestConfig

type ManifestConfig struct {
	SigningKeyPath string        `yaml:"signingKeyPath"`
	PublicKeyPath  string        `yaml:"publicKeyPath"`
	SigningKey     redact.Secret `yaml:"-"` // injected from env only; never from YAML
}

ManifestConfig configures run-manifest signing/verification keys. The signing key is supplied via env (GITDR_MANIFEST_SIGNING_KEY) or a file at SigningKeyPath.

type MetricsConfig

type MetricsConfig struct {
	// TextfilePath is the .prom file node_exporter's textfile collector scrapes.
	// Empty disables metrics output.
	TextfilePath string `yaml:"textfilePath"`
}

MetricsConfig configures Prometheus textfile-collector output.

type RetentionConfig

type RetentionConfig struct {
	Mode string `yaml:"mode"` // COMPLIANCE (default) | GOVERNANCE
	Days int    `yaml:"days"` // retain-until = now + Days
}

RetentionConfig configures object-lock retention applied to every write.

type S3Config

type S3Config struct {
	Bucket       string `yaml:"bucket"`
	Region       string `yaml:"region"`
	Endpoint     string `yaml:"endpoint"`     // empty = AWS; MinIO/Wasabi/B2 set their endpoint
	UsePathStyle bool   `yaml:"usePathStyle"` // true for MinIO and most S3-compatible stores
}

S3Config configures the S3 (and S3-compatible) backend.

type SourceConfig

type SourceConfig struct {
	Type    string       `yaml:"type"`    // "github" (only backend in this build)
	BaseURL string       `yaml:"baseURL"` // empty = github.com; GHES sets https://host/api/v3 (M2+)
	Repo    string       `yaml:"repo"`    // single-repo selector "owner/name" (walking skeleton)
	Include []string     `yaml:"include"`
	Exclude []string     `yaml:"exclude"`
	GitHub  GitHubConfig `yaml:"github"`
	GitLab  GitLabConfig `yaml:"gitlab"`
}

SourceConfig configures the VCS source.

type WORMConfig

type WORMConfig struct {
	// Require maps to --require-worm. Default false: if the destination is not provably
	// immutable, gitdr warns loudly and proceeds. Set true to fail closed instead.
	Require bool `yaml:"require"`
}

WORMConfig configures the immutability check. WORM is recommended, not required.

Jump to

Keyboard shortcuts

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