config

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var NoConfig = errors.New(fmt.Sprintf("no %s found", NomsConfigFile))

Functions

This section is empty.

Types

type Config

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

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
}

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) GetChunkStore

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

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

func (*Resolver) GetDatabase

func (r *Resolver) GetDatabase(str string) (datas.Database, 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) GetDataset

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

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

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

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

Resolve string to database name. If config is defined:

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

func (*Resolver) ResolvePathSpec

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

Resolve string to dataset or path name.

  • 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