Documentation
¶
Index ¶
- func ActiveProfiles() []string
- func ConfigurationProperties[T any](prefix string, target *T) *T
- func MatchesProfiles(profiles ...string) bool
- func SetActiveProfiles(profiles string)
- func Value[T any](expression string) T
- type Base64PropertySource
- type Environment
- func (e *Environment) ActiveProfiles() []string
- func (e *Environment) AddPropertySource(source PropertySource)
- func (e *Environment) MatchesProfiles(profiles ...string) bool
- func (e *Environment) Property(key string) any
- func (e *Environment) PropertySources() []PropertySource
- func (e *Environment) ResolveRequiredPlaceholders(expression string) any
- type ExprProcessor
- type MapPropertySource
- func (s *MapPropertySource) ContainsProperty(key string) bool
- func (s *MapPropertySource) HasProperty(key string) bool
- func (s *MapPropertySource) Name() string
- func (s *MapPropertySource) Properties() map[string]string
- func (s *MapPropertySource) Property(key string) string
- func (s *MapPropertySource) SetProperties(properties map[string]string)
- func (s *MapPropertySource) SetProperty(key string, value string)
- type PropertiesPropertySource
- type PropertySource
- type YamlPropertySource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigurationProperties ¶
func MatchesProfiles ¶ added in v1.0.9
Determine whether one or more of the given profiles is active.
If a profile begins with '!' the logic is inverted, meaning this method will return true if the given profile is not active. For example, env.MatchesProfiles("p1", "!p2") will return true if profile 'p1' is active or 'p2' is not active. A compound expression allows for more complicated profile logic to be expressed, for example "production & cloud".
func SetActiveProfiles ¶
func SetActiveProfiles(profiles string)
Bootstrap new environment with profiles listed, last wins. Do nothing if very profiles are already set in the specified order. Reload environment if empty value provided
Types ¶
type Base64PropertySource ¶
type Base64PropertySource struct {
// contains filtered or unexported fields
}
custom property source as additional logic for properties processing, like property=base64:dGVzdAo=
func NewBase64PropertySource ¶
func NewBase64PropertySource(environment *Environment) *Base64PropertySource
func (*Base64PropertySource) HasProperty ¶
func (s *Base64PropertySource) HasProperty(key string) bool
func (*Base64PropertySource) Name ¶
func (s *Base64PropertySource) Name() string
func (*Base64PropertySource) Properties ¶
func (s *Base64PropertySource) Properties() map[string]string
func (*Base64PropertySource) Property ¶
func (s *Base64PropertySource) Property(key string) string
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
func Instance ¶
func Instance() *Environment
func (*Environment) AddPropertySource ¶
func (e *Environment) AddPropertySource(source PropertySource)
custom property source as additional logic for properties processing, like property=base64:dGVzdAo=, see Base64PropertySource as an example
env.Instance().AddPropertySource(env.NewBase64PropertySource(env.Instance()))
func (*Environment) MatchesProfiles ¶
func (e *Environment) MatchesProfiles(profiles ...string) bool
Determine whether one or more of the given profiles is active.
If a profile begins with '!' the logic is inverted, meaning this method will return true if the given profile is not active. For example, env.MatchesProfiles("p1", "!p2") will return true if profile 'p1' is active or 'p2' is not active. A compound expression allows for more complicated profile logic to be expressed, for example "production & cloud".
func (*Environment) Property ¶
func (e *Environment) Property(key string) any
func (*Environment) PropertySources ¶
func (e *Environment) PropertySources() []PropertySource
first wins
func (*Environment) ResolveRequiredPlaceholders ¶
func (e *Environment) ResolveRequiredPlaceholders(expression string) any
type ExprProcessor ¶
type ExprProcessor struct { text.PatternProcessor // contains filtered or unexported fields }
func ExprProcessorOf ¶
func ExprProcessorOf(strict bool) *ExprProcessor
func (*ExprProcessor) Define ¶
func (p *ExprProcessor) Define(key string, value any)
func (*ExprProcessor) Reset ¶
func (p *ExprProcessor) Reset()
func (*ExprProcessor) SetStrict ¶
func (p *ExprProcessor) SetStrict(strict bool)
type MapPropertySource ¶
type MapPropertySource struct {
// contains filtered or unexported fields
}
func MapPropertySourceOf ¶
func MapPropertySourceOf(name string) *MapPropertySource
func MapPropertySourceOfMap ¶
func MapPropertySourceOfMap(name string, source map[string]string) *MapPropertySource
func (*MapPropertySource) ContainsProperty ¶
func (s *MapPropertySource) ContainsProperty(key string) bool
func (*MapPropertySource) HasProperty ¶
func (s *MapPropertySource) HasProperty(key string) bool
func (*MapPropertySource) Name ¶
func (s *MapPropertySource) Name() string
func (*MapPropertySource) Properties ¶
func (s *MapPropertySource) Properties() map[string]string
func (*MapPropertySource) Property ¶
func (s *MapPropertySource) Property(key string) string
func (*MapPropertySource) SetProperties ¶
func (s *MapPropertySource) SetProperties(properties map[string]string)
func (*MapPropertySource) SetProperty ¶
func (s *MapPropertySource) SetProperty(key string, value string)
type PropertiesPropertySource ¶
type PropertiesPropertySource struct {
MapPropertySource
}
func NewPropertiesPropertySource ¶
func NewPropertiesPropertySource(name, content string) *PropertiesPropertySource
type PropertySource ¶
type YamlPropertySource ¶
type YamlPropertySource struct {
MapPropertySource
}
func NewYamlPropertySource ¶
func NewYamlPropertySource(name, yaml string) *YamlPropertySource