mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-25 09:54:47 +01:00
zfs: Support foo/bar/* globs
This commit is contained in:
parent
5f84d30972
commit
d8adce6110
@ -64,7 +64,11 @@ func (m GlobMapping) Map(source DatasetPath) (target DatasetPath, err error) {
|
||||
for si, sc := range source {
|
||||
target = append(target, sc)
|
||||
if si < len(m.PrefixPath) {
|
||||
if sc != m.PrefixPath[si] {
|
||||
|
||||
compsMatch := sc == m.PrefixPath[si]
|
||||
endOfPrefixPath := si == len(m.PrefixPath)-1 && m.PrefixPath[si] == ""
|
||||
|
||||
if !(compsMatch || endOfPrefixPath) {
|
||||
err = NoMatchError
|
||||
return
|
||||
}
|
||||
|
@ -5,6 +5,27 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGlobMappingPrefixWildcard(t *testing.T) {
|
||||
|
||||
m := GlobMapping{
|
||||
PrefixPath: toDatasetPath("a/b/c/"), // TRAILING empty component!
|
||||
TargetRoot: toDatasetPath("x/y"),
|
||||
}
|
||||
|
||||
t.Logf("PrefixPath: %#v", m.PrefixPath)
|
||||
|
||||
var r DatasetPath
|
||||
var err error
|
||||
|
||||
r, err = m.Map(toDatasetPath("a/b/c"))
|
||||
assert.NotNil(t, err)
|
||||
|
||||
r, err = m.Map(toDatasetPath("a/b/c/d"))
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, toDatasetPath("x/y/a/b/c/d"), r)
|
||||
|
||||
}
|
||||
|
||||
func TestGlobMapping(t *testing.T) {
|
||||
|
||||
m := GlobMapping{
|
||||
|
Loading…
Reference in New Issue
Block a user