Make zfs.DatasetPath json.Marshaler and json.Unmarshaler

Had to resort to using pointers to zfs.DatasetPath everywhere... Should
find a better solution for that.
This commit is contained in:
Christian Schwarz
2017-08-06 13:04:29 +02:00
parent 2ce07c9342
commit cba083cadf
11 changed files with 75 additions and 57 deletions

View File

@ -3,10 +3,10 @@ package zfs
import "fmt"
type DatasetFilter interface {
Filter(p DatasetPath) (pass bool, err error)
Filter(p *DatasetPath) (pass bool, err error)
}
func ZFSListMapping(filter DatasetFilter) (datasets []DatasetPath, err error) {
func ZFSListMapping(filter DatasetFilter) (datasets []*DatasetPath, err error) {
if filter == nil {
panic("filter must not be nil")
@ -15,11 +15,11 @@ func ZFSListMapping(filter DatasetFilter) (datasets []DatasetPath, err error) {
var lines [][]string
lines, err = ZFSList([]string{"name"}, "-r", "-t", "filesystem,volume")
datasets = make([]DatasetPath, 0, len(lines))
datasets = make([]*DatasetPath, 0, len(lines))
for _, line := range lines {
var path DatasetPath
var path *DatasetPath
if path, err = NewDatasetPath(line[0]); err != nil {
return
}