From 6da2deb96ea003bba3447c01c730a3448738e6b0 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sun, 30 Apr 2017 17:56:11 +0200 Subject: [PATCH] config: fix mapping parser --- cmd/config.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index a38c769..e50fbf7 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -225,6 +225,7 @@ func parsePulls(v interface{}, pl poolLookup) (p []Pull, err error) { return } } + pull := Pull{ From: fromPool, } @@ -280,11 +281,11 @@ func parseClientMapping(v interface{}) (s ClientMapping, err error) { func parseComboMapping(m map[string]string) (c zfs.ComboMapping, err error) { - c.Mappings = make([]zfs.DatasetMapping, len(m)) + c.Mappings = make([]zfs.DatasetMapping, 0, len(m)) for lhs, rhs := range m { - if lhs[0] == '|' { + if lhs == "|" { if len(m) != 1 { err = errors.New("non-recursive mapping must be the only mapping for a sink") @@ -300,7 +301,7 @@ func parseComboMapping(m map[string]string) (c zfs.ComboMapping, err error) { c.Mappings = append(c.Mappings, m) - } else if lhs[0] == '*' { + } else if lhs == "*" && strings.HasPrefix(rhs, "!") { m := zfs.ExecMapping{} fields := strings.Fields(strings.TrimPrefix(rhs, "!"))