Documentation
¶
Overview ¶
internal/appstate/lock.go
Package appstate centralises all filesystem state access for the Omniview application, providing a single source of truth for the state directory root.
internal/appstate/scoped.go
Index ¶
- func ResolveRoot() (string, error)
- type Option
- type ScopedRoot
- func (s *ScopedRoot) Close() error
- func (s *ScopedRoot) FS() fs.FS
- func (s *ScopedRoot) MkdirAll(path string, perm fs.FileMode) error
- func (s *ScopedRoot) OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)
- func (s *ScopedRoot) ReadDir(name string) ([]fs.DirEntry, error)
- func (s *ScopedRoot) ReadFile(name string) ([]byte, error)
- func (s *ScopedRoot) Remove(name string) error
- func (s *ScopedRoot) RemoveAll(name string) error
- func (s *ScopedRoot) Rename(oldpath, newpath string) error
- func (s *ScopedRoot) ResolvePath(name string) string
- func (s *ScopedRoot) Stat(name string) (fs.FileInfo, error)
- func (s *ScopedRoot) WriteFile(name string, data []byte, perm fs.FileMode) error
- type Service
- func (s *Service) Close() error
- func (s *Service) Logs() *ScopedRoot
- func (s *Service) PluginData(id string) (*ScopedRoot, error)
- func (s *Service) PluginStore(id string) (*ScopedRoot, error)
- func (s *Service) Plugins() *ScopedRoot
- func (s *Service) Root() string
- func (s *Service) RootDir() *ScopedRoot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveRoot ¶
ResolveRoot determines the application state directory. Priority: OMNIVIEW_STATE_DIR env var > buildStateDir ldflags > ~/.omniview. Exported for use by secondary binaries (e.g., cmd/omniview-plugin-dev).
Types ¶
type ScopedRoot ¶
type ScopedRoot struct {
// contains filtered or unexported fields
}
ScopedRoot provides contained filesystem access to a subdirectory. All path arguments are relative to the scope root. The underlying os.Root enforces containment at the kernel level.
func (*ScopedRoot) Close ¶
func (s *ScopedRoot) Close() error
Close releases the underlying os.Root handle.
func (*ScopedRoot) FS ¶
func (s *ScopedRoot) FS() fs.FS
func (*ScopedRoot) ReadDir ¶
func (s *ScopedRoot) ReadDir(name string) ([]fs.DirEntry, error)
ReadDir reads the named directory relative to the scoped root. Implemented as Open + (*File).ReadDir since os.Root does not expose ReadDir.
func (*ScopedRoot) Remove ¶
func (s *ScopedRoot) Remove(name string) error
func (*ScopedRoot) RemoveAll ¶
func (s *ScopedRoot) RemoveAll(name string) error
func (*ScopedRoot) Rename ¶
func (s *ScopedRoot) Rename(oldpath, newpath string) error
func (*ScopedRoot) ResolvePath ¶
func (s *ScopedRoot) ResolvePath(name string) string
ResolvePath returns the absolute path for a relative name within the scoped root. If name is empty, the root path itself is returned. If name fails validation (e.g. absolute path or traversal), the root path is returned as a safe fallback.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the central authority for all application state filesystem access. Create once at startup via New() and inject into subsystems.
func NewTestService ¶
NewTestService creates a Service backed by a temporary directory for use in tests. The service is automatically cleaned up when the test finishes.
func (*Service) Close ¶
Close releases all resources held by the Service. Errors from individual close operations are aggregated and returned together. Close is idempotent; subsequent calls return the result of the first call.
func (*Service) Logs ¶
func (s *Service) Logs() *ScopedRoot
Logs returns the scoped root for the logs directory.
func (*Service) PluginData ¶
func (s *Service) PluginData(id string) (*ScopedRoot, error)
PluginData returns a scoped root for a specific plugin's data directory. The result is cached; subsequent calls for the same id return the cached instance.
func (*Service) PluginStore ¶
func (s *Service) PluginStore(id string) (*ScopedRoot, error)
PluginStore returns a scoped root for a specific plugin's store directory. The result is cached; subsequent calls for the same id return the cached instance.
func (*Service) Plugins ¶
func (s *Service) Plugins() *ScopedRoot
Plugins returns the scoped root for the plugins directory.
func (*Service) RootDir ¶
func (s *Service) RootDir() *ScopedRoot
RootDir returns the scoped root for the top-level state directory.