spec

package
v0.0.0-...-3afbc18 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package spec provides builders and parsers for spelling Noms databases, datasets and values.

Index

Constants

View Source
const CommitMetaDateFormat = "2006-01-02T15:04:05-0700"
View Source
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 CreateDatabaseSpecString

func CreateDatabaseSpecString(protocol, path string) string

func CreateHashSpecString

func CreateHashSpecString(protocol, path string, h hash.Hash) string

func CreateValueSpecString

func CreateValueSpecString(protocol, path, value string) string

func GetChunkStore

func GetChunkStore(str string) (chunks.ChunkStore, error)

func GetDatabase

func GetDatabase(str string) (datas.Database, error)

func GetDataset

func GetDataset(str string) (datas.Database, datas.Dataset, error)

func GetPath

func GetPath(str string) (datas.Database, types.Value, error)

func ReadAbsolutePaths

func ReadAbsolutePaths(db datas.Database, paths ...string) ([]types.Value, error)

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

func RegisterCommitMetaFlags(flags *flag.FlagSet)

RegisterCommitMetaFlags registers command line flags used for creating commit meta structs.

func RegisterDatabaseFlags

func RegisterDatabaseFlags(flags *flag.FlagSet)

Types

type AbsolutePath

type AbsolutePath struct {
	Dataset string
	Hash    hash.Hash
	Path    types.Path
}

AbsolutePath represents a path originating at a dataset or a well-formed hash (i.e. '#' + 32 chars) representing a Noms Value that is independently addressable. Either the Dataset of Hash field will indicate the beginning of the AbsolutePath and the other one will be nil. The Path field holds the remainder of the path.

func NewAbsolutePath

func NewAbsolutePath(str string) (AbsolutePath, error)

NewAbsolutePath attempts to parse 'str' and return an AbsolutePath.

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 DatabaseSpec

type DatabaseSpec struct {
	Protocol string
	Path     string
	// contains filtered or unexported fields
}

func ParseDatabaseSpec

func ParseDatabaseSpec(spec string) (DatabaseSpec, error)

ParseDatabaseSpec parses a database spec string into its parts

func (DatabaseSpec) Database

func (spec DatabaseSpec) Database() (ds datas.Database, err error)

func (DatabaseSpec) String

func (spec DatabaseSpec) String() string

type PathSpec

type PathSpec struct {
	DbSpec DatabaseSpec
	Path   AbsolutePath
}

func ParsePathSpec

func ParsePathSpec(spec string) (PathSpec, error)

ParsePathSpec parses a path spec string into its parts

func (PathSpec) String

func (spec PathSpec) String() string

func (PathSpec) Value

func (spec PathSpec) Value() (db datas.Database, val types.Value, err error)

Jump to

Keyboard shortcuts

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