Documentation ¶
Overview ¶
Package spec provides builders and parsers for spelling Noms databases, datasets and values.
Index ¶
- Constants
- func CreateCommitMetaStruct(db datas.Database, date, message string, keyValueStrings map[string]string, ...) (types.Struct, error)
- func CreateDatabaseSpecString(protocol, db string) string
- func CreateHashSpecString(protocol, db string, h hash.Hash) string
- func CreateValueSpecString(protocol, db, path string) string
- func ReadAbsolutePaths(db datas.Database, paths ...string) ([]types.Value, error)
- func RegisterCommitMetaFlags(flags *flag.FlagSet)
- type AbsolutePath
- type Spec
- func ForDatabase(spec string) (Spec, error)
- func ForDatabaseOpts(spec string, opts SpecOptions) (Spec, error)
- func ForDataset(spec string) (Spec, error)
- func ForDatasetOpts(spec string, opts SpecOptions) (Spec, error)
- func ForPath(spec string) (Spec, error)
- func ForPathOpts(spec string, opts SpecOptions) (Spec, error)
- func (sp Spec) Close() error
- func (sp Spec) GetDatabase() datas.Database
- func (sp Spec) GetDataset() (ds datas.Dataset)
- func (sp Spec) GetValue() (val types.Value)
- func (sp Spec) Href() string
- func (sp Spec) NewChunkStore() chunks.ChunkStore
- func (sp Spec) Pin() (Spec, bool)
- func (sp Spec) String() string
- type SpecOptions
Constants ¶
const CommitMetaDateFormat = "2006-01-02T15:04:05-0700"
const Separator = "::"
Variables ¶
This section is empty.
Functions ¶
func CreateCommitMetaStruct ¶
func CreateCommitMetaStruct(db datas.Database, date, message string, keyValueStrings map[string]string, keyValuePaths map[string]types.Value) (types.Struct, error)
CreateCommitMetaStruct creates and returns a Noms struct suitable for use in CommitOptions.Meta. It returns types.EmptyStruct and an error if any issues are encountered. Database is used only if commitMetaKeyValuePaths are provided on the command line and values need to be resolved. Date should be ISO 8601 format (see CommitMetaDateFormat), if empty the current date is used. The values passed as command line arguments (if any) are merged with the values provided as function arguments.
func CreateValueSpecString ¶
func ReadAbsolutePaths ¶
ReadAbsolutePaths attempts to parse each path in 'paths' and resolve them. If any path fails to parse correctly or if any path can be resolved to an existing Noms Value, then this function returns (nil, error).
func RegisterCommitMetaFlags ¶
RegisterCommitMetaFlags registers command line flags used for creating commit meta structs.
Types ¶
type AbsolutePath ¶
type AbsolutePath struct { // Dataset is the dataset this AbsolutePath is rooted at. Only one of // Dataset and Hash should be set. Dataset string // Hash is the hash this AbsolutePath is rooted at. Only one of Dataset and // Hash should be set. Hash hash.Hash // Path is the relative path from Dataset or Hash. This can be empty. In // that case, the AbsolutePath describes the value at either Dataset or // Hash. Path types.Path }
AbsolutePath describes the location of a Value within a Noms database.
To locate a value relative to some other value, see Path. To locate a value globally, see Spec.
For more on paths, absolute paths, and specs, see: https://github.com/attic-labs/noms/blob/master/doc/spelling.md.
func NewAbsolutePath ¶
func NewAbsolutePath(str string) (AbsolutePath, error)
NewAbsolutePath attempts to parse 'str' and return an AbsolutePath.
func (AbsolutePath) IsEmpty ¶
func (p AbsolutePath) IsEmpty() bool
func (AbsolutePath) Resolve ¶
func (p AbsolutePath) Resolve(db datas.Database) (val types.Value)
Resolve returns the Value reachable by 'p' in 'db'.
func (AbsolutePath) String ¶
func (p AbsolutePath) String() (str string)
type Spec ¶
type Spec struct { // Protocol is one of "mem", "ldb", "http", or "https". Protocol string // DatabaseName is the name of the Spec's database, which is the string after // "protocol:". http/https specs include their leading "//" characters. DatabaseName string // Options are the SpecOptions that the Spec was constructed with. Options SpecOptions // Path is nil unless the spec was created with ForPath. Path AbsolutePath // contains filtered or unexported fields }
Spec locates a Noms database, dataset, or value globally.
func ForDatabase ¶
ForDatabase parses a spec for a Database.
func ForDatabaseOpts ¶
func ForDatabaseOpts(spec string, opts SpecOptions) (Spec, error)
ForDatabaseOpts parses a spec for a Database.
func ForDataset ¶
ForDataset parses a spec for a Dataset.
func ForDatasetOpts ¶
func ForDatasetOpts(spec string, opts SpecOptions) (Spec, error)
ForDatasetOpts parses a spec for a Dataset.
func ForPathOpts ¶
func ForPathOpts(spec string, opts SpecOptions) (Spec, error)
ForPathOpts parses a spec for a path to a Value.
func (Spec) GetDatabase ¶
GetDatabase returns the Database instance that this Spec's DatabaseName describes. The same Database instance is returned every time, unless Close is called. If the Spec is closed, it is re-opened with a new Database.
func (Spec) GetDataset ¶
GetDataset returns the current Dataset instance for this Spec's Database. GetDataset is live, so if Commit is called on this Spec's Database later, a new up-to-date Dataset will returned on the next call to GetDataset. If this is not a Dataset spec, returns nil.
func (Spec) GetValue ¶
GetValue returns the Value at this Spec's Path within its Database, or nil if this isn't a Path Spec or if that path isn't found.
func (Spec) Href ¶
Href treats the Protocol and DatabaseName as a URL, and returns its href. For example, the spec http://example.com/path::ds returns "http://example.com/path". If the Protocol is not "http" or "http", returns an empty string.
func (Spec) NewChunkStore ¶
func (sp Spec) NewChunkStore() chunks.ChunkStore
NewChunkStore returns a new ChunkStore instance that this Spec's DatabaseName describes. It's unusual to call this method, GetDatabase is more useful. Unlike GetDatabase, a new ChunkStore instance is returned every time. If there is no ChunkStore, for example remote databases, returns nil.
type SpecOptions ¶
type SpecOptions struct { // Authorization token for requests. For example, if the database is HTTP // this will used for an `Authorization: Bearer ${authorization}` header. Authorization string }
SpecOptions customize Spec behavior.