Documentation
¶
Index ¶
- func Escape(path string) string
- func FSContainsFiles(fsys fs.FS) (bool, error)
- func HashDirectory(root string) (string, error)
- func HashFS(fsys fs.FS) (string, error)
- func MapFS(m map[string]string) fs.FS
- func NewEscapeFS(f fs.ReadDirFS) fs.ReadDirFS
- func NewFilterFS(fs fs.FS, include []string, exclude []string) (fs.FS, error)
- func NewTraceFS(fsys fs.FS) fs.FS
- func Walk(fs_ fs.FS)
- type FilterFS
- type TraceFS
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FSContainsFiles ¶
FSContainsFiles returns true if the given fs.FS contains any files, and false otherwise.
func HashDirectory ¶ added in v0.6.0
HashDirectory computes a deterministic SHA-256 hash over all files in a directory tree. Files are sorted by their relative path, and each file contributes its relative path (null-terminated) followed by its contents to the hash. An empty directory produces the hash of an empty input.
func HashFS ¶ added in v0.6.0
HashFS computes a deterministic SHA-256 hash over all files in an fs.FS. Files are sorted by path, each contributing its path (null-terminated) followed by its contents.
func NewFilterFS ¶
NewFilterFS takes an fs.FS instance and lists of glob strings to be included and excluded. On Open(), it'll return `fs.ErrNotExist` if the file is excluded, or if the include list is non-empty and the file wasn't explicitly included. Both glob lists expect /-separated paths. On ReadDir(), the same logic applies, except that any directory is returned, unless it is explicitly excluded. With typical usage, it'll result in many empty directories; but for our use case of feeding the `fs.FS` into OPA's bundle build machinery, that doesn't make a difference. Filtering by ReadDir() lets us avoid listing files that we'll not allow access to. When building a bundle using fs.FS, not doing this would give us "file does not exist" errors for excluded files.