Documentation ¶
Overview ¶
Package spec provides builders and parsers for spelling Noms databases, datasets and values.
Index ¶
- Constants
- Variables
- func CommitMetaFromFlags(ctx context.Context) (*datas.CommitMeta, 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(ctx context.Context, db datas.Database, vrw types.ValueReadWriter, ...) ([]types.Value, error)
- func RegisterCommitMetaFlags(flags *flag.FlagSet)
- type AWSCredentialSource
- type AbsolutePath
- type ProtocolImpl
- 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(ctx context.Context) datas.Database
- func (sp Spec) GetDataset(ctx context.Context) (ds datas.Dataset)
- func (sp Spec) GetVRW(ctx context.Context) types.ValueReadWriter
- func (sp Spec) GetValue(ctx context.Context) (val types.Value, err error)
- func (sp Spec) Href() string
- func (sp Spec) NewChunkStore(ctx context.Context) chunks.ChunkStore
- func (sp Spec) Pin(ctx context.Context) (Spec, bool)
- func (sp Spec) String() string
- type SpecOptions
Constants ¶
const ( Separator = "::" DefaultAWSRegion = "us-west-2" DefaultAWSCredsProfile = "default" )
const CommitMetaDateFormat = time.RFC3339
Variables ¶
var ExternalProtocols = map[string]ProtocolImpl{}
Functions ¶
func CommitMetaFromFlags ¶
func CommitMetaFromFlags(ctx context.Context) (*datas.CommitMeta, error)
Return the CommitMeta for an invocation of `noms` with CLI flags.
func CreateValueSpecString ¶
func ReadAbsolutePaths ¶
func ReadAbsolutePaths(ctx context.Context, db datas.Database, vrw types.ValueReadWriter, 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 ¶
RegisterCommitMetaFlags registers command line flags used for creating commit meta structs.
Types ¶
type AWSCredentialSource ¶
type AWSCredentialSource int
const ( InvalidCS AWSCredentialSource = iota - 1 // Auto will try env first and fall back to role (This is the default) AutoCS // Role Uses the AWS IAM role of the instance for auth RoleCS // Env uses the credentials stored in the environment variables AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY EnvCS // Uses credentials stored in a file FileCS )
func AWSCredentialSourceFromStr ¶
func AWSCredentialSourceFromStr(str string) AWSCredentialSource
func (AWSCredentialSource) String ¶
func (ct AWSCredentialSource) String() string
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(ctx context.Context, db datas.Database, vrw types.ValueReadWriter) (val types.Value, err error)
Resolve returns the Value reachable by 'p' in 'db'.
func (AbsolutePath) String ¶
func (p AbsolutePath) String() (str string)
type ProtocolImpl ¶
type ProtocolImpl interface {
NewChunkStore(sp Spec) (chunks.ChunkStore, error)
}
type Spec ¶
type Spec struct { // Protocol is one of "mem", "aws", "gs", "nbs" Protocol string // DatabaseName is the name of the Spec's database, which is the string after // "protocol:". 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. Spec caches its database instance so it therefore does not reflect new commits in the db, by (legacy) design.
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(ctx context.Context) 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 // Region that should be used when creating the aws session AWSRegion string // The type of credentials that should be used when creating the aws session AWSCredSource AWSCredentialSource // Credential file to use when using auto or file credentials AWSCredFile string }
SpecOptions customize Spec behavior.
func (*SpecOptions) AwsCredFileOrDefault ¶
func (so *SpecOptions) AwsCredFileOrDefault() string
func (*SpecOptions) AwsRegionOrDefault ¶
func (so *SpecOptions) AwsRegionOrDefault() string