1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2025-07-01 05:28:30 +00:00

walk: implement FsEval hooks

In certain circumstances (such as the manifest generation of a
filesystem as an unprivileged user) it is important to provide hooks
that override the default os.* implementation of filesystem-related
functions.

In order to avoid merging too much code from outside projects (such as
umoci) this is implemented by providing FsEval hooks to Walk() and
Check(). This allows for users of go-mtree to modify how filesystem
checks are done, without compromising the simplicity of go-mtree's code.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
Aleksa Sarai 2016-11-18 18:53:26 +11:00
parent 98824a87da
commit e22043cb86
No known key found for this signature in database
GPG key ID: 9E18AA267DDB8DB4
9 changed files with 110 additions and 57 deletions

View file

@ -26,7 +26,7 @@ func ExampleStreamer() {
// handle error ...
}
res, err := Check("/tmp/dir/", dh, nil)
res, err := Check("/tmp/dir/", dh, nil, nil)
if err != nil {
// handle error ...
}
@ -145,7 +145,7 @@ func TestArchiveCreation(t *testing.T) {
}
// Test the tar manifest against the actual directory
res, err := Check("./testdata/collection", tdh, []Keyword{"sha1"})
res, err := Check("./testdata/collection", tdh, []Keyword{"sha1"}, nil)
if err != nil {
t.Fatal(err)
}
@ -170,7 +170,7 @@ func TestArchiveCreation(t *testing.T) {
}
// Validate the directory manifest against the archive
dh, err := Walk("./testdata/collection", nil, []Keyword{"sha1"})
dh, err := Walk("./testdata/collection", nil, []Keyword{"sha1"}, nil)
if err != nil {
t.Fatal(err)
}
@ -224,7 +224,7 @@ func TestTreeTraversal(t *testing.T) {
}
// top-level "." directory will contain contents of traversal.tar
res, err = Check("./testdata/.", tdh, []Keyword{"sha1"})
res, err = Check("./testdata/.", tdh, []Keyword{"sha1"}, nil)
if err != nil {
t.Fatal(err)
}
@ -262,7 +262,7 @@ func TestTreeTraversal(t *testing.T) {
}
// Implied top-level "." directory will contain the contents of singlefile.tar
res, err = Check("./testdata/.", tdh, []Keyword{"sha1"})
res, err = Check("./testdata/.", tdh, []Keyword{"sha1"}, nil)
if err != nil {
t.Fatal(err)
}