Documentation
¶
Overview ¶
Package workspace manages the user's workspace: workspace.yaml, the collections mounted into it, and its private data directory. A workspace is never stored in a collection repository.
Index ¶
- Constants
- Variables
- func CheckMounts(ws model.Workspace, home string, exists func(string) bool) diag.List
- func DataDir(p settings.Paths, name string, collection model.ID) string
- func Dir(p settings.Paths, name string) string
- func DirExists(path string) bool
- func DraftsDir(p settings.Paths, name string) string
- func EnvironmentsDir(p settings.Paths, name string) string
- func ExpandPath(path, home string) string
- func KeptDir(p settings.Paths, name string) string
- func LegacyDraftsDir(p settings.Paths, name string) string
- func LoadOrCreate(p settings.Paths, name string, c Codec, idSource *ids.Source) (model.Workspace, diag.List, error)
- func Mount(ws model.Workspace, id model.ID, path string, resolve PathResolver) (model.Workspace, error)
- func Relocate(ws model.Workspace, id model.ID, path string) (model.Workspace, error)
- func Save(p settings.Paths, c Codec, ws model.Workspace) error
- func TrashDir(p settings.Paths, name string) string
- func Unmount(ws model.Workspace, id model.ID) (model.Workspace, error)
- func UserDir(p settings.Paths, name, user string) string
- type Codec
- type PathResolver
Constants ¶
const DefaultName = "default"
DefaultName is the workspace used when none is named.
const DefaultUser = "default"
DefaultUser is the user everything a person makes in the app belongs to. There is only one for now; the directory layout is ready for more.
Variables ¶
var ( ErrAlreadyMounted = errors.New("collection already mounted") ErrNotMounted = errors.New("collection not mounted") )
Mount errors.
Functions ¶
func CheckMounts ¶
CheckMounts reports every mount whose directory does not exist.
func DataDir ¶
DataDir holds run history, saved responses and cookies for one collection in the named workspace.
func DraftsDir ¶
DraftsDir holds the named workspace's drafts: collections the user has not saved to a folder of their own yet.
func EnvironmentsDir ¶
EnvironmentsDir holds the workspace's environments. They belong to the workspace, not to a collection: every collection sees the same set, and the files are personal (never committed with a collection).
func ExpandPath ¶
ExpandPath replaces a leading "~" or "~/" with home. "~user" forms are left alone: Flow-I does not look up other users' home directories.
func KeptDir ¶
KeptDir holds the unsaved edits of flows that were kept when the app quit, one file per flow, until the flow is opened again.
func LegacyDraftsDir ¶
LegacyDraftsDir is where drafts lived before they belonged to a user. Drafts already there stay there and are still drafts.
func LoadOrCreate ¶
func LoadOrCreate(p settings.Paths, name string, c Codec, idSource *ids.Source) (model.Workspace, diag.List, error)
LoadOrCreate reads the named workspace, creating it with a fresh id on first use.
func Mount ¶
func Mount(ws model.Workspace, id model.ID, path string, resolve PathResolver) (model.Workspace, error)
Mount returns a copy of ws with the collection added. The path is kept as given (so "~" survives), but duplicates are detected on the resolved path.
func Save ¶
Save writes workspace.yaml atomically. Its location comes from ws.File, or the default location for the workspace's directory when unset.
Types ¶
type Codec ¶
type Codec interface {
DecodeWorkspace(file string, data []byte) (model.Workspace, diag.List)
EncodeWorkspace(model.Workspace) ([]byte, error)
}
Codec converts workspace.yaml to and from the model.
type PathResolver ¶
PathResolver turns a mount path into a comparable form (absolute, with symlinks resolved). Injected so tests need no real filesystem.