config

package
v0.0.0-...-0d3a4d9 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(s ...ConfigSource) error

Add methods add configuration sources to the default provider

func AddYaml

func AddYaml(resources fs.FS) error

AddYaml adds yaml configuration source for the embedded yaml file to the default provider

func Extension

func Extension(name string, value interface{}) error

Extension setup the properties in the structure base on the tags

func Profile

func Profile() string

Profile of the default configuration source provider

func Properties

func Properties(value interface{}) error

Properties setup the properties in the structure base on the tags

func Property

func Property(name string, defaultValue string) string

Property string value property from the default configuration source provider

func PropertyBool

func PropertyBool(name string, defaultValue bool) bool

PropertyBool bool value property from the default configuration source provider

func PropertyInt

func PropertyInt(name string, defaultValue int) int

PropertyInt int value property from the default configuration source provider

func SetProfile

func SetProfile(profile string)

SetProfile set profile to default provider

Types

type ConfigSource

type ConfigSource interface {
	// Init initialize method
	Init() error
	// Name of the configuration source
	Name() string
	// Priority of the configuration source
	Priority() int
	// Properties is the map of all avaiable properties in the configuration source
	Properties() (map[string]string, error)
	// Property get property by the name
	Property(name string) (string, bool, error)
}

ConfigSource configuration source interface

type ConfigSourceProvider

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

ConfigSourceProvider configuration source provider

var (
	// Default configuration source provider instance
	Default *ConfigSourceProvider
	// ConfigProfileProperty configuration profile property
	ConfigProfileProperty = "config.profile"
)

func (*ConfigSourceProvider) Add

Add methods add configuration sources

func (*ConfigSourceProvider) AddYaml

func (c *ConfigSourceProvider) AddYaml(resources fs.FS) error

AddYaml adds yaml configuration source for the embedded yaml file

func (*ConfigSourceProvider) Extension

func (c *ConfigSourceProvider) Extension(name string, value interface{}) error

Extension setup the properties in the structure base on the tags

func (*ConfigSourceProvider) Profile

func (c *ConfigSourceProvider) Profile() string

Profile configuration profile of the configuration source provider

func (*ConfigSourceProvider) Properties

func (c *ConfigSourceProvider) Properties(value interface{}) error

Properties setup the properties in the structure base on the tags

func (*ConfigSourceProvider) Property

func (c *ConfigSourceProvider) Property(name, defaultValue string) string

Property string value property from the configuration source provider

func (*ConfigSourceProvider) PropertyBool

func (c *ConfigSourceProvider) PropertyBool(name string, defaultValue bool) bool

PropertyBool bool value property from the configuration source provider

func (*ConfigSourceProvider) PropertyInt

func (c *ConfigSourceProvider) PropertyInt(name string, defaultValue int) int

PropertyInt int value property from the configuration source provider

func (*ConfigSourceProvider) SetProfile

func (c *ConfigSourceProvider) SetProfile(profile string)

SetProfile set configuration profile to provider

type EnvConfigSource

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

func (*EnvConfigSource) Init

func (f *EnvConfigSource) Init() error

func (*EnvConfigSource) Name

func (f *EnvConfigSource) Name() string

func (*EnvConfigSource) Priority

func (f *EnvConfigSource) Priority() int

func (*EnvConfigSource) Properties

func (f *EnvConfigSource) Properties() (map[string]string, error)

func (*EnvConfigSource) Property

func (f *EnvConfigSource) Property(name string) (string, bool, error)

type FlagsConfigSource

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

func (*FlagsConfigSource) Init

func (f *FlagsConfigSource) Init() error

func (*FlagsConfigSource) Name

func (f *FlagsConfigSource) Name() string

func (*FlagsConfigSource) Priority

func (f *FlagsConfigSource) Priority() int

func (*FlagsConfigSource) Properties

func (f *FlagsConfigSource) Properties() (map[string]string, error)

func (*FlagsConfigSource) Property

func (f *FlagsConfigSource) Property(name string) (string, bool, error)

type YamlConfigSource

type YamlConfigSource struct {
	Prio int
	// contains filtered or unexported fields
}

func (*YamlConfigSource) Init

func (y *YamlConfigSource) Init() error

func (*YamlConfigSource) Name

func (y *YamlConfigSource) Name() string

func (*YamlConfigSource) Priority

func (y *YamlConfigSource) Priority() int

func (*YamlConfigSource) Properties

func (y *YamlConfigSource) Properties() (map[string]string, error)

func (*YamlConfigSource) Property

func (y *YamlConfigSource) Property(name string) (string, bool, error)

Jump to

Keyboard shortcuts

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