config

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const RetentionGridKeepCountAll int = -1

Variables

This section is empty.

Functions

func Validator

func Validator() *validator.Validate

Types

type ActiveJob

type ActiveJob struct {
	Type               string                   `yaml:"type" validate:"required"`
	Name               string                   `yaml:"name" validate:"required"`
	Connect            Connect                  `yaml:"connect"`
	Pruning            PruningSenderReceiver    `yaml:"pruning" validate:"required"`
	Replication        Replication              `yaml:"replication"`
	ConflictResolution ConflictResolution       `yaml:"conflict_resolution"`
	MonitorSnapshots   MonitorSnapshots         `yaml:"monitor"`
	Interval           PositiveDurationOrManual `yaml:"interval"`
	Cron               string                   `yaml:"cron"`
	Hooks              JobHooks                 `yaml:"hooks"`
}

func (*ActiveJob) CronSpec

func (self *ActiveJob) CronSpec() string

type AuthKey added in v0.9.0

type AuthKey struct {
	Name string `yaml:"name" validate:"required"`
	Key  string `yaml:"key" validate:"required"`
}

type Config

type Config struct {
	Global Global   `yaml:"global"`
	Listen []Listen `yaml:"listen" validate:"dive"`

	Keys        []AuthKey `yaml:"keys" validate:"dive"`
	IncludeKeys string    `yaml:"include_keys" validate:"omitempty,filepath"`

	Jobs        []JobEnum `yaml:"jobs" validate:"min=1,dive"`
	IncludeJobs string    `yaml:"include_jobs" validate:"omitempty,filepath"`
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Config

func ParseConfig

func ParseConfig(path string, opts ...Option) (*Config, error)

func ParseConfigBytes

func ParseConfigBytes(path string, bytes []byte, opts ...Option,
) (*Config, error)

func (*Config) Job

func (c *Config) Job(name string) (*JobEnum, error)

type ConflictResolution

type ConflictResolution struct {
	InitialReplication string `yaml:"initial_replication" default:"all" validate:"required"`
}

type Connect added in v0.9.0

type Connect struct {
	Type           string `yaml:"type" validate:"required,oneof=http local"`
	Server         string `yaml:"server" validate:"required_if=Type http,omitempty,url"`
	ListenerName   string `yaml:"listener_name" validate:"required"`
	ClientIdentity string `yaml:"client_identity" validate:"required"`
}

type DatasetFilter added in v0.8.10

type DatasetFilter struct {
	Pattern   string `yaml:"pattern"`
	Exclude   bool   `yaml:"exclude"`
	Recursive bool   `yaml:"recursive" validate:"excluded_with=Shell"`
	Shell     bool   `yaml:"shell" validate:"excluded_with=Recursive"`
}

type Duration

type Duration struct {
	// contains filtered or unexported fields
}

func (Duration) Duration

func (d Duration) Duration() time.Duration

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(value *yaml.Node) error

type FileLoggingOutlet

type FileLoggingOutlet struct {
	LoggingOutletCommon `yaml:",inline"`
	FileName            string `yaml:"filename"`
}

type FilesystemsFilter

type FilesystemsFilter map[string]bool

type Global

type Global struct {
	RpcTimeout time.Duration `yaml:"rpc_timeout" default:"1m" validate:"gt=0s"`
	ZfsBin     string        `yaml:"zfs_bin" default:"zfs" validate:"required"`

	Logging    LoggingOutletEnumList  `yaml:"logging" validate:"min=1"`
	Monitoring []PrometheusMonitoring `yaml:"monitoring" validate:"dive"`
	Control    GlobalControl          `yaml:"control"`
}

type GlobalControl

type GlobalControl struct {
	SockPath string `yaml:"sockpath" default:"/var/run/zrepl/control" validate:"filepath"`
	SockMode uint32 `yaml:"sockmode" validate:"lte=0o777"`
}

type HookCommand

type HookCommand struct {
	Path        string            `yaml:"path" validate:"required"`
	Args        []string          `yaml:"args" validate:"dive,required"`
	Env         map[string]string `yaml:"env" validate:"dive,keys,required,endkeys,required"`
	Timeout     time.Duration     `yaml:"timeout" default:"30s" validate:"min=0s"`
	Filesystems FilesystemsFilter `yaml:"filesystems"`
	Datasets    []DatasetFilter   `yaml:"datasets" validate:"dive"`
	ErrIsFatal  bool              `yaml:"err_is_fatal"`
}

func (*HookCommand) UnmarshalYAML added in v0.8.10

func (self *HookCommand) UnmarshalYAML(value *yaml.Node) error

type JobEnum

type JobEnum struct {
	Ret any `validate:"required"`
}

func (JobEnum) MonitorSnapshots

func (j JobEnum) MonitorSnapshots() MonitorSnapshots

func (JobEnum) Name

func (j JobEnum) Name() string

func (*JobEnum) UnmarshalYAML

func (t *JobEnum) UnmarshalYAML(value *yaml.Node) (err error)

type JobHooks added in v0.8.10

type JobHooks struct {
	Pre  *HookCommand `yaml:"pre"`
	Post *HookCommand `yaml:"post"`
}

type Listen

type Listen struct {
	Addr string `yaml:"addr" validate:"required_without=Unix,omitempty,hostname_port"`

	Unix     string `yaml:"unix" validate:"required_without=Addr,omitempty,filepath"`
	UnixMode uint32 `yaml:"unix_mode" validate:"lte=0o777"`

	TLSCert string `yaml:"tls_cert" validate:"required_with=TLSKey,omitempty,filepath"`
	TLSKey  string `yaml:"tls_key" validate:"omitempty,filepath"`

	Control bool `yaml:"control" validate:"required_without_all=Metrics Zfs"`
	Metrics bool `yaml:"metrics" validate:"required_without_all=Control Zfs"`
	Zfs     bool `yaml:"zfs" validate:"required_without_all=Control Metrics"`
}

type LoggingOutletCommon

type LoggingOutletCommon struct {
	Type       string   `yaml:"type" validate:"required"`
	Level      string   `yaml:"level" validate:"required"`
	Format     string   `yaml:"format" validate:"required"`
	HideFields []string `yaml:"hide_fields"`
	Time       bool     `yaml:"time" default:"true"`
}

type LoggingOutletEnum

type LoggingOutletEnum struct {
	Ret any `validate:"required"`
}

func (*LoggingOutletEnum) UnmarshalYAML

func (t *LoggingOutletEnum) UnmarshalYAML(value *yaml.Node) (err error)

type LoggingOutletEnumList

type LoggingOutletEnumList []LoggingOutletEnum

func (*LoggingOutletEnumList) SetDefaults

func (l *LoggingOutletEnumList) SetDefaults()

type MonitorCount

type MonitorCount struct {
	Prefix       string          `yaml:"prefix"`
	SkipDatasets []DatasetFilter `yaml:"skip_datasets" validate:"dive"`
	Warning      uint            `yaml:"warning"`
	Critical     uint            `yaml:"critical" validate:"required"`
}

type MonitorCreation

type MonitorCreation struct {
	Prefix       string          `yaml:"prefix"`
	SkipDatasets []DatasetFilter `yaml:"skip_datasets" validate:"dive"`
	Warning      time.Duration   `yaml:"warning"`
	Critical     time.Duration   `yaml:"critical" validate:"required"`
}

type MonitorSnapshots

type MonitorSnapshots struct {
	Count  []MonitorCount    `yaml:"count" validate:"dive"`
	Latest []MonitorCreation `yaml:"latest" validate:"dive"`
	Oldest []MonitorCreation `yaml:"oldest" validate:"dive"`
}

func (*MonitorSnapshots) Valid

func (self *MonitorSnapshots) Valid() bool

type Option added in v0.9.0

type Option func(self *Config)

func WithoutIncludes added in v0.9.3

func WithoutIncludes() Option

type PassiveJob

type PassiveJob struct {
	Type             string           `yaml:"type" validate:"required"`
	Name             string           `yaml:"name" validate:"required"`
	ClientKeys       []string         `yaml:"client_keys" validate:"dive,required"`
	Pruning          PruningLocal     `yaml:"pruning"`
	MonitorSnapshots MonitorSnapshots `yaml:"monitor"`
}

type PlaceholderRecvOptions

type PlaceholderRecvOptions struct {
	Encryption string `yaml:"encryption" default:"inherit" validate:"required"`
}

type PositiveDuration

type PositiveDuration struct {
	// contains filtered or unexported fields
}

func (PositiveDuration) Duration

func (d PositiveDuration) Duration() time.Duration

func (*PositiveDuration) UnmarshalYAML

func (d *PositiveDuration) UnmarshalYAML(value *yaml.Node) error

type PositiveDurationOrManual

type PositiveDurationOrManual struct {
	Interval time.Duration
	Manual   bool
}

func (*PositiveDurationOrManual) UnmarshalYAML

func (i *PositiveDurationOrManual) UnmarshalYAML(value *yaml.Node) (err error)

type PrometheusMonitoring

type PrometheusMonitoring struct {
	Type           string `yaml:"type" validate:"required"`
	Listen         string `yaml:"listen" validate:"required,hostname_port"`
	ListenFreeBind bool   `yaml:"listen_freebind"`
}

type PropertyRecvOptions

type PropertyRecvOptions struct {
	Inherit  []zfsprop.Property          `yaml:"inherit" validate:"dive,required"`
	Override map[zfsprop.Property]string `yaml:"override" validate:"dive,required"`
}

type PruneGrid

type PruneGrid struct {
	Type  string                `yaml:"type"`
	Grid  RetentionIntervalList `yaml:"grid"`
	Regex string                `yaml:"regex"`
}

type PruneKeepLastN

type PruneKeepLastN struct {
	Type  string `yaml:"type" validate:"required"`
	Count int    `yaml:"count" validate:"required"`
	Regex string `yaml:"regex"`
}

type PruneKeepNotReplicated

type PruneKeepNotReplicated struct {
	Type                 string `yaml:"type" validate:"required"`
	KeepSnapshotAtCursor bool   `yaml:"keep_snapshot_at_cursor" default:"true"`
}

type PruneKeepRegex

type PruneKeepRegex struct {
	Type   string `yaml:"type" validate:"required"`
	Regex  string `yaml:"regex" validate:"required"`
	Negate bool   `yaml:"negate"`
}

type PruningEnum

type PruningEnum struct {
	Ret any `validate:"required"`
}

func (*PruningEnum) UnmarshalYAML

func (t *PruningEnum) UnmarshalYAML(value *yaml.Node) (err error)

type PruningLocal

type PruningLocal struct {
	Concurrency uint          `yaml:"concurrency"`
	Keep        []PruningEnum `yaml:"keep"`
}

type PruningSenderReceiver

type PruningSenderReceiver struct {
	Concurrency  uint          `yaml:"concurrency"`
	KeepSender   []PruningEnum `yaml:"keep_sender"`
	KeepReceiver []PruningEnum `yaml:"keep_receiver"`
}

type PullJob

type PullJob struct {
	ActiveJob `yaml:",inline"`
	RootFS    string      `yaml:"root_fs" validate:"required"`
	Recv      RecvOptions `yaml:"recv"`
}

func (*PullJob) GetAppendClientIdentity

func (j *PullJob) GetAppendClientIdentity() bool

func (*PullJob) GetRecvOptions

func (j *PullJob) GetRecvOptions() *RecvOptions

func (*PullJob) GetRootFS

func (j *PullJob) GetRootFS() string

type PushJob

type PushJob struct {
	ActiveJob    `yaml:",inline"`
	Snapshotting SnapshottingEnum  `yaml:"snapshotting"`
	Filesystems  FilesystemsFilter `yaml:"filesystems" validate:"required_without=Datasets"`
	Datasets     []DatasetFilter   `yaml:"datasets" validate:"required_without=Filesystems,dive"`
	Send         SendOptions       `yaml:"send"`
}

func (*PushJob) GetFilesystems

func (j *PushJob) GetFilesystems() (FilesystemsFilter, []DatasetFilter)

func (*PushJob) GetSendOptions

func (j *PushJob) GetSendOptions() *SendOptions

type RecvOptions

type RecvOptions struct {
	Properties  PropertyRecvOptions    `yaml:"properties"`
	Placeholder PlaceholderRecvOptions `yaml:"placeholder"`

	ExecPipe [][]string `yaml:"execpipe" validate:"dive,required"`
}

type Replication

type Replication struct {
	Protection  ReplicationOptionsProtection  `yaml:"protection"`
	Concurrency ReplicationOptionsConcurrency `yaml:"concurrency"`
	Prefix      string                        `yaml:"prefix"`
}

type ReplicationOptionsConcurrency

type ReplicationOptionsConcurrency struct {
	Steps         int  `yaml:"steps" default:"1" validate:"min=1"`
	SizeEstimates uint `yaml:"size_estimates"`
}

type ReplicationOptionsProtection

type ReplicationOptionsProtection struct {
	Initial     string `yaml:"initial" default:"guarantee_resumability" validate:"required"`
	Incremental string `yaml:"incremental" default:"guarantee_resumability" validate:"required"`
}

type RetentionInterval

type RetentionInterval struct {
	// contains filtered or unexported fields
}

func ParseRetentionIntervalSpec

func ParseRetentionIntervalSpec(s string) (intervals []RetentionInterval, err error)

func (*RetentionInterval) KeepCount

func (i *RetentionInterval) KeepCount() int

func (*RetentionInterval) Length

func (i *RetentionInterval) Length() time.Duration

type RetentionIntervalList

type RetentionIntervalList []RetentionInterval

func (*RetentionIntervalList) UnmarshalYAML

func (t *RetentionIntervalList) UnmarshalYAML(value *yaml.Node) (err error)

type SendOptions

type SendOptions struct {
	ListPlaceholders bool `yaml:"list_placeholders"`
	Encrypted        bool `yaml:"encrypted"`
	Raw              bool `yaml:"raw" default:"true"`
	SendProperties   bool `yaml:"send_properties"`
	BackupProperties bool `yaml:"backup_properties"`
	LargeBlocks      bool `yaml:"large_blocks"`
	Compressed       bool `yaml:"compressed"`
	EmbeddedData     bool `yaml:"embedded_data"`
	Saved            bool `yaml:"saved"`

	ExecPipe [][]string `yaml:"execpipe" validate:"dive,required"`
}

type SinkJob

type SinkJob struct {
	PassiveJob `yaml:",inline"`
	RootFS     string      `yaml:"root_fs" validate:"required"`
	Recv       RecvOptions `yaml:"recv"`
}

func (*SinkJob) GetAppendClientIdentity

func (j *SinkJob) GetAppendClientIdentity() bool

func (*SinkJob) GetRecvOptions

func (j *SinkJob) GetRecvOptions() *RecvOptions

func (*SinkJob) GetRootFS

func (j *SinkJob) GetRootFS() string

type SnapJob

type SnapJob struct {
	Type             string            `yaml:"type" validate:"required"`
	Name             string            `yaml:"name" validate:"required"`
	Pruning          PruningLocal      `yaml:"pruning"`
	Snapshotting     SnapshottingEnum  `yaml:"snapshotting"`
	Filesystems      FilesystemsFilter `yaml:"filesystems" validate:"required_without=Datasets"`
	Datasets         []DatasetFilter   `yaml:"datasets" validate:"required_without=Filesystems,dive"`
	MonitorSnapshots MonitorSnapshots  `yaml:"monitor"`
}

type SnapshottingEnum

type SnapshottingEnum struct {
	Ret any `validate:"required"`
}

func (*SnapshottingEnum) UnmarshalYAML

func (t *SnapshottingEnum) UnmarshalYAML(value *yaml.Node) (err error)

type SnapshottingManual

type SnapshottingManual struct {
	Type string `yaml:"type" validate:"required"`
}

type SnapshottingPeriodic

type SnapshottingPeriodic struct {
	Type            string        `yaml:"type" validate:"required"`
	Prefix          string        `yaml:"prefix" validate:"required"`
	Interval        Duration      `yaml:"interval"`
	Cron            string        `yaml:"cron"`
	Hooks           []HookCommand `yaml:"hooks" validate:"dive"`
	TimestampFormat string        `yaml:"timestamp_format" default:"dense" validate:"required"`
	TimestampLocal  bool          `yaml:"timestamp_local" default:"true"`
	Concurrency     uint          `yaml:"concurrency"`
}

func (*SnapshottingPeriodic) CronSpec

func (self *SnapshottingPeriodic) CronSpec() string

type SourceJob

type SourceJob struct {
	PassiveJob   `yaml:",inline"`
	Replication  Replication       `yaml:"replication"`
	Snapshotting SnapshottingEnum  `yaml:"snapshotting"`
	Filesystems  FilesystemsFilter `yaml:"filesystems" validate:"required_without=Datasets"`
	Datasets     []DatasetFilter   `yaml:"datasets" validate:"required_without=Filesystems,dive"`
	Send         SendOptions       `yaml:"send"`
}

func (*SourceJob) GetFilesystems

func (j *SourceJob) GetFilesystems() (FilesystemsFilter, []DatasetFilter)

func (*SourceJob) GetSendOptions

func (j *SourceJob) GetSendOptions() *SendOptions

type SyslogFacility

type SyslogFacility syslog.Priority

func (*SyslogFacility) SetDefaults

func (f *SyslogFacility) SetDefaults()

func (*SyslogFacility) UnmarshalJSON

func (f *SyslogFacility) UnmarshalJSON(b []byte) error

func (*SyslogFacility) UnmarshalYAML

func (t *SyslogFacility) UnmarshalYAML(value *yaml.Node) (err error)

type SyslogLoggingOutlet

type SyslogLoggingOutlet struct {
	LoggingOutletCommon `yaml:",inline"`
	Facility            SyslogFacility `yaml:"facility" default:"local0" validate:"required"`
	RetryInterval       time.Duration  `yaml:"retry_interval" default:"10s" validate:"gt=0s"`
}

type TCPLoggingOutlet

type TCPLoggingOutlet struct {
	LoggingOutletCommon `yaml:",inline"`
	Address             string               `yaml:"address" validate:"required,hostname_port"`
	Net                 string               `yaml:"net" default:"tcp" validate:"required"`
	RetryInterval       time.Duration        `yaml:"retry_interval" default:"10s" validate:"gt=0s"`
	TLS                 *TCPLoggingOutletTLS `yaml:"tls"`
}

type TCPLoggingOutletTLS

type TCPLoggingOutletTLS struct {
	CA   string `yaml:"ca" validate:"required"`
	Cert string `yaml:"cert" validate:"required"`
	Key  string `yaml:"key" validate:"required"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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