From 301be177ea19dc3ff3da842e405d45c717aa0fb0 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Mon, 1 May 2017 20:07:57 +0200 Subject: [PATCH] config: fix broken parsing of direct mapping Would only parse wildcard ('|') DirectMapping but no specific direct mappings. --- cmd/config.go | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index e50fbf7..05e92d8 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -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) + } }