config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Targets map[string]Target `yaml:"targets"`
	// contains filtered or unexported fields
}

Config holds configuration data for various targets.

func New

func New(data io.Reader) (*Config, error)

New instantiates a config and immediately populates it with the supplied data.

func NewFromEnvOrFile

func NewFromEnvOrFile(location string, envvar string) (*Config, error)

func NewFromFile

func NewFromFile(location string) (*Config, error)

func (*Config) Create

func (config *Config) Create(name string, storeType string) *Config

Create inserts a new target.

func (*Config) Delete

func (config *Config) Delete(name string) *Config

Delete removes a target by name from the configuration struct.

func (*Config) Load

func (config *Config) Load(data io.Reader) error

Load reads a provided data source that is expected to contain yaml that can be directly unmarshalled into File field of Config.

func (*Config) Save

func (config *Config) Save() error

func (*Config) SaveFrom

func (config *Config) SaveFrom(dest io.Writer) error

SaveFrom renders the current configuration as YAML and writes it to a consumer specified io.Writer.

func (*Config) String

func (config *Config) String() string

String returns a yaml-formatted representation of the content of config.

func (*Config) Target

func (config *Config) Target(name string) (*Target, error)

Target finds the requested target, creating one if needed.

type Target

type Target map[string]string

Target describes a single target in the configuration file.

func (*Target) Delete

func (target *Target) Delete(key string) *Target

Delete removes a configuration value.

func (*Target) Get

func (target *Target) Get(key string) string

Get retrieves a configuration value from a target without consumers knowing where it was stored.

func (*Target) Set

func (target *Target) Set(key string, value string) *Target

Set assigns a configuration value to the target.

Jump to

Keyboard shortcuts

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