Documentation
¶
Overview ¶
Package datastore provides a high-level interface for managing dodot's internal state on the filesystem. It abstracts away the physical layout of the data directory, providing a clean API for handlers and executors.
Index ¶
- type DataStore
- type MemoryFS
- func (m *MemoryFS) ClearErrors()
- func (m *MemoryFS) CreateFileWithContent(path string, content string) error
- func (m *MemoryFS) FileExists(path string) bool
- func (m *MemoryFS) GetLinkTarget(path string) (string, error)
- func (m *MemoryFS) GetReadCount() int
- func (m *MemoryFS) GetWriteCount() int
- func (m *MemoryFS) IsSymlink(path string) bool
- func (m *MemoryFS) Lstat(name string) (fs.FileInfo, error)
- func (m *MemoryFS) MkdirAll(path string, perm fs.FileMode) error
- func (m *MemoryFS) ReadDir(name string) ([]fs.DirEntry, error)
- func (m *MemoryFS) ReadFile(name string) ([]byte, error)
- func (m *MemoryFS) Readlink(name string) (string, error)
- func (m *MemoryFS) Remove(name string) error
- func (m *MemoryFS) RemoveAll(path string) error
- func (m *MemoryFS) Rename(oldpath, newpath string) error
- func (m *MemoryFS) SetError(path string, err error)
- func (m *MemoryFS) Stat(name string) (fs.FileInfo, error)
- func (m *MemoryFS) String() string
- func (m *MemoryFS) Symlink(oldname, newname string) error
- func (m *MemoryFS) WriteFile(name string, data []byte, perm fs.FileMode) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataStore ¶
type DataStore interface {
// CreateDataLink links a source file into the datastore structure.
// Returns the path to the created link in the datastore.
// This is step 1 for handlers that need to stage files.
CreateDataLink(pack, handlerName, sourceFile string) (datastorePath string, err error)
// CreateUserLink creates a user-visible symlink.
// This is step 2 for the symlink handler to make files accessible.
// Other handlers don't need this - their files are accessed via shell init.
CreateUserLink(datastorePath, userPath string) error
// RunAndRecord executes a command and records completion with a sentinel.
// This is idempotent - if the sentinel exists, the command is not re-run.
// Used by provisioning handlers (install, homebrew) to track completion.
RunAndRecord(pack, handlerName, command, sentinel string) error
// HasSentinel checks if an operation has been completed.
// This enables idempotent operations and status reporting.
HasSentinel(pack, handlerName, sentinel string) (bool, error)
// RemoveState removes all state for a handler in a pack.
// This is used for cleanup/uninstall operations.
RemoveState(pack, handlerName string) error
// HasHandlerState checks if any state exists for a handler in a pack.
// This is useful for determining if a handler has been used/provisioned.
HasHandlerState(pack, handlerName string) (bool, error)
// ListPackHandlers returns a list of all handlers that have state for a given pack.
// This helps identify which handlers have been used in a pack.
ListPackHandlers(pack string) ([]string, error)
// ListHandlerSentinels returns all sentinel files for a specific handler in a pack.
// This provides detailed information about what operations have been completed.
ListHandlerSentinels(pack, handlerName string) ([]string, error)
}
DataStore represents dodot's simplified storage interface. This interface has only 5 operations instead of the previous 20+. The simplicity is intentional - handlers contain logic, not the storage layer.
type MemoryFS ¶
type MemoryFS struct {
// contains filtered or unexported fields
}
MemoryFS implements types.FS interface with in-memory storage for testing
func NewMemoryFS ¶
func NewMemoryFS() *MemoryFS
NewMemoryFS creates a new in-memory filesystem for testing
func (*MemoryFS) ClearErrors ¶
func (m *MemoryFS) ClearErrors()
ClearErrors removes all error injections
func (*MemoryFS) CreateFileWithContent ¶
CreateFileWithContent is a helper to create a file with content
func (*MemoryFS) FileExists ¶
FileExists checks if a file exists
func (*MemoryFS) GetLinkTarget ¶
GetLinkTarget returns the target of a symlink
func (*MemoryFS) GetReadCount ¶
GetReadCount returns the number of read operations
func (*MemoryFS) GetWriteCount ¶
GetWriteCount returns the number of write operations