providers

package
v0.0.0-...-1d9613f Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

README

package providers

Providers implement the ConfigProvider interface and are responsible for scanning different sources like files on disk, environment variables or databases, searching for check configurations. Every configuration, regardless of the format, must specify at least one check instance. Providers dump every configuration they find into a CheckConfig struct containing an array of configuration instances. Configuration instances are converted in YAML format so that a check object will be eventually able to convert them into the appropriate data structure.

Usage example:

var configs []loader.CheckConfig
for _, provider := range configProviders {
  c, _ := provider.Collect()
  configs = append(configs, c...)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderCatalog = make(map[string]ConfigProviderFactory)

ProviderCatalog keeps track of config providers by name

Functions

func GetCheckConfigFromFile

func GetCheckConfigFromFile(name, fpath string) (check.Config, error)

GetCheckConfigFromFile returns an instance of check.Config if `fpath` points to a valid config file

func RegisterProvider

func RegisterProvider(name string, factory ConfigProviderFactory)

RegisterProvider adds a loader to the providers catalog

Types

type ConfigProvider

type ConfigProvider interface {
	Collect() ([]check.Config, error)
	String() string
	IsUpToDate() (bool, error)
}

ConfigProvider is the interface that wraps the Collect method

Collect is responsible of populating a list of CheckConfig instances by retrieving configuration patterns from external resources: files on disk, databases, environment variables are just few examples.

Any type implementing the interface will take care of any dependency or data needed to access the resource providing the configuration. IsUpToDate checks the local cache of the CP and returns accordingly.

func NewECSConfigProvider

func NewECSConfigProvider(config config.ConfigurationProviders) (ConfigProvider, error)

NewECSConfigProvider returns a new ECSConfigProvider. It configures an http Client with a 500 ms timeout.

type ConfigProviderFactory

type ConfigProviderFactory func(cfg config.ConfigurationProviders) (ConfigProvider, error)

ConfigProviderFactory is any function capable to create a ConfigProvider instance

type ECSConfigProvider

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

ECSConfigProvider implements the ConfigProvider interface. It collects configuration templates from the ECS metadata API.

func (*ECSConfigProvider) Collect

func (p *ECSConfigProvider) Collect() ([]check.Config, error)

Collect finds all running containers in the agent's task, reads their labels and extract configuration templates from them for auto discovery.

func (*ECSConfigProvider) IsUpToDate

func (p *ECSConfigProvider) IsUpToDate() (bool, error)

IsUpToDate updates the list of AD templates versions in the Agent's cache and checks the list is up to date compared to ECS' data.

func (*ECSConfigProvider) String

func (p *ECSConfigProvider) String() string

String returns a string representation of the ECSConfigProvider

type FileConfigProvider

type FileConfigProvider struct {
	Errors map[string]string
	// contains filtered or unexported fields
}

FileConfigProvider collect configuration files from disk

func NewFileConfigProvider

func NewFileConfigProvider(paths []string) *FileConfigProvider

NewFileConfigProvider creates a new FileConfigProvider searching for configuration files on the given paths

func (*FileConfigProvider) Collect

func (c *FileConfigProvider) Collect() ([]check.Config, error)

Collect scans provided paths searching for configuration files. When found, it parses the files and try to unmarshall Yaml contents into a CheckConfig instance

func (*FileConfigProvider) IsUpToDate

func (c *FileConfigProvider) IsUpToDate() (bool, error)

IsUpToDate is not implemented for the file Providers as the files are not meant to change very often.

func (*FileConfigProvider) String

func (c *FileConfigProvider) String() string

String returns a string representation of the FileConfigProvider

type ProviderCache

type ProviderCache struct {
	LatestTemplateIdx float64
	NumAdTemplates    int
}

ProviderCache contains the number of AD Templates and the latest Index

func NewCPCache

func NewCPCache() *ProviderCache

NewCPCache instantiate a ProviderCache.

Jump to

Keyboard shortcuts

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