mirror of
https://github.com/zrepl/zrepl.git
synced 2025-08-16 09:57:49 +02:00
WIP: Switch to new config format.
Don't use jobrun for daemon, just call JobDo() once, the job must organize stuff itself. Sacrifice all the oneshot commands, they will be reintroduced as client-calls to the daemon.
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/zrepl/zrepl/zfs"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
type DatasetMapFilter struct {
|
||||
@ -23,8 +24,8 @@ type datasetMapFilterEntry struct {
|
||||
subtreeMatch bool
|
||||
}
|
||||
|
||||
func NewDatasetMapFilter(capacity int, filterOnly bool) DatasetMapFilter {
|
||||
return DatasetMapFilter{
|
||||
func NewDatasetMapFilter(capacity int, filterOnly bool) *DatasetMapFilter {
|
||||
return &DatasetMapFilter{
|
||||
entries: make([]datasetMapFilterEntry, 0, capacity),
|
||||
filterOnly: filterOnly,
|
||||
}
|
||||
@ -158,3 +159,21 @@ func parseDatasetFilterResult(result string) (pass bool, err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func parseDatasetMapFilter(mi interface{}, filterOnly bool) (f *DatasetMapFilter, err error) {
|
||||
|
||||
var m map[string]string
|
||||
if err = mapstructure.Decode(mi, &m); err != nil {
|
||||
err = fmt.Errorf("maps / filters must be specified as map[string]string: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
f = NewDatasetMapFilter(len(m), filterOnly)
|
||||
for pathPattern, mapping := range m {
|
||||
if err = f.Add(pathPattern, mapping); err != nil {
|
||||
err = fmt.Errorf("invalid mapping entry ['%s':'%s']: %s", pathPattern, mapping, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user