config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config loads and validates the exporter configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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.

func Load

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

Load reads, interpolates ${ENV} references, applies defaults, and validates.

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"`
	Report     ReportOutput   `yaml:"report"`
}

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"`
}

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 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

func (s Server) BaseURL() string

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

func NewWatcher(path string) (*Watcher, error)

NewWatcher starts watching path. Call Close to stop.

func (*Watcher) Close

func (w *Watcher) Close() error

Close stops the watcher.

func (*Watcher) Trigger

func (w *Watcher) Trigger()

Trigger forces a reload (used by tests and callers that want a manual refresh).

func (*Watcher) Updates

func (w *Watcher) Updates() <-chan *Config

Updates is the channel of successfully reloaded configs.

Jump to

Keyboard shortcuts

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