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:
Christian Schwarz
2017-09-10 16:13:05 +02:00
parent 8bf3516003
commit 73c9033583
20 changed files with 865 additions and 1291 deletions

View File

@ -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
}