Documentation ¶
Overview ¶
Package ns defines the qri dataset naming system This package is currently an experiment while we try to settle the distinction between a dataset.datasetPod and a reference. This code is extracted from
github.com/qri-io/qri/repo/ref.go
This package will either move to a new location or be removed entirely before 2019-04-01
initial RFC is here: https://github.com/qri-io/rfcs/blob/master/text/0006-dataset_naming.md
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyRef indicates that the given reference is empty ErrEmptyRef = fmt.Errorf("repo: empty dataset reference") )
Functions ¶
func CompareRef ¶
CompareRef compares two Dataset Refs, returning an error describing any difference between the two references
func HTTPPathToQriPath ¶
HTTPPathToQriPath converts a http path to a qri path
Types ¶
type QriCtxKey ¶
type QriCtxKey string
QriCtxKey defines a distinct type for keys for context values should always use custom types to avoid collissions. see comment on context.WithValue for more info
const RefCtxKey QriCtxKey = "datasetRef"
RefCtxKey is the key for adding a dataset reference to a context.Context
type Ref ¶
type Ref struct { // Peername of dataset owner Peername string `json:"peername,omitempty"` // ProfileID of dataset owner ProfileID string `json:"profileID,omitempty"` // Unique name reference for this dataset Name string `json:"name,omitempty"` // Content-addressed path for this dataset Path string `json:"path,omitempty"` }
Ref encapsulates a reference to a dataset. This needs to exist to bind ways of referring to a dataset to a dataset itself, as datasets can't easily contain their own hash information, and names are unique on a per-repository basis. It's tempting to think this needs to be "bigger", supporting more fields, keep in mind that if the information is important at all, it should be stored as metadata within the dataset itself.
func MustParseRef ¶
MustParseRef panics if the reference is invalid. Useful for testing
func ParseRef ¶
ParseRef decodes a dataset reference from a string value It’s possible to refer to a dataset in a number of ways. The full definition of a dataset reference is as follows:
dataset_reference = peer_name/dataset_name@peer_id/network/hash
we swap in defaults as follows, all of which are represented as empty strings:
network - defaults to /ipfs/ hash - tip of version history (latest known commit)
these defaults are currently enforced by convention. TODO - make Dataset Ref parsing the responisiblity of the repo.Repo interface, replacing empty strings with actual defaults
dataset names & hashes are disambiguated by checking if the input parses to a valid multihash after base58 decoding. through defaults & base58 checking the following should all parse:
peer_name/dataset_name /network/hash peername peer_id @peer_id @peer_id/network/hash
see tests for more exmples
TODO - add validation that prevents peernames from being valid base58 multihashes and makes sure hashes are actually valid base58 multihashes TODO - figure out how IPFS CID's play into this
func RefFromCtx ¶
RefFromCtx extracts a Dataset reference from a given context if one is set, returning nil otherwise
func RefFromHTTPPath ¶
RefFromHTTPPath parses a path and returns a datasetRef
func RefFromReq ¶
RefFromReq examines the path element of a request URL to
func (Ref) AliasString ¶
AliasString returns the alias components of a Ref as a string