Documentation ¶
Index ¶
- Constants
- func PlaceWorkspace(rootPath string, opts ...PlaceWorkspaceOpt) error
- type Catalog
- func (cat *Catalog) AddByModuleMirror(ref wfapi.CatalogRef, packType wfapi.Packtype, addr wfapi.WarehouseAddr) error
- func (cat *Catalog) AddByWareMirror(ref wfapi.CatalogRef, wareId wfapi.WareID, addr wfapi.WarehouseAddr) error
- func (cat *Catalog) AddItem(ref wfapi.CatalogRef, wareId wfapi.WareID, overwrite bool) error
- func (cat *Catalog) AddReplay(ref wfapi.CatalogRef, plot wfapi.Plot, overwrite bool) error
- func (cat *Catalog) GetMirror(ref wfapi.CatalogRef) (*wfapi.CatalogMirrors, error)
- func (cat *Catalog) GetModule(ref wfapi.CatalogRef) (*wfapi.CatalogModule, error)
- func (cat *Catalog) GetRelease(ref wfapi.CatalogRef) (*wfapi.CatalogRelease, error)
- func (cat *Catalog) GetReplay(ref wfapi.CatalogRef) (*wfapi.Plot, error)
- func (cat *Catalog) GetWare(ref wfapi.CatalogRef) (*wfapi.WareID, *wfapi.WarehouseAddr, error)
- func (cat *Catalog) Modules() []wfapi.ModuleName
- type PlaceWorkspaceOpt
- type Workspace
- func FindRootWorkspace(fsys fs.FS, basisPath string, searchPath string) (*Workspace, error)
- func FindWorkspace(fsys fs.FS, basisPath, searchPath string) (ws *Workspace, remainingSearchPath string, err error)
- func OpenHomeWorkspace(fsys fs.FS) (*Workspace, error)
- func OpenWorkspace(fsys fs.FS, rootPath string) (*Workspace, error)
- func (ws *Workspace) CachePath(wareId wfapi.WareID) (string, error)
- func (ws *Workspace) CatalogBasePath() string
- func (ws *Workspace) CatalogPath(name string) (string, error)
- func (ws *Workspace) CreateCatalog(name string) error
- func (ws *Workspace) CreateOrOpenCatalog(name string) (Catalog, error)
- func (ws *Workspace) GetCatalogReplay(ref wfapi.CatalogRef) (*wfapi.Plot, error)
- func (ws *Workspace) GetCatalogWare(ref wfapi.CatalogRef) (*wfapi.WareID, *wfapi.WarehouseAddr, error)
- func (ws *Workspace) GetWarehouseAddress() wfapi.WarehouseAddr
- func (ws *Workspace) HasCatalog(name string) (bool, error)
- func (ws *Workspace) InternalPath() string
- func (ws *Workspace) IsHomeWorkspace() bool
- func (ws *Workspace) IsRootWorkspace() bool
- func (ws *Workspace) ListCatalogs() ([]string, error)
- func (ws *Workspace) MemoBasePath() string
- func (ws *Workspace) MemoPath(fid string) string
- func (ws *Workspace) OpenCatalog(name string) (Catalog, error)
- func (ws *Workspace) Path() (fs.FS, string)
- func (ws *Workspace) WarehousePath() string
- type WorkspaceSet
- func (wsSet WorkspaceSet) GetCatalogReplay(ref wfapi.CatalogRef) (*wfapi.Plot, error)
- func (wsSet WorkspaceSet) GetCatalogWare(ref wfapi.CatalogRef) (*wfapi.WareID, *wfapi.WarehouseAddr, error)
- func (wsSet WorkspaceSet) GetWarehouseAddresses() []wfapi.WarehouseAddr
- func (wsSet WorkspaceSet) Local() *Workspace
- func (wsSet WorkspaceSet) Root() *Workspace
- func (wsSet WorkspaceSet) Tidy(ctx context.Context, plot wfapi.Plot, force bool) error
Constants ¶
const (
CatalogNameFormat = `^[A-Za-z0-9][-A-Za-z0-9_.]{0,62}$`
)
Variables ¶
This section is empty.
Functions ¶
func PlaceWorkspace ¶
func PlaceWorkspace(rootPath string, opts ...PlaceWorkspaceOpt) error
PlaceWorkspace places the directory structure down on the filesystem for a workspace to be detected.
Errors:
- warpforge-error-io -- when creating workspace fails
Types ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
The Catalog struct represents a single catalog. All methods of Catalog will operate on that specific catalog. Higher level functionality to traverse multiple catalogs is provided by Workspace and WorkspaceSet structs.
func OpenCatalog ¶
OpenCatalog creates an object that can be used to access catalog data on the local filesystem. It will check if files looking like catalog data exist, and error if not. It also immediately loads a list of available modules into memory.
Note that you can get a similar object through `Workspace.OpenCatalog()`, which is often more convenient.
Errors:
- warpforge-error-io -- when building the module list fails due to I/O error
- warpforge-error-catalog-invalid -- when the catalog does not exist
func (*Catalog) AddByModuleMirror ¶
func (cat *Catalog) AddByModuleMirror( ref wfapi.CatalogRef, packType wfapi.Packtype, addr wfapi.WarehouseAddr) error
Adds a ByModule mirror to a catalog entry
Errors:
- warpforge-error-io -- when reading or writing mirror file fails
- warpforge-error-catalog-parse -- when parsing existing mirror file fails
- warpforge-error-serialization -- when serializing the new mirror file fails
- warpforge-error-catalog-invalid -- when the wrong type of mirror file already exists
func (*Catalog) AddByWareMirror ¶
func (cat *Catalog) AddByWareMirror( ref wfapi.CatalogRef, wareId wfapi.WareID, addr wfapi.WarehouseAddr) error
Adds a ByWare mirror to a catalog entry
Errors:
- warpforge-error-io -- when reading or writing mirror file fails
- warpforge-error-catalog-parse -- when parsing existing mirror file fails
- warpforge-error-serialization -- when serializing the new mirror file fails
- warpforge-error-catalog-invalid -- when the wrong type of mirror file already exists
func (*Catalog) AddItem ¶
Adds a new item to the catalog.
Errors:
- warpforge-error-catalog-parse -- when parsing of the lineage file fails
- warpforge-error-io -- when reading or writing the lineage file fails
- warpforge-error-serialization -- when serializing the lineage fails
- warpforge-error-catalog-invalid -- when an error occurs while searching for module or release
- warpforge-error-already-exists -- when trying to insert an already existing item
func (*Catalog) AddReplay ¶
Add a replay plot to a catalog.
Errors:
- warpforge-error-catalog-invalid -- when the contents of the catalog is invalid
- warpforge-error-catalog-parse -- when parsing of catalog data fails
- warpforge-error-io -- when an io error occurs while opening the catalog
- warpforge-error-serialization -- when the updated structures fail to serialize
func (*Catalog) GetMirror ¶
func (cat *Catalog) GetMirror(ref wfapi.CatalogRef) (*wfapi.CatalogMirrors, error)
Get a catalog mirror for a given catalog reference.
Errors:
- warpforge-error-io -- when reading lineage file fails
- warpforge-error-catalog-parse -- when ipld parsing of mirror file fails
func (*Catalog) GetModule ¶
func (cat *Catalog) GetModule(ref wfapi.CatalogRef) (*wfapi.CatalogModule, error)
Get a module for a given catalog reference.
Errors:
- warpforge-error-io -- when reading module file fails
- warpforge-error-catalog-parse -- when ipld unmarshaling fails
func (*Catalog) GetRelease ¶
func (cat *Catalog) GetRelease(ref wfapi.CatalogRef) (*wfapi.CatalogRelease, error)
Get a release from a given catalog.
Errors:
- warpforge-error-io -- when reading of lineage or mirror files fails
- warpforge-error-catalog-parse -- when ipld parsing of lineage or mirror files fails
- warpforge-error-catalog-invalid -- when catalog files or entries are not found
func (*Catalog) GetReplay ¶
Get a replay plot from a catalog.
Errors:
- warpforge-error-catalog-invalid -- when the contents of the catalog is invalid
- warpforge-error-catalog-parse -- when parsing of catalog data fails
- warpforge-error-io -- when an io error occurs while opening the catalog
func (*Catalog) GetWare ¶
func (cat *Catalog) GetWare(ref wfapi.CatalogRef) (*wfapi.WareID, *wfapi.WarehouseAddr, error)
Get a ware from a given catalog.
Errors:
- warpforge-error-io -- when reading of lineage or mirror files fails
- warpforge-error-catalog-parse -- when ipld parsing of lineage or mirror files fails
- warpforge-error-catalog-invalid -- when catalog files are not found
- warpforge-error-catalog-missing-entry -- when catalog item is not found
func (*Catalog) Modules ¶
func (cat *Catalog) Modules() []wfapi.ModuleName
Get the list of modules within this catalog.
type PlaceWorkspaceOpt ¶
func SetRootWorkspaceOpt ¶
func SetRootWorkspaceOpt() PlaceWorkspaceOpt
type Workspace ¶
type Workspace struct {
// contains filtered or unexported fields
}
func FindRootWorkspace ¶
FindRootWorkspace calls FindWorkspaceStack and returns the root workspace.
A root workspace is marked by containing a file named "root"
If no root filesystems are marked, this will default to the last item in the stack, which is the home workspace.
An fsys handle is required, but is typically `os.DirFS("/")` outside of tests.
Errors:
- warpforge-error-searching-filesystem -- when an error occurs while searching for the workspace
func FindWorkspace ¶
func FindWorkspace(fsys fs.FS, basisPath, searchPath string) (ws *Workspace, remainingSearchPath string, err error)
FindWorkspace looks for a workspace on the filesystem and returns the first one found, searching directories upward.
It searches from `join(basisPath,searchPath)` up to `basisPath` (in other words, it won't search above basisPath). Invoking it with an empty string for `basisPath` and cwd for `searchPath` is typical.
If no workspace is found, it will return nil for both the workspace pointer and error value. If errors are returned, they're due to filesystem IO. FindWorkspace will ignore your home workspace and carry on searching upwards.
An fsys handle is required, but is typically `os.DirFS("/")` outside of tests.
Errors:
- warpforge-error-searching-filesystem -- when an unexpected error occurs traversing the search path
func OpenHomeWorkspace ¶
OpenHomeWorkspace calls OpenWorkspace on the user's homedir. It will error if there's no workspace files yet there (it does not create them).
An fsys handle is required, but is typically `os.DirFS("/")` outside of tests.
Errors:
- warpforge-error-workspace -- when the workspace directory fails to open
func OpenWorkspace ¶
OpenWorkspace returns a pointer to a Workspace object. It does a basic check that the workspace exists on the filesystem, but little other work; most info loading will be done on-demand later.
OpenWorkspace assumes it will find a workspace exactly where you say; it doesn't search. Consider using FindWorkspace or FindWorkspaceStack in most application code.
An fsys handle is required, but is typically `os.DirFS("/")` outside of tests.
Errors:
- warpforge-error-workspace -- when the workspace directory fails to open
func (*Workspace) CachePath ¶
Returns the path for a cached ware within a workspace Errors:
- warpforge-error-wareid-invalid -- when a malformed WareID is provided
func (*Workspace) CatalogBasePath ¶
Returns the base path which contains named catalogs (e.g., `.../.warpforge/catalogs`)
func (*Workspace) CatalogPath ¶
CatalogPath returns the catalog path for catalog with a given name within a workspace. A non-root workspace must use an empty string as the catalog name. A root workspace must use a catalog name that matches the regular expression in the CatalogNameFormat package variable. A root workspace may not use an empty string catalog name.
Errors:
- warpforge-error-catalog-name -- when the catalog name is invalid
func (*Workspace) CreateCatalog ¶
CreateCatalog creates a new catalog. CreateCatalog only creates the catalog and does not open it.
Errors:
- warpforge-error-io -- when reading or writing the catalog directory fails
- warpforge-error-already-exists -- when the catalog already exists
- warpforge-error-catalog-name -- when the catalog name is invalid
func (*Workspace) CreateOrOpenCatalog ¶
CreateOrOpenCatalog will create a catalog if it does not exist before opening
Errors:
- warpforge-error-io -- when reading or writing the catalog directory fails
- warpforge-error-catalog-name -- when the catalog name is invalid
- warpforge-error-catalog-invalid -- when opened catalog has invalid data
func (*Workspace) GetCatalogReplay ¶
Get a catalog replay from a workspace, doing lookup by CatalogRef. In a root workspace this will check valid catalogs within the "catalogs" subdirectory In a non-root workspace, it will check the "catalog" subdirectory
Errors:
- warpforge-error-io -- when reading of lineage or mirror files fails
- warpforge-error-catalog-parse -- when ipld parsing of lineage or mirror files fails
- warpforge-error-catalog-invalid -- when ipld parsing of lineage or mirror files fails
func (*Workspace) GetCatalogWare ¶
func (ws *Workspace) GetCatalogWare(ref wfapi.CatalogRef) (*wfapi.WareID, *wfapi.WarehouseAddr, error)
Get a catalog ware from a workspace, doing lookup by CatalogRef. In a root workspace this will check valid catalogs within the "catalogs" subdirectory In a non-root workspace, it will check the "catalog" subdirectory
Errors:
- warpforge-error-io -- when reading of lineage or mirror files fails
- warpforge-error-catalog-parse -- when ipld parsing of lineage or mirror files fails
- warpforge-error-catalog-invalid -- when ipld parsing of lineage or mirror files fails
- warpforge-error-catalog-missing-entry -- when catalog item is missing
func (*Workspace) GetWarehouseAddress ¶
func (ws *Workspace) GetWarehouseAddress() wfapi.WarehouseAddr
GetWarehouseAddress will return a URL-style path to the workspace warehouse. will use the rootpath prefixed with "/"
func (*Workspace) HasCatalog ¶
Check if this workspace has a catalog with a given name.
Errors:
- warpforge-error-io -- when reading or writing the catalog directory fails
- warpforge-error-catalog-name -- when the catalog name is invalid
func (*Workspace) InternalPath ¶ added in v0.7.0
InternalPath returns the workspace's path including the .warp* segment.
func (*Workspace) IsHomeWorkspace ¶
IsHomeWorkspace returns true if this workspace is the one in the user's home dir. The home workspace is sometimes treated specially, because it's always the last one -- it can have no parents, and is the final word for any config overrides. Some functions will refuse to work on the home workspace, or work specially on it.
func (*Workspace) IsRootWorkspace ¶
IsRootWorkspace returns true if the workspace is a root workspace
func (*Workspace) ListCatalogs ¶
List the catalogs available within a workspace Will skip catalogs with invalid names A non-root workspace will only return the empty catalog name
Errors:
- warpforge-error-io -- when listing directory fails
func (*Workspace) MemoBasePath ¶
Returns the base path which contains memos (e.g., `.../.warpforge/memos`)
func (*Workspace) OpenCatalog ¶
Open a catalog within this workspace with a given name
Errors:
- warpforge-error-catalog-invalid -- when opened catalog has invalid data
- warpforge-error-io -- when IO error occurs during opening of catalog
- warpforge-error-catalog-name -- when the catalog name is invalid
func (*Workspace) Path ¶
Path returns the workspace's fs and path -- the directory that is its root. (This does *not* include the ".warp*" segment on the end of the path.)
func (*Workspace) WarehousePath ¶ added in v0.7.0
WarehousePath returns the path to the catalog in a non-root workspace.
type WorkspaceSet ¶
type WorkspaceSet []*Workspace
A WorkspaceSet is a slice of workspaces ending with a root workspace.
func FindWorkspaceStack ¶
func FindWorkspaceStack(fsys fs.FS, basisPath, searchPath string) (wss WorkspaceSet, err error)
FindWorkspaceStack works similarly to FindWorkspace, but finds all workspaces, not just the nearest one. The first element of the returned slice is the nearest workspace; subsequent elements are its parents, then grandparents, etc. The last element of the returned slice is the root workspace. If no root workspace is found then the last element will be the home workspace (or at the most extreme: where the home workspace *should be*).
It searches from `join(basisPath,searchPath)` up to `basisPath` (in other words, it won't search above basisPath). Invoking it with an empty string for `basisPath` and cwd for `searchPath` is typical.
An fsys handle is required, but is typically `os.DirFS("/")` outside of tests.
Errors:
- warpforge-error-searching-filesystem -- when an unexpected error occurs traversing the search path
func (WorkspaceSet) GetCatalogReplay ¶
func (wsSet WorkspaceSet) GetCatalogReplay(ref wfapi.CatalogRef) (*wfapi.Plot, error)
Get a catalog replay from a workspace set. Looks up a ware by CatalogRef, traversing the workspace set:
- traverses the workspace stack looking in "catalog" dirs.
- looks through all catalogs (within the "catalogs" dir) of the root workspace in alphabetical order, picking the first matching ware found.
Errors:
- warpforge-error-io -- when an IO error occurs while reading the catalog entry
- warpforge-error-catalog-parse -- when ipld parsing of a catalog entry fails
- warpforge-error-catalog-invalid -- when ipld parsing of lineage or mirror files fails
func (WorkspaceSet) GetCatalogWare ¶
func (wsSet WorkspaceSet) GetCatalogWare(ref wfapi.CatalogRef) (*wfapi.WareID, *wfapi.WarehouseAddr, error)
Get a catalog ware from a workspace set. Looks up a ware by CatalogRef, traversing the workspace set:
- traverses the workspace stack looking in "catalog" dirs.
- looks through all catalogs (within the "catalogs" dir) of the root workspace in alphabetical order, picking the first matching ware found.
Errors:
- warpforge-error-io -- when an IO error occurs while reading the catalog entry
- warpforge-error-catalog-parse -- when ipld parsing of a catalog entry fails
- warpforge-error-catalog-invalid -- when ipld parsing of lineage or mirror files fails
func (WorkspaceSet) GetWarehouseAddresses ¶
func (wsSet WorkspaceSet) GetWarehouseAddresses() []wfapi.WarehouseAddr
GetWarehouses returns a set of warehouse addresses for all the warehouses in the workspace stack
func (WorkspaceSet) Local ¶
func (wsSet WorkspaceSet) Local() *Workspace
Local returns the most local workspace. This workspace _MAY_ be a root workspace
func (WorkspaceSet) Root ¶
func (wsSet WorkspaceSet) Root() *Workspace
Root returns the root workspace of the workspace set
func (WorkspaceSet) Tidy ¶
Tidy will bundle plot dependencies into the local workspace from any workspace in the set. The local workspace must be a non-root workspace
Errors:
- warpforge-error-catalog-invalid -- a catalog in this workspace set is invalid
- warpforge-error-catalog-parse -- a catalog in this workspace set can't be parsed
- warpforge-error-catalog-missing-entry -- a dependency can't be found
- warpforge-error-catalog-name -- honestly, shouldn't happen
- warpforge-error-workspace -- workspace stack missing a non-root workspace
- warpforge-error-io -- reading/writing catalog fails