config

package
v0.0.1-0...-a0864a0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2019 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 {
	// contains filtered or unexported fields
}

Config used to ease getting values from config using dot notation (obj.Selector.array[0].Selector), and used to resolve dynamic values.

func NewConfig

func NewConfig(config map[string]interface{}) *Config

NewConfig construct new Config from map[string]interface{}

func (*Config) NewSelector

func (cw *Config) NewSelector(base string) (Selector, error)

NewSelector Returns a new Selector used to evaluate dynamic fields in a config (this receiver was made for easing refactoring)

func (*Config) Populate

func (cw *Config) Populate(dst interface{}) error

Populate will populate 'dst' struct with the config field in the YAML configuration, structs can use two tags, `mapstructure` to map the config to the struct look up (github.com/mitchellh/mapstructure) docsfor more about its tags, and `validate` tag for quick validation lookup (gopkg.in/go-playground/validator.v9) validate tags for more about its tags.

type Selector

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

Selector Contains a base in the config, this base can be static or dynamic, dynamic values must be get using Evaluate()

func NewSelector

func NewSelector(base string) (Selector, error)

NewSelector Returns a new Selector used to evaluate dynamic fields in a config

func (*Selector) Evaluate

func (v *Selector) Evaluate(data map[string]interface{}) (string, error)

Evaluate Evaluate dynamic values of config such as `image-@{image.title}.jpg` as a string, return error if it doesn't exist in supplied Data. TODO differentiate between not found in data, and being evaluated to 0 in a better way.

func (*Selector) EvaluateBool

func (v *Selector) EvaluateBool(data map[string]interface{}) (bool, error)

EvaluateBool Evaluate dynamic values of config such as `@{image.doFlip}` as bool, return error if it doesn't exist in supplied Data. values such as 0,1,T,F,True,False are all possible values,if base evaluated value is "" it returns zero value of Float64 = 0.0

func (*Selector) EvaluateFloat64

func (v *Selector) EvaluateFloat64(data map[string]interface{}) (float64, error)

EvaluateFloat64 Evaluate dynamic values of config such as `@{image.width}` as float64, return error if it doesn't exist in supplied Data. if base evaluated value is "" it returns zero value of Float64 = 0.0

func (*Selector) EvaluateInt64

func (v *Selector) EvaluateInt64(data map[string]interface{}) (int64, error)

EvaluateInt64 Evaluate dynamic values of config such as `@{image.width}` as Int64, return error if it doesn't exist in supplied Data. if base evaluated value is "" it returns zero value of Int64 = 0

func (*Selector) EvaluateUint8

func (v *Selector) EvaluateUint8(data map[string]interface{}) (uint8, error)

EvaluateUint8 Evaluate dynamic values of config such as `@{image.width}` as uint8, return error if it doesn't exist in supplied Data. if base evaluated value is "" it returns zero value of Uint8 = 0

Jump to

Keyboard shortcuts

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