Skip to content

Commit a5eb19e

Browse files
committed
osfs: Ensure BoundOS.Chroot returns another BoundOS fs
Signed-off-by: Paulo Gomes <[email protected]>
1 parent 4504880 commit a5eb19e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

osfs/os_bound.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,14 @@ func (fs *BoundOS) Readlink(link string) (string, error) {
217217
return os.Readlink(link)
218218
}
219219

220-
// Chroot returns a new OS filesystem, with the base dir set to the
220+
// Chroot returns a new BoundOS filesystem, with the base dir set to the
221221
// result of joining the provided path with the underlying base dir.
222222
func (fs *BoundOS) Chroot(path string) (billy.Filesystem, error) {
223223
joined, err := securejoin.SecureJoin(fs.baseDir, path)
224224
if err != nil {
225225
return nil, err
226226
}
227-
return New(joined), nil
227+
return New(joined, WithBoundOS()), nil
228228
}
229229

230230
// Root returns the current base dir of the billy.Filesystem.

osfs/os_bound_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ func TestChroot(t *testing.T) {
285285
g.Expect(err).ToNot(gomega.HaveOccurred())
286286
g.Expect(f).ToNot(gomega.BeNil())
287287
g.Expect(f.Root()).To(gomega.Equal(filepath.Join(tmp, "test")))
288+
g.Expect(f).Should(gomega.BeAssignableToTypeOf(&BoundOS{}))
288289
}
289290

290291
func TestRoot(t *testing.T) {

0 commit comments

Comments
 (0)