mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-21 16:03:32 +01:00
config: fix broken parsing of direct mapping
Would only parse wildcard ('|') DirectMapping but no specific direct mappings.
This commit is contained in:
parent
b87829817a
commit
301be177ea
@ -285,23 +285,7 @@ func parseComboMapping(m map[string]string) (c zfs.ComboMapping, err error) {
|
||||
|
||||
for lhs, rhs := range m {
|
||||
|
||||
if lhs == "|" {
|
||||
|
||||
if len(m) != 1 {
|
||||
err = errors.New("non-recursive mapping must be the only mapping for a sink")
|
||||
}
|
||||
|
||||
m := zfs.DirectMapping{
|
||||
Source: nil,
|
||||
}
|
||||
|
||||
if m.Target, err = zfs.NewDatasetPath(rhs); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
c.Mappings = append(c.Mappings, m)
|
||||
|
||||
} else if lhs == "*" && strings.HasPrefix(rhs, "!") {
|
||||
if lhs == "*" && strings.HasPrefix(rhs, "!") {
|
||||
|
||||
m := zfs.ExecMapping{}
|
||||
fields := strings.Fields(strings.TrimPrefix(rhs, "!"))
|
||||
@ -329,6 +313,24 @@ func parseComboMapping(m map[string]string) (c zfs.ComboMapping, err error) {
|
||||
|
||||
c.Mappings = append(c.Mappings, m)
|
||||
|
||||
} else {
|
||||
|
||||
m := zfs.DirectMapping{}
|
||||
|
||||
if lhs == "|" {
|
||||
m.Source = nil
|
||||
} else {
|
||||
if m.Source, err = zfs.NewDatasetPath(lhs); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if m.Target, err = zfs.NewDatasetPath(rhs); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
c.Mappings = append(c.Mappings, m)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user