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 ¶
- type AzureConfig
- type BackupConfig
- type Config
- func (c *Config) EncryptionKeyMaterial() ([]byte, error)
- func (c *Config) GitHubTokenFile() (string, error)
- func (c *Config) ResolveGitHubPrivateKey() ([]byte, error)
- func (c *Config) ResolveManifestPublicKey() ([]byte, error)
- func (c *Config) ResolveManifestSigningKey() ([]byte, error)
- func (c *Config) Validate() error
- type DestinationConfig
- type EncryptionConfig
- type GCSConfig
- type GitHubConfig
- type GitLabConfig
- type LogConfig
- type ManifestConfig
- type MetricsConfig
- type RetentionConfig
- type S3Config
- type SourceConfig
- type WORMConfig
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:"-"`
// SubscriptionID and ResourceGroup locate the storage account in Azure Resource Manager,
// the only API that reports whether the container's immutability policy is locked.
// Optional; without them gitdr cannot confirm immutability on Azure and says unknown.
SubscriptionID string `yaml:"subscriptionID"`
ResourceGroup string `yaml:"resourceGroup"`
}
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 Load ¶
Load reads config from path (may be empty for "defaults + env only"), then applies environment overrides.
func (*Config) EncryptionKeyMaterial ¶
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) GitHubTokenFile ¶ added in v0.1.20
GitHubTokenFile says which credential a GitHub run uses: the token file's path when source.github.tokenPath is set, and "" when an App private key is. Both, or neither, is an error.
Both is refused rather than resolved by precedence. The token file exists so that a run never holds the App key, which can mint a token for every installation of the App; a run handed both would hold it anyway, and quietly preferring one would hide that.
It reads nothing, and nothing Validate does touches the file either, so verify, restore and drill run without it. With a token file, appID and installationID are ignored rather than refused: the token already belongs to one installation.
func (*Config) ResolveGitHubPrivateKey ¶
ResolveGitHubPrivateKey returns the GitHub App private key PEM from env (preferred) or the configured file path.
func (*Config) ResolveManifestPublicKey ¶
ResolveManifestPublicKey returns the manifest public key from the configured path.
func (*Config) ResolveManifestSigningKey ¶
ResolveManifestSigningKey returns the manifest signing key from env (preferred) or the configured file path.
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 ¶
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
// TokenPath names a file holding an installation token, used instead of the App key. It
// is a path, not a secret: the file is read by the source before every request and never
// here, so a caller can replace it during a run. SPEC §3, "GitHub token file".
TokenPath string `yaml:"tokenPath"`
}
GitHubConfig holds the GitHub credential, which is one of two things: a GitHub App (appID, installationID and its private key), or a file holding an installation token somebody else minted. The private key is supplied via env (GITDR_GITHUB_APP_PRIVATE_KEY) or a file at PrivateKeyPath.
type GitLabConfig ¶
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.