Documentation ¶
Overview ¶
Package osfs provides a billy filesystem for the OS.
Index ¶
- Variables
- func New(baseDir string, opts ...Option) billy.Filesystem
- type BoundOS
- func (fs *BoundOS) Chroot(path string) (billy.Filesystem, error)
- func (fs *BoundOS) Create(filename string) (billy.File, error)
- func (fs *BoundOS) Join(elem ...string) string
- func (fs *BoundOS) Lstat(filename string) (os.FileInfo, error)
- func (fs *BoundOS) MkdirAll(path string, perm os.FileMode) error
- func (fs *BoundOS) Open(filename string) (billy.File, error)
- func (fs *BoundOS) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error)
- func (fs *BoundOS) ReadDir(path string) ([]os.FileInfo, error)
- func (fs *BoundOS) Readlink(link string) (string, error)
- func (fs *BoundOS) Remove(filename string) error
- func (fs *BoundOS) RemoveAll(path string) error
- func (fs *BoundOS) Rename(from, to string) error
- func (fs *BoundOS) Root() string
- func (fs *BoundOS) Stat(filename string) (os.FileInfo, error)
- func (fs *BoundOS) Symlink(target, link string) error
- func (fs *BoundOS) TempFile(dir, prefix string) (billy.File, error)
- type ChrootOS
- func (fs *ChrootOS) Capabilities() billy.Capability
- func (fs *ChrootOS) Create(filename string) (billy.File, error)
- func (fs *ChrootOS) Join(elem ...string) string
- func (fs *ChrootOS) Lstat(filename string) (os.FileInfo, error)
- func (fs *ChrootOS) MkdirAll(path string, perm os.FileMode) error
- func (fs *ChrootOS) Open(filename string) (billy.File, error)
- func (fs *ChrootOS) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error)
- func (fs *ChrootOS) ReadDir(dir string) ([]os.FileInfo, error)
- func (fs *ChrootOS) Readlink(link string) (string, error)
- func (fs *ChrootOS) Remove(filename string) error
- func (fs *ChrootOS) RemoveAll(path string) error
- func (fs *ChrootOS) Rename(from, to string) error
- func (fs *ChrootOS) Stat(filename string) (os.FileInfo, error)
- func (fs *ChrootOS) Symlink(target, link string) error
- func (fs *ChrootOS) TempFile(dir, prefix string) (billy.File, error)
- type Option
- type Type
Constants ¶
This section is empty.
Variables ¶
var Default = &ChrootOS{}
Default Filesystem representing the root of the os filesystem.
Functions ¶
Types ¶
type BoundOS ¶ added in v5.5.0
type BoundOS struct {
// contains filtered or unexported fields
}
BoundOS is a fs implementation based on the OS filesystem which is bound to a base dir. Prefer this fs implementation over ChrootOS.
Behaviours of note:
- Read and write operations can only be directed to files which descends from the base dir.
- Symlinks don't have their targets modified, and therefore can point to locations outside the base dir or to non-existent paths.
- Readlink and Lstat ensures that the link file is located within the base dir, evaluating any symlinks that file or base dir may contain.
func (*BoundOS) Chroot ¶ added in v5.5.0
Chroot returns a new OS filesystem, with the base dir set to the result of joining the provided path with the underlying base dir.
func (*BoundOS) Root ¶ added in v5.5.0
Root returns the current base dir of the billy.Filesystem. This is required in order for this implementation to be a drop-in replacement for other upstream implementations (e.g. memory and osfs).
type ChrootOS ¶ added in v5.5.0
type ChrootOS struct{}
ChrootOS is a legacy filesystem based on a "soft chroot" of the os filesystem. Although this is still the default os filesystem, consider using BoundOS instead.
Behaviours of note:
- A "soft chroot" translates the base dir to "/" for the purposes of the fs abstraction.
- Symlinks targets may be modified to be kept within the chroot bounds.
- Some file modes does not pass-through the fs abstraction.
- The combination of 1 and 2 may cause go-git to think that a Git repository is dirty, when in fact it isn't.
func (*ChrootOS) Capabilities ¶ added in v5.5.0
func (fs *ChrootOS) Capabilities() billy.Capability
Capabilities implements the Capable interface.
type Option ¶ added in v5.5.0
type Option func(*options)
func WithBoundOS ¶ added in v5.5.0
func WithBoundOS() Option
WithBoundOS returns the option of using a Bound filesystem OS.
func WithChrootOS ¶ added in v5.5.0
func WithChrootOS() Option
WithChrootOS returns the option of using a Chroot filesystem OS.
func WithDeduplicatePath ¶ added in v5.5.0
WithDeduplicatePath toggles the deduplication of the base dir in the path. This occurs when absolute links are being used. Assuming base dir /base/dir and an absolute symlink /base/dir/target:
With DeduplicatePath (default): /base/dir/target Without DeduplicatePath: /base/dir/base/dir/target
This option is only used by the BoundOS OS type.