qri: github.com/qri-io/qri/base Index | Files | Directories

package base

import "github.com/qri-io/qri/base"

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


Package Files

base.go dag.go dataset.go dataset_prepare.go entries.go log.go ref.go render.go revisions.go select.go


var DefaultTemplate = "" /* 251 byte string literal not displayed */

DefaultTemplate is the template that render will fall back to should no template be available

func ApplyPath Uses

func ApplyPath(ds *dataset.Dataset, path string) (interface{}, error)

ApplyPath gets a dataset value by applying a case.Sensitve.dot.separated.path ApplyPath cannot select file fields

func CloseDataset Uses

func CloseDataset(ds *dataset.Dataset) (err error)

CloseDataset ensures all open dataset files are closed

func ConvertBodyFile Uses

func ConvertBodyFile(file qfs.File, in, out *dataset.Structure, limit, offset int, all bool) (data []byte, err error)

ConvertBodyFile takes an input file & structure, and converts a specified selection to the structure specified by out

func ConvertBodyFormat Uses

func ConvertBodyFormat(bodyFile qfs.File, fromSt, toSt *dataset.Structure) (qfs.File, error)

ConvertBodyFormat rewrites a body from a source format to a destination format.

func CreateDataset Uses

func CreateDataset(ctx context.Context, r repo.Repo, streams ioes.IOStreams, ds, dsPrev *dataset.Dataset, dryRun, pin, force, shouldRender bool) (ref repo.DatasetRef, 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 DatasetBodyFile Uses

func DatasetBodyFile(ctx context.Context, store cafs.Filestore, ds *dataset.Dataset) (qfs.File, error)

DatasetBodyFile creates a streaming data file from a Dataset using the following precedence: * ds.BodyBytes not being nil (requires ds.Structure.Format be set to know data format) * ds.BodyPath being a url * ds.BodyPath being a path on the local filesystem TODO - consider moving this func to some other package. maybe actions?

func DatasetLog Uses

func DatasetLog(ctx context.Context, 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 FetchDataset Uses

func FetchDataset(ctx context.Context, r repo.Repo, ref *repo.DatasetRef, pin, load bool) (err error)

FetchDataset grabs a dataset from a remote source

func InLocalNamespace Uses

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 Uses

func InferValues(pro *profile.Profile, ds *dataset.Dataset) error

InferValues populates any missing fields that must exist to create a snapshot

func InlineJSONBody Uses

func InlineJSONBody(ds *dataset.Dataset) error

InlineJSONBody reads the contents dataset.BodyFile() into a json.RawMessage, assigning the result to dataset.Body

func ListDatasets Uses

func ListDatasets(ctx context.Context, r repo.Repo, term string, limit, offset int, RPC, publishedOnly, showVersions bool) (res []repo.DatasetRef, err error)

ListDatasets lists datasets from a repo

func LoadRevs Uses

func LoadRevs(ctx context.Context, r repo.Repo, ref repo.DatasetRef, revs []*rev.Rev) (res *dataset.Dataset, err error)

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 MaybeAddDefaultViz Uses

func MaybeAddDefaultViz(ds *dataset.Dataset)

MaybeAddDefaultViz sets a dataset viz component and template if none exists

func NewDAGInfo Uses

func NewDAGInfo(ctx context.Context, store cafs.Filestore, ng ipld.NodeGetter, path, label string) (*dag.Info, error)

NewDAGInfo generates a DAGInfo for a given node. If a label is provided, it gnenerates a sub-DAGInfo at that

func NewManifest Uses

func NewManifest(ctx context.Context, ng ipld.NodeGetter, path string) (*dag.Manifest, error)

NewManifest generates a manifest for a given node

func OpenDataset Uses

func OpenDataset(ctx context.Context, fsys qfs.Filesystem, ds *dataset.Dataset) (err error)

OpenDataset prepares a dataset for use, checking each component for populated Path or Byte suffixed fields, consuming those fields to set File handlers that are ready for reading

func PinDataset Uses

func PinDataset(ctx context.Context, r repo.Repo, ref repo.DatasetRef) error

PinDataset marks a dataset for retention in a store

func PrepareDatasetSave Uses

func PrepareDatasetSave(ctx context.Context, r repo.Repo, peername, name string) (prev, mutable *dataset.Dataset, prevPath string, err error)

PrepareDatasetSave prepares a set of changes for submission to SaveDataset prev is the previous dataset, if it exists body is the previous dataset body, if it exists mutable is the previous dataset, but without the commit and transform, making it sutable for mutation/combination with any potential changes requested by the user we do not error if the dataset is not found in the repo, instead we return all empty values TODO (b5): input parameters here assume the store can properly resolve the previous dataset path through canonicalization (looking the name up in the repo). The value given by the input dataset document may differ, and we should probably respect that value if it does

func ReadDataset Uses

func ReadDataset(ctx context.Context, r repo.Repo, ref *repo.DatasetRef) (err error)

ReadDataset grabs a dataset from the store

func ReadDatasetPath Uses

func ReadDatasetPath(ctx context.Context, r repo.Repo, path string) (ds *dataset.Dataset, err error)

ReadDatasetPath takes a path string, parses, canonicalizes, loads a dataset pointer, and opens the file The medium-term goal here is to obfuscate use of repo.DatasetRef, which we're hoping to deprecate

func ReadEntries Uses

func ReadEntries(reader dsio.EntryReader) (interface{}, error)

ReadEntries reads entries and returns them as a native go array or map

func Render Uses

func Render(ctx context.Context, r repo.Repo, ref repo.DatasetRef, tmplData []byte) ([]byte, error)

Render executes a template for a dataset, returning a slice of HTML Render uses go's html/template package to generate html documents from an input dataset. It's API has been adjusted to use lowerCamelCase instead of UpperCamelCase naming conventions

func Select Uses

func Select(ctx context.Context, r repo.Repo, ref repo.DatasetRef, path string) (interface{}, error)

Select loads a dataset value specified by case.Sensitve.dot.separated.paths

func SetPublishStatus Uses

func SetPublishStatus(r repo.Repo, ref *repo.DatasetRef, published bool) error

SetPublishStatus updates the Published field of a dataset ref

func ToDatasetRef Uses

func ToDatasetRef(path string, r repo.Repo, allowFSI bool) (*repo.DatasetRef, error)

ToDatasetRef parses the dataset ref and returns it, allowing datasets with no history only if FSI is enabled.

func UnpinDataset Uses

func UnpinDataset(ctx context.Context, r repo.Repo, ref repo.DatasetRef) error

UnpinDataset unmarks a dataset for retention in a store

func ValidateDataset Uses

func ValidateDataset(ds *dataset.Dataset) (err error)

ValidateDataset checks that a dataset is semantically valid

type LogDiffResult Uses

type LogDiffResult struct {
    Head        repo.DatasetRef
    Add, Remove []repo.DatasetRef

LogDiffResult is the result of comparing a set of references

func LogDiff Uses

func LogDiff(ctx context.Context, r repo.Repo, a []repo.DatasetRef) (ldr LogDiffResult, err error)

LogDiff determines the difference between an input slice of references


fillPackage fill assigns arbitrary values to struct fields using reflection.

Package base imports 30 packages (graph) and is imported by 6 packages. Updated 2019-09-15. Refresh now. Tools for package owners.