Documentation ¶
Overview ¶
Package base defines business that operates on local data it's main job is to composing APIs from the lower half of our tech stack, providing uniform functions for higher up packages, mainly p2p and actions. p2p and actions should use base as the only way of operate on the local repo Here's some ascii art to clarify the stack:
┌───────────────┐ ┌───────────────┐ │ cmd │ │ api │ └───────────────┘ └───────────────┘ ┌─────────────────────────────────┐ │ lib │ └─────────────────────────────────┘ ┌─────────────────────────────────┐ │ actions │ └─────────────────────────────────┘ ┌───────────────────────┐ │ p2p │ └───────────────────────┘ ┌─────────────────────────────────┐ │ base │ <-- you are here └─────────────────────────────────┘ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │ repo │ │ dsfs │ │ cafs │ │ ... │ └──────┘ └──────┘ └──────┘ └──────┘
There are packages omitted from this diagram, but these are the vitals. base functions mainly work with repo.Repo instances, using repo interface methods and related packages to do their work. This is part of a larger pattern of having actions rely on lower level interfaces wherever possible to enhance configurability
Index ¶
- Variables
- func ApplyPath(ds *dataset.DatasetPod, path string) (interface{}, error)
- func ConvertBodyFormat(bodyFile cafs.File, fromSt, toSt *dataset.Structure) (cafs.File, error)
- func CreateDataset(r repo.Repo, streams ioes.IOStreams, name string, ds *dataset.Dataset, ...) (ref repo.DatasetRef, resBody cafs.File, err error)
- func DatasetLog(r repo.Repo, ref repo.DatasetRef, limit, offset int, loadDatasets bool) (rlog []repo.DatasetRef, err error)
- func DatasetPodBodyFile(store cafs.Filestore, dsp *dataset.DatasetPod) (cafs.File, error)
- func FetchDataset(r repo.Repo, ref *repo.DatasetRef, pin, load bool) (err error)
- func InLocalNamespace(r repo.Repo, ref *repo.DatasetRef) bool
- func InferValues(pro *profile.Profile, name *string, ds *dataset.Dataset, body cafs.File) (res cafs.File, err error)
- func ListDatasets(r repo.Repo, limit, offset int, RPC, publishedOnly bool) (res []repo.DatasetRef, err error)
- func LoadRevs(r repo.Repo, ref repo.DatasetRef, revs []*rev.Rev) (res *dataset.Dataset, err error)
- func NewManifest(ctx context.Context, ng ipld.NodeGetter, path string) (*dag.Manifest, error)
- func PinDataset(r repo.Repo, ref repo.DatasetRef) error
- func PrepareDatasetSave(r repo.Repo, peername, name string) (prev *dataset.Dataset, body cafs.File, prevPath string, err error)
- func ReadDataset(r repo.Repo, ref *repo.DatasetRef) (err error)
- func Render(r repo.Repo, ref repo.DatasetRef, tmplData []byte, limit, offest int, all bool) ([]byte, error)
- func Select(r repo.Repo, ref repo.DatasetRef, path string) (interface{}, error)
- func SetPublishStatus(r repo.Repo, ref *repo.DatasetRef, published bool) error
- func UnpinDataset(r repo.Repo, ref repo.DatasetRef) error
- func ValidateDataset(name string, ds *dataset.Dataset) (err error)
- type LogDiffResult
Constants ¶
This section is empty.
Variables ¶
var DefaultTemplate = `` /* 1860-byte string literal not displayed */
DefaultTemplate is the template that render will fall back to should no template be available
Functions ¶
func ApplyPath ¶
func ApplyPath(ds *dataset.DatasetPod, path string) (interface{}, error)
ApplyPath gets a dataset value by applying a case.Sensitve.dot.separated.path
func ConvertBodyFormat ¶ added in v0.6.1
ConvertBodyFormat rewrites a body from a source format to a destination format.
func CreateDataset ¶
func CreateDataset(r repo.Repo, streams ioes.IOStreams, name string, ds *dataset.Dataset, body cafs.File, dryRun, pin bool) (ref repo.DatasetRef, resBody cafs.File, err error)
CreateDataset uses dsfs to add a dataset to a repo's store, updating all references within the repo if successful. CreateDataset is a lower-level component of github.com/qri-io/qri/actions.CreateDataset
func DatasetLog ¶
func DatasetLog(r repo.Repo, ref repo.DatasetRef, limit, offset int, loadDatasets bool) (rlog []repo.DatasetRef, err error)
DatasetLog fetches the history of changes to a dataset, if loadDatasets is true, dataset information will be populated
func DatasetPodBodyFile ¶
DatasetPodBodyFile creates a streaming data file from a DatasetPod using the following precedence: * dsp.BodyBytes not being nil (requires dsp.Structure.Format be set to know data format) * dsp.BodyPath being a url * dsp.BodyPath being a path on the local filesystem TODO - consider moving this func to some other package. maybe actions?
func FetchDataset ¶
FetchDataset grabs a dataset from a remote source
func InLocalNamespace ¶
func InLocalNamespace(r repo.Repo, ref *repo.DatasetRef) bool
InLocalNamespace checks if a dataset ref is local, assumes the reference is already canonicalized
func InferValues ¶
func InferValues(pro *profile.Profile, name *string, ds *dataset.Dataset, body cafs.File) (res cafs.File, err error)
InferValues populates any missing fields that must exist to create a snapshot
func ListDatasets ¶
func ListDatasets(r repo.Repo, limit, offset int, RPC, publishedOnly bool) (res []repo.DatasetRef, err error)
ListDatasets lists datasets from a repo
func LoadRevs ¶
LoadRevs grabs a component of a dataset that exists <n>th generation ancestor of the referenced version, where presence of a component in a previous snapshot constitutes ancestry
func NewManifest ¶ added in v0.6.1
NewManifest generates a manifest for a given node
func PinDataset ¶
func PinDataset(r repo.Repo, ref repo.DatasetRef) error
PinDataset marks a dataset for retention in a store
func PrepareDatasetSave ¶
func PrepareDatasetSave(r repo.Repo, peername, name string) (prev *dataset.Dataset, body cafs.File, prevPath string, err error)
PrepareDatasetSave prepares a set of changes for submission to SaveDataset
func ReadDataset ¶
func ReadDataset(r repo.Repo, ref *repo.DatasetRef) (err error)
ReadDataset grabs a dataset from the store
func Render ¶
func Render(r repo.Repo, ref repo.DatasetRef, tmplData []byte, limit, offest int, all bool) ([]byte, error)
Render executes a template for a dataset, returning a slice of HTML
func SetPublishStatus ¶
SetPublishStatus updates the Published field of a dataset ref
func UnpinDataset ¶
func UnpinDataset(r repo.Repo, ref repo.DatasetRef) error
UnpinDataset unmarks a dataset for retention in a store
Types ¶
type LogDiffResult ¶
type LogDiffResult struct { Head repo.DatasetRef Add, Remove []repo.DatasetRef }
LogDiffResult is the result of comparing a set of references
func LogDiff ¶
func LogDiff(r repo.Repo, a []repo.DatasetRef) (ldr LogDiffResult, err error)
LogDiff determines the difference between an input slice of references