Documentation
¶
Index ¶
- func NewDiscovery(variables data.Map, metricAnnotations data.InterfaceMap, ...) discovery.Discovery
- func Replace(vals *Values, template interface{}, options ...ReplaceOption) (transformedData []data.Transformed, err error)
- func ReplaceBytes(vals *Values, template []byte, options ...ReplaceOption) ([][]byte, error)
- type Binder
- type DiscovererInfo
- type DiscovererType
- type OnDemand
- type ReplaceOption
- type Sources
- type Test
- type Values
- type YAMLAgentConfig
- type YAMLConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDiscovery ¶
func NewDiscovery(variables data.Map, metricAnnotations data.InterfaceMap, entityRewrites []data.EntityRewrite) discovery.Discovery
NewDiscovery returns an instance of discovery.Discovery aimed to be used for testing as prod should come from unmarshalling.
func Replace ¶
func Replace(vals *Values, template interface{}, options ...ReplaceOption) (transformedData []data.Transformed, err error)
Replace receives one template, which may be a map or a struct whose string fields may contain ${variable} placeholders, and returns an array of items of the same type of the template, but replacing the variable placeholders from the respective Values. The Values of type "variable" are the same for all the returned values. The returned array contains one instance per each "discovered" data value.
func ReplaceBytes ¶ added in v0.1.0
func ReplaceBytes(vals *Values, template []byte, options ...ReplaceOption) ([][]byte, error)
ReplaceBytes receives a byte array that may contain ${variable} placeholders, and returns an array of byte arrays replacing the variable placeholders from the respective Values.
Types ¶
type Binder ¶
type Binder interface {
// Fetch queries the Sources for discovery data and user-defined variables, and returns the
// acquired Values.
Fetch(ctx *Sources) (Values, error)
// Replace receives one template, which may be a map or a struct whose string fields may
// contain ${variable} placeholders, and returns an array of items of the same type of the
// template, but replacing the variable placeholders from the respective Values.
// The Values of type "variable" are the same for all the returned values. The returned
// array contains one instance per each "discovered" data value.
Replace(vals *Values, template interface{}, options ...ReplaceOption) (transformedData []data.Transformed, err error)
}
Binder wraps the functions provided by this package
type DiscovererInfo ¶
type DiscovererInfo struct {
Type DiscovererType
Name string
Matchers map[string]string
}
DiscovererInfo keeps util info about the discoverer.
type DiscovererType ¶
type DiscovererType string
type OnDemand ¶
OnDemand can be used during Replace and ReplaceBytes to dynamically get variable values given a variable name (key).
type ReplaceOption ¶
type ReplaceOption func(rc *replaceConfig)
Option provide extra behaviour configuration to the replacement process.
func Provided ¶
func Provided(od OnDemand) ReplaceOption
Provided configures the Replace and ReplaceBytes functions to get variables from the OnDemand function. If a given variable is not found on the variables/discovery replacement, the variable name is first looked up in the OnDemand provider before being replaced or discarded as not found.
type Sources ¶
type Sources struct {
Info DiscovererInfo
// contains filtered or unexported fields
}
Sources holds the configuration of all the discovery and variable sources. It is built from the LoadYAML function
type Test ¶
type Test struct {
Value interface{} `yaml:"value,omitempty" json:"value,omitempty"`
}
Test for testing purposes until providers get decoupled.
type Values ¶
type Values struct {
// contains filtered or unexported fields
}
The outcome of a sources Fetch process. It keeps both variables (secrets) and discovered matches
func Fetch ¶
Fetch queries the Sources for discovery data and user-defined variables, and returns the acquired Values.
type YAMLAgentConfig ¶
type YAMLAgentConfig struct {
Variables map[string]varEntry `yaml:"variables,omitempty" json:"variables,omitempty"` // key: variable name
}
func (*YAMLAgentConfig) DataSources ¶
func (dc *YAMLAgentConfig) DataSources() (*Sources, error)
type YAMLConfig ¶
type YAMLConfig struct {
YAMLAgentConfig `yaml:",inline"`
Discovery struct {
TTL string `yaml:"ttl,omitempty"`
Docker *discovery.Container `yaml:"docker,omitempty"`
Fargate *discovery.Container `yaml:"fargate,omitempty"`
Command *discovery.Command `yaml:"command,omitempty"`
} `yaml:"discovery"`
}
func (*YAMLConfig) DataSources ¶
func (dc *YAMLConfig) DataSources() (*Sources, error)
DataSources builds a set of data binding sources for the YAMLConfig instance.
func (*YAMLConfig) Enabled ¶
func (y *YAMLConfig) Enabled() bool