config

package
v0.40.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NomsConfigFile = ".nomsconfig"
	DefaultDbAlias = "default"
)

Variables

View Source
var ErrNoConfig = fmt.Errorf("no %s found", NomsConfigFile)

Functions

This section is empty.

Types

type AWSConfig

type AWSConfig struct {
	Region     string
	CredSource string `toml:"cred_source"`
	CredFile   string `toml:"cred_file"`
}

Global AWS Config

type Config

type Config struct {
	File string
	Db   map[string]DbConfig
	AWS  AWSConfig
}

All configuration

func FindNomsConfig

func FindNomsConfig() (*Config, error)

Find the closest directory containing .nomsconfig starting in cwd and then searching up ancestor tree. Look first looking in cwd and then up through its ancestors

func NewConfig

func NewConfig(data string) (*Config, error)

func ReadConfig

func ReadConfig(name string) (*Config, error)

func (*Config) String

func (c *Config) String() string

func (*Config) WriteTo

func (c *Config) WriteTo(configHome string) (string, error)

type DbConfig

type DbConfig struct {
	Url     string
	Options map[string]string
}

Configuration for a specific database

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

func NewResolver

func NewResolver() *Resolver

A Resolver enables using db defaults, db aliases and dataset '.' replacement in command line arguments when a .nomsconfig file is present. To use it, create a config resolver before command line processing and use it to resolve each dataspec argument in succession.

func (*Resolver) DbConfigForDbSpec

func (r *Resolver) DbConfigForDbSpec(str string) *DbConfig

Resolve string to database name. And get the DbConfig if one exists. If config is defined:

  • replace the empty string with the default db url
  • replace any db alias with it's url

func (*Resolver) GetChunkStore

func (r *Resolver) GetChunkStore(ctx context.Context, str string) (chunks.ChunkStore, error)

Resolve string to a chunkstore. Like ResolveDatabase, but returns the underlying ChunkStore

func (*Resolver) GetDatabase

func (r *Resolver) GetDatabase(ctx context.Context, str string) (datas.Database, types.ValueReadWriter, error)

Resolve string to database spec. If a config is present,

  • resolve a db alias to its db spec
  • resolve "" to the default db spec

func (*Resolver) GetDatabaseSpecForPath

func (r *Resolver) GetDatabaseSpecForPath(ctx context.Context, str string) (spec.Spec, error)

GetDatabaseForPath returns the database and a VRW for the path given, but does not attempt to load a value

func (*Resolver) GetDataset

Resolve string to a dataset. If a config is present,

  • if no db prefix is present, assume the default db
  • if the db prefix is an alias, replace it

func (*Resolver) GetPath

Resolve string to a value path. If a config is present,

  • if no db spec is present, assume the default db
  • if the db spec is an alias, replace it

func (*Resolver) ResolveDbSpec

func (r *Resolver) ResolveDbSpec(str string) string

See config.DbConfigForDbSpec which will retrieve the entire DbConfig object associated with the db (if one exists). This method retrieves the Url from that DbConfig.

func (*Resolver) ResolvePathSpec

func (r *Resolver) ResolvePathSpec(str string) string

See ResolvePathSpecAndGetDbConfig which does both path spec resolutioon and config retrieval

func (*Resolver) ResolvePathSpecAndGetDbConfig

func (r *Resolver) ResolvePathSpecAndGetDbConfig(str string) (string, *DbConfig)

Resolve string to dataset or path name and get the appropriate DbConfig if one exists.

  • replace database name as described in ResolveDatabase
  • if this is the first call to ResolvePath, remember the datapath part for subsequent calls.
  • if this is not the first call and a "." is used, replace it with the first datapath.

Jump to

Keyboard shortcuts

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