add to config

This commit is contained in:
Anton Schirg 2018-08-27 15:18:08 +02:00
parent ecd9db4ac6
commit b955d308d9
4 changed files with 72 additions and 41 deletions

View File

@ -26,12 +26,14 @@ type PushJob struct {
Replication PushReplication `yaml:"replication"` Replication PushReplication `yaml:"replication"`
Snapshotting Snapshotting `yaml:"snapshotting"` Snapshotting Snapshotting `yaml:"snapshotting"`
Pruning PruningSenderReceiver `yaml:"pruning"` Pruning PruningSenderReceiver `yaml:"pruning"`
Debug JobDebugSettings `yaml:"debug,optional"`
} }
type SinkJob struct { type SinkJob struct {
Type string `yaml:"type"` Type string `yaml:"type"`
Name string `yaml:"name"` Name string `yaml:"name"`
Replication SinkReplication `yaml:"replication"` Replication SinkReplication `yaml:"replication"`
Debug JobDebugSettings `yaml:"debug,optional"`
} }
type PullJob struct { type PullJob struct {
@ -39,11 +41,13 @@ type PullJob struct {
Name string `yaml:"name"` Name string `yaml:"name"`
Replication PullReplication `yaml:"replication"` Replication PullReplication `yaml:"replication"`
Pruning PruningSenderReceiver `yaml:"pruning"` Pruning PruningSenderReceiver `yaml:"pruning"`
Debug JobDebugSettings `yaml:"debug,optional"`
} }
type PullReplication struct { type PullReplication struct {
Connect ConnectEnum `yaml:"connect"` Connect ConnectEnum `yaml:"connect"`
RootDataset string `yaml:"root_dataset"` RootDataset string `yaml:"root_dataset"`
Interval time.Duration `yaml:"interval,positive"`
} }
type SourceJob struct { type SourceJob struct {
@ -52,14 +56,16 @@ type SourceJob struct {
Replication SourceReplication `yaml:"replication"` Replication SourceReplication `yaml:"replication"`
Snapshotting Snapshotting `yaml:"snapshotting"` Snapshotting Snapshotting `yaml:"snapshotting"`
Pruning PruningLocal `yaml:"pruning"` Pruning PruningLocal `yaml:"pruning"`
Debug JobDebugSettings `yaml:"debug,optional"`
} }
type LocalJob struct { type LocalJob struct {
Type string `yaml:"type"` Type string `yaml:"type"`
Name string `yaml:"name"` Name string `yaml:"name"`
Replication LocalReplication `yaml:"replication"` Replication LocalReplication `yaml:"replication"`
Snapshotting Snapshotting `yaml:"snapshotting"` Snapshotting Snapshotting `yaml:"snapshotting"`
Pruning PruningSenderReceiver `yaml:"pruning"` Pruning PruningSenderReceiver `yaml:"pruning"`
Debug JobDebugSettings `yaml:"debug,optional"`
} }
type PushReplication struct { type PushReplication struct {
@ -79,12 +85,12 @@ type SourceReplication struct {
type LocalReplication struct { type LocalReplication struct {
Filesystems map[string]bool `yaml:"filesystems"` Filesystems map[string]bool `yaml:"filesystems"`
RootDataset string `yaml:"root_dataset"` RootDataset string `yaml:"root_dataset"`
} }
type Snapshotting struct { type Snapshotting struct {
SnapshotPrefix string `yaml:"snapshot_prefix"` SnapshotPrefix string `yaml:"snapshot_prefix"`
Interval time.Duration `yaml:"interval"` Interval time.Duration `yaml:"interval,positive"`
} }
type PruningSenderReceiver struct { type PruningSenderReceiver struct {
@ -108,25 +114,31 @@ type ConnectEnum struct {
} }
type TCPConnect struct { type TCPConnect struct {
Type string `yaml:"type"` Type string `yaml:"type"`
Address string `yaml:"address"` Address string `yaml:"address"`
DialTimeout time.Duration `yaml:"dial_timeout,positive,default=10s"`
} }
type TLSConnect struct { type TLSConnect struct {
Type string `yaml:"type"` Type string `yaml:"type"`
Address string `yaml:"address"` Address string `yaml:"address"`
Ca string `yaml:"ca"` Ca string `yaml:"ca"`
Cert string `yaml:"cert"` Cert string `yaml:"cert"`
Key string `yaml:"key"` Key string `yaml:"key"`
ServerCN string `yaml:"server_cn"`
DialTimeout time.Duration `yaml:"dial_timeout,positive,default=10s"`
} }
type SSHStdinserverConnect struct { type SSHStdinserverConnect struct {
Type string `yaml:"type"` Type string `yaml:"type"`
Host string `yaml:"host"` Host string `yaml:"host"`
User string `yaml:"user"` User string `yaml:"user"`
Port uint16 `yaml:"port"` Port uint16 `yaml:"port"`
IdentityFile string `yaml:"identity_file"` IdentityFile string `yaml:"identity_file"`
Options []string `yaml:"options"` TransportOpenCommand []string `yaml:"transport_open_command,optional"` //TODO unused
SSHCommand string `yaml:"ssh_command,optional"` //TODO unused
Options []string `yaml:"options"`
DialTimeout time.Duration `yaml:"dial_timeout,positive,default=10s"`
} }
type ServeEnum struct { type ServeEnum struct {
@ -140,15 +152,16 @@ type TCPServe struct {
} }
type TLSServe struct { type TLSServe struct {
Type string `yaml:"type"` Type string `yaml:"type"`
Listen string `yaml:"listen"` Listen string `yaml:"listen"`
Ca string `yaml:"ca"` Ca string `yaml:"ca"`
Cert string `yaml:"cert"` Cert string `yaml:"cert"`
Key string `yaml:"key"` Key string `yaml:"key"`
ClientCN string `yaml:"client_cn"`
} }
type StdinserverServer struct { type StdinserverServer struct {
Type string `yaml:"type"` Type string `yaml:"type"`
ClientIdentity string `yaml:"client_identity"` ClientIdentity string `yaml:"client_identity"`
} }
@ -165,6 +178,11 @@ type PruneKeepLastN struct {
Count int `yaml:"count"` Count int `yaml:"count"`
} }
type PruneKeepPrefix struct { // FIXME rename to KeepPrefix
Type string `yaml:"type"`
Prefix string `yaml:"prefix"`
}
type LoggingOutletEnum struct { type LoggingOutletEnum struct {
Ret interface{} Ret interface{}
} }
@ -182,14 +200,14 @@ type StdoutLoggingOutlet struct {
type SyslogLoggingOutlet struct { type SyslogLoggingOutlet struct {
LoggingOutletCommon `yaml:",inline"` LoggingOutletCommon `yaml:",inline"`
RetryInterval time.Duration `yaml:"retry_interval"` RetryInterval time.Duration `yaml:"retry_interval,positive"`
} }
type TCPLoggingOutlet struct { type TCPLoggingOutlet struct {
LoggingOutletCommon `yaml:",inline"` LoggingOutletCommon `yaml:",inline"`
Address string `yaml:"address"` Address string `yaml:"address"`
Net string `yaml:"net,default=tcp"` Net string `yaml:"net,default=tcp"`
RetryInterval time.Duration `yaml:"retry_interval"` RetryInterval time.Duration `yaml:"retry_interval,positive"`
TLS *TCPLoggingOutletTLS `yaml:"tls,optional"` TLS *TCPLoggingOutletTLS `yaml:"tls,optional"`
} }
@ -220,6 +238,13 @@ type GlobalStdinServer struct {
SockDir string `yaml:"sockdir,default=/var/run/zrepl/stdinserver"` SockDir string `yaml:"sockdir,default=/var/run/zrepl/stdinserver"`
} }
type JobDebugSettings struct {
Conn struct {
ReadDump string `yaml:"read_dump"`
WriteDump string `yaml:"write_dump"`
} `yaml:"conn"`
}
func enumUnmarshal(u func(interface{}, bool) error, types map[string]interface{}) (interface{}, error) { func enumUnmarshal(u func(interface{}, bool) error, types map[string]interface{}) (interface{}, error) {
var in struct { var in struct {
Type string Type string
@ -247,15 +272,15 @@ func (t *JobEnum) UnmarshalYAML(u func(interface{}, bool) error) (err error) {
"sink": &SinkJob{}, "sink": &SinkJob{},
"pull": &PullJob{}, "pull": &PullJob{},
"source": &SourceJob{}, "source": &SourceJob{},
"local": &LocalJob{}, "local": &LocalJob{},
}) })
return return
} }
func (t *ConnectEnum) UnmarshalYAML(u func(interface{}, bool) error) (err error) { func (t *ConnectEnum) UnmarshalYAML(u func(interface{}, bool) error) (err error) {
t.Ret, err = enumUnmarshal(u, map[string]interface{}{ t.Ret, err = enumUnmarshal(u, map[string]interface{}{
"tcp": &TCPConnect{}, "tcp": &TCPConnect{},
"tls": &TLSConnect{}, "tls": &TLSConnect{},
"ssh+stdinserver": &SSHStdinserverConnect{}, "ssh+stdinserver": &SSHStdinserverConnect{},
}) })
return return
@ -263,8 +288,8 @@ func (t *ConnectEnum) UnmarshalYAML(u func(interface{}, bool) error) (err error)
func (t *ServeEnum) UnmarshalYAML(u func(interface{}, bool) error) (err error) { func (t *ServeEnum) UnmarshalYAML(u func(interface{}, bool) error) (err error) {
t.Ret, err = enumUnmarshal(u, map[string]interface{}{ t.Ret, err = enumUnmarshal(u, map[string]interface{}{
"tcp": &TCPServe{}, "tcp": &TCPServe{},
"tls": &TLSServe{}, "tls": &TLSServe{},
"stdinserver": &StdinserverServer{}, "stdinserver": &StdinserverServer{},
}) })
return return
@ -275,6 +300,7 @@ func (t *PruningEnum) UnmarshalYAML(u func(interface{}, bool) error) (err error)
"not_replicated": &PruneKeepNotReplicated{}, "not_replicated": &PruneKeepNotReplicated{},
"last_n": &PruneKeepLastN{}, "last_n": &PruneKeepLastN{},
"grid": &PruneGrid{}, "grid": &PruneGrid{},
"prefix": &PruneKeepPrefix{},
}) })
return return
} }

View File

@ -1,15 +1,16 @@
jobs: jobs:
- name: pull_servers - name: pull_servers
type: pull type: pull
replication: replication:
connect: connect:
type: tls type: tls
address: "server1.foo.bar:8888" address: "server1.foo.bar:8888"
ca: /certs/ca.crt ca: "/certs/ca.crt"
cert: /certs/cert.crt cert: "/certs/cert.crt"
key: /certs/key.pem key: "/certs/key.pem"
server_cn: "server1"
root_dataset: "pool2/backup_servers" root_dataset: "pool2/backup_servers"
interval: 10m
pruning: pruning:
keep_sender: keep_sender:
- type: not_replicated - type: not_replicated

View File

@ -12,6 +12,7 @@ jobs:
options: # optional, default [], `-o` arguments passed to ssh options: # optional, default [], `-o` arguments passed to ssh
- "Compression=on" - "Compression=on"
root_dataset: "pool2/backup_servers" root_dataset: "pool2/backup_servers"
interval: 10m
pruning: pruning:
keep_sender: keep_sender:
- type: not_replicated - type: not_replicated
@ -21,6 +22,8 @@ jobs:
grid: 1x1h(keep=all) | 24x1h | 14x1d grid: 1x1h(keep=all) | 24x1h | 14x1d
keep_bookmarks: all keep_bookmarks: all
keep_receiver: keep_receiver:
- type: prefix
prefix: keep_
- type: grid - type: grid
grid: 1x1h(keep=all) | 24x1h | 35x1d | 6x30d grid: 1x1h(keep=all) | 24x1h | 35x1d | 6x30d
keep_bookmarks: all keep_bookmarks: all

View File

@ -9,6 +9,7 @@ jobs:
ca: "ca.pem" ca: "ca.pem"
cert: "cert.pem" cert: "cert.pem"
key: "key.pem" key: "key.pem"
client_cn: "laptop1"
global: global:
logging: logging:
- type: "tcp" - type: "tcp"