Documentation
¶
Overview ¶
Package config loads and validates the exporter configuration.
Index ¶
- func LoadDotEnv(cfgPath string)
- func ParseWeekday(s string) (time.Weekday, error)
- type Collection
- type Compliance
- type ComplianceOverride
- type ComplianceTarget
- type Config
- type OTel
- type ReportConfig
- type ReportOutput
- type ReportServer
- type ReportToken
- type Retention
- type RetentionOverride
- type SMTP
- type Schedule
- type Server
- type ServerHTTP
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadDotEnv ¶ added in v1.4.0
func LoadDotEnv(cfgPath string)
LoadDotEnv loads a .env file before config interpolation so the `cp .env.example .env` quickstart works for bare-metal runs too, not just docker compose (which reads .env natively). It tries the working directory first, then the config file's directory (covers systemd units whose WorkingDirectory is not the install dir). The first file found wins.
Already-set environment variables always take precedence: godotenv.Load only sets keys that are not present in the environment, so real env/secret injection can never be shadowed by a stray .env file.
Types ¶
type Collection ¶
type Collection struct {
Interval time.Duration `yaml:"interval"`
Timeout time.Duration `yaml:"timeout"`
Lookback time.Duration `yaml:"lookback"`
AssetAgeThreshold time.Duration `yaml:"assetAgeThreshold"`
PerJobActivities bool `yaml:"perJobActivities"`
}
Collection holds loop timing. Lookback bounds the activities query window; AssetAgeThreshold gates per-asset last-copy-age emission; PerJobActivities opts into per-job activity metrics (higher cardinality — one series set per job in the window).
type Compliance ¶
type Compliance struct {
Grace time.Duration `yaml:"grace"`
Defaults ComplianceTarget `yaml:"defaults"`
Overrides []ComplianceOverride `yaml:"overrides"`
}
Compliance configures Phase 2 SLA target resolution: a lateness grace window, the per-tenant default target, and override rules that refine it.
type ComplianceOverride ¶
type ComplianceOverride struct {
Tenant string `yaml:"tenant"`
AssetType string `yaml:"assetType"`
PolicyName string `yaml:"policyName"`
ComplianceTarget `yaml:",inline"`
}
ComplianceOverride narrows a target to the assets it selects. Empty selector fields match any value; the most specific matching override wins (resolved in internal/report).
type ComplianceTarget ¶
type ComplianceTarget struct {
RPOHours int `yaml:"rpoHours"`
RetentionDays int `yaml:"retentionDays"`
MinCopies int `yaml:"minCopies"`
}
ComplianceTarget is an SLA target spec: backup-frequency (RPO), retention, and copy count.
type Config ¶
type Config struct {
Server ServerHTTP `yaml:"server"`
Collection Collection `yaml:"collection"`
OTel OTel `yaml:"otel"`
Servers []Server `yaml:"servers"`
}
Config is the whole file.
type OTel ¶
type OTel struct {
Enabled bool `yaml:"enabled"`
Endpoint string `yaml:"endpoint"`
Insecure bool `yaml:"insecure"`
Interval string `yaml:"interval"`
}
OTel configures optional OTLP metric/trace export.
type ReportConfig ¶
type ReportConfig struct {
Database struct {
DSN string `yaml:"dsn"`
} `yaml:"database"`
Capture struct {
Interval time.Duration `yaml:"interval"`
Timeout time.Duration `yaml:"timeout"`
RetentionDays int `yaml:"retentionDays"`
} `yaml:"capture"`
Servers []ReportServer `yaml:"servers"`
Compliance Compliance `yaml:"compliance"`
Retention Retention `yaml:"retention"`
Report ReportOutput `yaml:"report"`
SMTP SMTP `yaml:"smtp"`
Schedules []Schedule `yaml:"schedules"`
}
ReportConfig is the cmd/report configuration.
func LoadReport ¶
func LoadReport(path string) (*ReportConfig, error)
LoadReport reads, interpolates ${ENV} references, applies defaults, and validates.
type ReportOutput ¶
type ReportOutput struct {
Listen string `yaml:"listen"` // empty = CLI-only (no HTTP endpoint)
AuthToken string `yaml:"authToken"` // optional bearer; empty = no auth (localhost posture)
BrandName string `yaml:"brandName"`
Tokens []ReportToken `yaml:"tokens"`
}
ReportOutput configures Phase 3 report generation: the optional HTTP endpoint and branding.
type ReportServer ¶
type ReportServer struct {
Name string `yaml:"name"`
Tenant string `yaml:"tenant"`
Host string `yaml:"host"`
Port int `yaml:"port"` // defaults to 8443
Username string `yaml:"username"`
Password string `yaml:"password"`
PasswordFile string `yaml:"passwordFile"`
InsecureSkipVerify bool `yaml:"insecureSkipVerify"`
}
ReportServer is one PPDM server captured for backup history, tagged with a tenant.
func (ReportServer) BaseURL ¶
func (s ReportServer) BaseURL() string
BaseURL returns the https://host:port root for the PPDM REST API.
type ReportToken ¶ added in v1.1.0
ReportToken authorizes a bearer token to read the named tenants' reports ("*" = all).
type Retention ¶ added in v1.1.0
type Retention struct {
DefaultDays int `yaml:"defaultDays"`
Overrides []RetentionOverride `yaml:"overrides"`
}
Retention configures how long captured history is kept per tenant. DefaultDays applies to any tenant without an override; it falls back to capture.retentionDays when unset.
type RetentionOverride ¶ added in v1.1.0
RetentionOverride sets a per-tenant retention window (days) overriding the default.
type SMTP ¶ added in v1.1.0
type SMTP struct {
Host string `yaml:"host"`
Port int `yaml:"port"` // defaults to 587
From string `yaml:"from"`
Username string `yaml:"username"`
Password string `yaml:"password"`
StartTLS bool `yaml:"starttls"`
}
SMTP configures outbound email delivery for scheduled reports.
type Schedule ¶ added in v1.1.0
type Schedule struct {
Tenant string `yaml:"tenant"`
Cadence string `yaml:"cadence"` // daily | weekly | monthly
Weekday string `yaml:"weekday"` // weekly only (Mon..Sun)
Day int `yaml:"day"` // monthly only (1..31, clamped to month length)
Hour int `yaml:"hour"` // 0..23
Recipients []string `yaml:"recipients"`
}
Schedule is one per-tenant report cadence. Times are UTC.
type Server ¶
type Server struct {
Name string `yaml:"name"`
Host string `yaml:"host"`
Port int `yaml:"port"` // defaults to 8443
Username string `yaml:"username"`
Password string `yaml:"password"`
PasswordFile string `yaml:"passwordFile"`
InsecureSkipVerify bool `yaml:"insecureSkipVerify"`
}
Server is one PPDM server to monitor.
func (Server) BaseURL ¶
BaseURL returns the https://host:port root for the PPDM REST API.
type ServerHTTP ¶
type ServerHTTP struct {
Host string `yaml:"host"`
Port string `yaml:"port"`
URI string `yaml:"uri"`
LogName string `yaml:"logName"`
}
ServerHTTP holds the exporter's own HTTP-server settings. Named to avoid colliding with the PPDM target Server struct.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher reloads and revalidates the config on SIGHUP or file change, emitting the new *Config on Updates(). A bad reload is logged and dropped (the running config stays).
func NewWatcher ¶
NewWatcher starts watching path. Call Close to stop.