From 7e442ea0eac711e88ad9f6e93b57d6b2dcb0a5a5 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sat, 2 Sep 2017 12:40:22 +0200 Subject: [PATCH] cmd: remove legacy NoMatchError --- cmd/config_mapfilter.go | 5 +---- cmd/replication.go | 10 +++++----- cmd/test.go | 6 +++++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cmd/config_mapfilter.go b/cmd/config_mapfilter.go index 7ea2589..8d7e4b3 100644 --- a/cmd/config_mapfilter.go +++ b/cmd/config_mapfilter.go @@ -1,7 +1,6 @@ package cmd import ( - "errors" "fmt" "strings" @@ -24,8 +23,6 @@ type datasetMapFilterEntry struct { subtreeMatch bool } -var NoMatchError error = errors.New("no match found in mapping") - func NewDatasetMapFilter(capacity int, filterOnly bool) DatasetMapFilter { return DatasetMapFilter{ entries: make([]datasetMapFilterEntry, 0, capacity), @@ -111,7 +108,7 @@ func (m DatasetMapFilter) Map(source *zfs.DatasetPath) (target *zfs.DatasetPath, mi, hasMapping := m.mostSpecificPrefixMapping(source) if !hasMapping { - err = NoMatchError + return nil, nil return } me := m.entries[mi] diff --git a/cmd/replication.go b/cmd/replication.go index 608bfe7..0413ffe 100644 --- a/cmd/replication.go +++ b/cmd/replication.go @@ -184,11 +184,11 @@ func doPull(pull PullContext) (err error) { var localFs *zfs.DatasetPath localFs, err = pull.Mapping.Map(remoteFilesystems[fs]) if err != nil { - if err != NoMatchError { - err := fmt.Errorf("error mapping %s: %s", remoteFilesystems[fs], err) - log.Printf("%s", err) - return err - } + err := fmt.Errorf("error mapping %s: %s", remoteFilesystems[fs], err) + log.Printf("%s", err) + return err + } + if localFs == nil { continue } log.Printf("%s => %s", remoteFilesystems[fs].ToString(), localFs.ToString()) diff --git a/cmd/test.go b/cmd/test.go index 0e0a28f..1cf3345 100644 --- a/cmd/test.go +++ b/cmd/test.go @@ -84,7 +84,11 @@ func doTestDatasetMapFilter(cmd *cobra.Command, args []string) { log.Printf("error evaluating mapping: %s", err) os.Exit(1) } - log.Printf("%s => %s", ip.ToString(), res.ToString()) + toStr := "NO MAPPING" + if res != nil { + toStr = res.ToString() + } + log.Printf("%s => %s", ip.ToString(), toStr) }