Documentation
¶
Overview ¶
Package vfs abstracts the file-reading operations the scanner performs during cross-file resolution (Terraform sibling/variable globs, module directory reads, $ref includes). The CLI uses DiskFS — a thin passthrough to the real filesystem, behaviorally identical to direct os.* calls. The HTTP server uses an in-memory implementation built from content pushed over the wire, so it can resolve unsaved editor buffers and browser web-shell files that never touch disk.
The interface deliberately mirrors os/filepath (absolute OS paths, filepath glob semantics) rather than io/fs.FS, because the readers it serves operate on absolute paths and use filepath.Glob.
Index ¶
- type DiskFS
- type FS
- type MemFS
- func (m *MemFS) Abs(name string) (string, error)
- func (m *MemFS) Glob(pattern string) ([]string, error)
- func (m *MemFS) MissingFiles() []string
- func (m *MemFS) Paths() []string
- func (m *MemFS) ReadDir(name string) ([]fs.DirEntry, error)
- func (m *MemFS) ReadFile(name string) ([]byte, error)
- func (m *MemFS) Stat(name string) (fs.FileInfo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiskFS ¶
type DiskFS struct{}
DiskFS is the real-filesystem implementation used by the CLI. Each method is a direct passthrough to os/filepath, so threading DiskFS through the resolution code is behavior-preserving.
type FS ¶
type FS interface {
// ReadFile reads the named file and returns its contents.
ReadFile(name string) ([]byte, error)
// Stat returns file info for the named file.
Stat(name string) (fs.FileInfo, error)
// ReadDir reads the named directory, returning its entries.
ReadDir(name string) ([]fs.DirEntry, error)
// Glob returns the names matching pattern (filepath.Glob semantics).
Glob(pattern string) ([]string, error)
// Abs resolves name against the filesystem's root.
Abs(name string) (string, error)
}
FS is the set of read operations the cross-file resolution code performs.
type MemFS ¶
type MemFS struct {
// contains filtered or unexported fields
}
MemFS is an in-memory FS built from content pushed over HTTP. Keys are normalized (cleaned, forward-slash) paths. It is request-scoped: a fresh instance is built per analyze request, so the missing-file set it accumulates belongs to exactly one scan and never leaks across requests.
Concurrency: Terraform module enrichment runs reader goroutines, so all access is guarded by a mutex.
func NewMemFS ¶
NewMemFS builds a MemFS from a path -> content map. Keys are normalized so they match the paths the Terraform readers compute via filepath.Join/Dir.
func (*MemFS) Abs ¶
Abs keeps the path workspace-relative. This keeps Terraform module and missing-file paths relative to the request's own workspace, which is correct even when a single server process serves many IDE workspaces.
func (*MemFS) Glob ¶
Glob returns pushed paths matching pattern (filepath.Glob semantics over the single directory level the Terraform readers use, e.g. "<dir>/*.tf"). A non-match is never recorded — an empty glob is legal, exactly as on disk.
func (*MemFS) MissingFiles ¶
MissingFiles returns the sorted set of paths the scan referenced but that were not pushed — the escalation list returned to the IDE.
func (*MemFS) Paths ¶
Paths returns the sorted set of pushed file paths (used to seed the scan's file set in server mode).
func (*MemFS) ReadDir ¶
ReadDir returns the immediate children of a directory synthesized from the pushed file keys. A miss (no file lives under the directory) is recorded: an absent directory is the primary escalation signal (a Terraform module whose source directory was not pushed).
func (*MemFS) ReadFile ¶
ReadFile returns a copy of the named file's content, or fs.ErrNotExist if it was not pushed (recording the miss for the escalation list).