mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-22 16:34:32 +01:00
e70b6f3071
Done: * implement autosnapper that asserts interval between snapshots * implement pruner * job pull: pulling + pruning * job source: autosnapping + serving TODO * job source: pruning * job local: everything * fatal errors such as serve that cannot bind socket must be more visible * couldn't things that need a snapshotprefix just use a interface Prefixer() instead? then we could have prefixsnapshotfilter and not duplicate it every time... * either go full context.Context or not at all...? just wait because community climate around it isn't that great and we only need it for cancellation? roll our own?
34 lines
717 B
Go
34 lines
717 B
Go
package cmd
|
|
|
|
import (
|
|
"github.com/pkg/errors"
|
|
"github.com/zrepl/zrepl/zfs"
|
|
"strings"
|
|
)
|
|
|
|
type PrefixSnapshotFilter struct {
|
|
Prefix string
|
|
}
|
|
|
|
func parseSnapshotPrefix(i string) (p string, err error) {
|
|
if len(i) <= 0 {
|
|
err = errors.Errorf("snapshot prefix must not be empty string")
|
|
return
|
|
}
|
|
p = i
|
|
return
|
|
}
|
|
|
|
func parsePrefixSnapshotFilter(i string) (f *PrefixSnapshotFilter, err error) {
|
|
if !(len(i) > 0) {
|
|
err = errors.Errorf("snapshot prefix must be longer than 0 characters")
|
|
return
|
|
}
|
|
f = &PrefixSnapshotFilter{i}
|
|
return
|
|
}
|
|
|
|
func (f *PrefixSnapshotFilter) Filter(fsv zfs.FilesystemVersion) (accept bool, err error) {
|
|
return fsv.Type == zfs.Snapshot && strings.HasPrefix(fsv.Name, f.Prefix), nil
|
|
}
|