mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-24 17:35:01 +01:00
config: PushACLs, sinks are also just ClientMappings & LOCAL_TRANSPORT_IDENTITY
This commit is contained in:
parent
ac5a911c64
commit
3e0c758d7f
@ -45,16 +45,17 @@ type Pull struct {
|
|||||||
From *Pool
|
From *Pool
|
||||||
Mapping zfs.DatasetMapping
|
Mapping zfs.DatasetMapping
|
||||||
}
|
}
|
||||||
type Sink struct {
|
type ClientMapping struct {
|
||||||
From string
|
From string
|
||||||
Mapping zfs.DatasetMapping
|
Mapping zfs.DatasetMapping
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Pools []Pool
|
Pools []Pool
|
||||||
Pushs []Push
|
Pushs []Push
|
||||||
Pulls []Pull
|
Pulls []Pull
|
||||||
Sinks []Sink
|
Sinks []ClientMapping
|
||||||
|
PullACLs []ClientMapping
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseConfig(path string) (config Config, err error) {
|
func ParseConfig(path string) (config Config, err error) {
|
||||||
@ -94,7 +95,10 @@ func parseMain(root map[string]interface{}) (c Config, err error) {
|
|||||||
if c.Pulls, err = parsePulls(root["pulls"], poolLookup); err != nil {
|
if c.Pulls, err = parsePulls(root["pulls"], poolLookup); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if c.Sinks, err = parseSinks(root["sinks"]); err != nil {
|
if c.Sinks, err = parseClientMappings(root["sinks"]); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if c.PullACLs, err = parseClientMappings(root["pull_acls"]); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -112,6 +116,12 @@ func parsePools(v interface{}) (pools []Pool, err error) {
|
|||||||
|
|
||||||
pools = make([]Pool, len(asList))
|
pools = make([]Pool, len(asList))
|
||||||
for i, p := range asList {
|
for i, p := range asList {
|
||||||
|
|
||||||
|
if p.Name == LOCAL_TRANSPORT_IDENTITY {
|
||||||
|
err = errors.New(fmt.Sprintf("pool name '%s' reserved for local pulls", LOCAL_TRANSPORT_IDENTITY))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var transport Transport
|
var transport Transport
|
||||||
if transport, err = parseTransport(p.Transport); err != nil {
|
if transport, err = parseTransport(p.Transport); err != nil {
|
||||||
return
|
return
|
||||||
@ -227,28 +237,34 @@ func parsePulls(v interface{}, pl poolLookup) (p []Pull, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseSinks(v interface{}) (sinks []Sink, err error) {
|
func expectList(v interface{}) (asList []interface{}, err error) {
|
||||||
|
|
||||||
var asList []interface{}
|
|
||||||
var ok bool
|
var ok bool
|
||||||
if asList, ok = v.([]interface{}); !ok {
|
if asList, ok = v.([]interface{}); !ok {
|
||||||
return nil, errors.New("expected list")
|
err = errors.New("expected list")
|
||||||
}
|
}
|
||||||
|
|
||||||
sinks = make([]Sink, len(asList))
|
|
||||||
|
|
||||||
for i, s := range asList {
|
|
||||||
var sink Sink
|
|
||||||
if sink, err = parseSink(s); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
sinks[i] = sink
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseSink(v interface{}) (s Sink, err error) {
|
func parseClientMappings(v interface{}) (cm []ClientMapping, err error) {
|
||||||
|
|
||||||
|
var asList []interface{}
|
||||||
|
if asList, err = expectList(v); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cm = make([]ClientMapping, len(asList))
|
||||||
|
|
||||||
|
for i, e := range asList {
|
||||||
|
var m ClientMapping
|
||||||
|
if m, err = parseClientMapping(e); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cm[i] = m
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseClientMapping(v interface{}) (s ClientMapping, err error) {
|
||||||
t := struct {
|
t := struct {
|
||||||
From string
|
From string
|
||||||
Mapping map[string]string
|
Mapping map[string]string
|
||||||
|
@ -2,17 +2,10 @@ pools:
|
|||||||
- name: offsite_backups
|
- name: offsite_backups
|
||||||
transport:
|
transport:
|
||||||
ssh:
|
ssh:
|
||||||
zrepl_identity: db2
|
host: 192.168.122.6
|
||||||
host: backups1.example.com
|
|
||||||
user: root
|
user: root
|
||||||
port: 22
|
port: 22
|
||||||
command: ssh
|
identity_file: /etc/zrepl/identities/offsite_backups
|
||||||
args: []
|
|
||||||
|
|
||||||
- name: local_mirror
|
|
||||||
transport:
|
|
||||||
local:
|
|
||||||
pool: mirrorpool
|
|
||||||
|
|
||||||
pushs:
|
pushs:
|
||||||
- to: offsite_backups
|
- to: offsite_backups
|
||||||
@ -26,7 +19,9 @@ pulls:
|
|||||||
# like in sinks
|
# like in sinks
|
||||||
}
|
}
|
||||||
|
|
||||||
- from: local_mirror
|
# local replication, only allowed in pull mode
|
||||||
|
# the from name 'local' is reserved for this purpose
|
||||||
|
- from: local
|
||||||
mapping: {
|
mapping: {
|
||||||
"tank/usr/home":"mirrorpool/foo/bar"
|
"tank/usr/home":"mirrorpool/foo/bar"
|
||||||
}
|
}
|
||||||
@ -79,3 +74,10 @@ sinks:
|
|||||||
"*": backups/special_snowflake/remainingbackup
|
"*": backups/special_snowflake/remainingbackup
|
||||||
# NOTE: ^ alignment, should be possible, looks nicer
|
# NOTE: ^ alignment, should be possible, looks nicer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pull_acls:
|
||||||
|
# same synatx as in sinks, but the returned mapping does not matter
|
||||||
|
- from: office_backup
|
||||||
|
mapping: {
|
||||||
|
"tank/usr/home":"notnull"
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user