base

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2018 License: GPL-3.0 Imports: 29 Imported by: 1

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

Constants

This section is empty.

Variables

View Source
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

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

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

func DatasetPodBodyFile(store cafs.Filestore, dsp *dataset.DatasetPod) (cafs.File, error)

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

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

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

func LoadRevs(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 NewManifest added in v0.6.1

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

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 Select

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

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

func SetPublishStatus

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

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

func ValidateDataset

func ValidateDataset(name string, ds *dataset.Dataset) (err error)

ValidateDataset checks that a dataset is semantically valid

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL