common

package
v0.0.0-...-39ea062 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OverwriteConfigOpts

func OverwriteConfigOpts(options []ucfg.Option)

OverwriteConfigOpts allow to change the globally set config option

func RegisterConfigVersion

func RegisterConfigVersion(version string, f VersionFactory)

func Unpack

func Unpack(cfg *Config, builder Builder) error

Types

type Config

type Config ucfg.Config

Config object to store hierarchical configurations into. See https://godoc.org/github.com/elastic/go-ucfg#Config

func LoadFile

func LoadFile(path string) (*Config, [md5.Size]byte, error)

func MergeConfigs

func MergeConfigs(cfgs ...*Config) (*Config, error)

func MustNewConfigFrom

func MustNewConfigFrom(from interface{}) *Config

MustNewConfigFrom creates a new Config object from the given input. From can be any kind of structured data (struct, map, array, slice).

If from is a string, the contents is treated like raw YAML input. The string will be parsed and a structure config object is build from the parsed result.

MustNewConfigFrom panics if an error occurs.

func NewConfig

func NewConfig() *Config

func NewConfigFrom

func NewConfigFrom(from interface{}) (*Config, error)

NewConfigFrom creates a new Config object from the given input. From can be any kind of structured data (struct, map, array, slice).

If from is a string, the contents is treated like raw YAML input. The string will be parsed and a structure config object is build from the parsed result.

func NewConfigWithJSON

func NewConfigWithJSON(in []byte, source string) (*Config, error)

func NewConfigWithYAML

func NewConfigWithYAML(in []byte, source string) (*Config, error)

func (*Config) Bool

func (c *Config) Bool(name string, idx int) (bool, error)

func (*Config) Child

func (c *Config) Child(name string, idx int) (*Config, error)

func (*Config) CountField

func (c *Config) CountField(name string) (int, error)

func (*Config) FlattenedKeys

func (c *Config) FlattenedKeys(options ...ucfg.Option) []string

func (*Config) Float

func (c *Config) Float(name string, idx int) (float64, error)

func (*Config) GetFields

func (c *Config) GetFields() []string

func (*Config) HasField

func (c *Config) HasField(name string) bool

func (*Config) Int

func (c *Config) Int(name string, idx int) (int64, error)

func (*Config) IsArray

func (c *Config) IsArray() bool

func (*Config) IsDict

func (c *Config) IsDict() bool

func (*Config) Merge

func (c *Config) Merge(from interface{}) error

func (*Config) MustName

func (c *Config) MustName(fallback ...string) string

func (*Config) Name

func (c *Config) Name() (string, error)

func (*Config) Path

func (c *Config) Path() string

func (*Config) PathOf

func (c *Config) PathOf(field string) string

func (*Config) SetBool

func (c *Config) SetBool(name string, idx int, value bool) error

func (*Config) SetChild

func (c *Config) SetChild(name string, idx int, value *Config) error

func (*Config) SetFloat

func (c *Config) SetFloat(name string, idx int, value float64) error

func (*Config) SetInt

func (c *Config) SetInt(name string, idx int, value int64) error

func (*Config) SetString

func (c *Config) SetString(name string, idx int, value string) error

func (*Config) String

func (c *Config) String(name string, idx int) (string, error)

func (*Config) Unpack

func (c *Config) Unpack(to interface{}) error

type ConfigNamespace

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

ConfigNamespace storing at most one configuration section by name and sub-section.

func (*ConfigNamespace) Config

func (ns *ConfigNamespace) Config() *Config

Config return the sub-configuration section if a section has been set.

func (*ConfigNamespace) IsSet

func (ns *ConfigNamespace) IsSet() bool

IsSet returns true if a sub-configuration section has been set.

func (*ConfigNamespace) Name

func (ns *ConfigNamespace) Name() string

Name returns the configuration sections it's name if a section has been set.

func (*ConfigNamespace) Unpack

func (ns *ConfigNamespace) Unpack(cfg *Config) error

Unpack unpacks a configuration with at most one sub object. An sub object is ignored if it is disabled by setting `enabled: false`. If the configuration passed contains multiple active sub objects, Unpack will return an error.

type FuncMapInterface

type FuncMapInterface interface {
	FuncMap() template.FuncMap
}

type TemplateValue

type TemplateValue string

func (TemplateValue) Execute

func (val TemplateValue) Execute(context interface{}) (string, error)

func (TemplateValue) MustExecute

func (val TemplateValue) MustExecute(context interface{}) string

type VersionFactory

type VersionFactory func(config *Config) (ConfigFactory, error)

type VersionNamespace

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

VersionNamespace storing at most one configuration section by name and sub-section.

func (*VersionNamespace) Config

func (ns *VersionNamespace) Config() ConfigFactory

configVersionFactory return the sub-configuration section if a section has been set.

func (*VersionNamespace) IsSet

func (ns *VersionNamespace) IsSet() bool

IsSet returns true if a sub-configuration section has been set.

func (*VersionNamespace) Name

func (ns *VersionNamespace) Name() string

Name returns the configuration sections it's name if a section has been set.

func (*VersionNamespace) Unpack

func (ns *VersionNamespace) Unpack(cfg *Config) error

Unpack unpacks a configuration with at most one sub object. An sub object is ignored if it is disabled by setting `enabled: false`. If the configuration passed contains multiple active sub objects, Unpack will return an error.

Jump to

Keyboard shortcuts

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