config

package
v0.0.1-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

This module is responsible for loading the config file

This package contains all the constants used throughout the application

Index

Constants

View Source
const DefaultEnvironment = "local"

This is the default name for the application config file: local.yaml

View Source
const DefaultEnvironmentConfigName = "CARBON_CONFIG"

The name of the config file can be changed via this environment variable

Variables

View Source
var (

	// The last time the config was updated/reloaded
	UpdatedAt time.Time
)

Functions

func InitConfig

func InitConfig(ctx context.Context)

Types

type APIConfig

type APIConfig struct {
	// The address to listen to
	Address string `mapstructure:"address"`

	// The port to listen to
	Port string `mapstructure:"port"`

	// The prometheus metrics path
	MetricsPath string `mapstructure:"metricsPath"`
}

Defines the configuration for the API

type Account

type Account struct {

	// AWS: The regions we should scrape the data for
	Regions []string `mapstructure:"regions"`

	// AWS Specific:
	// Cloudwatch namespaces
	// A namespace is a container for CloudWatch metrics.
	// Metrics in different namespaces are isolated from each other,
	// so that metrics from different applications are not mistakenly aggregated into the same statistics.
	// For example, Amazon EC2 uses the AWS/EC2 namespace.
	// For the list of AWS namespaces, see AWS services that publish CloudWatch metrics.
	// https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html
	Namespaces []string `mapstructure:"namespaces"`

	// GCP: The project
	Project string `mapstructure:"project"`

	// The location from where to load the credentials
	Credentials ProviderConfig `mapstructure:"credentials"`

	// The location from where to load the additional configuration
	Config ProviderConfig `mapstructure:"config"`
}

type ApplicationConfig

type ApplicationConfig struct {
	APIConfig       APIConfig   `mapstructure:"api"`
	Proxy           ProxyConfig `mapstructure:"proxy"`
	ProvidersConfig `mapstructure:"providersConfig"`
	Providers       map[v1.Provider]Provider `mapstructure:"providers"`
	LogLevel        string                   `mapstructure:"logLevel"`
	Cache           Cache                    `mapstructure:"cache"`
	Plugins         PluginConfig             `mapstructure:"plugins"`
}

ApplicationConfig is the full app config

func AppConfig

func AppConfig() *ApplicationConfig

AppConfig returns the app config

type Cache

type Cache struct {
	// The cache store built-into eko/gocache with
	// the default being bigcache
	Store string `mapstructure:"store"`

	// Cache key expiration time
	Expiry time.Duration `mapstructure:"expiry"`
}

Cache configurations

type PluginConfig

type PluginConfig struct {
	// Where to load exporter plugins from
	ExporterDir string `mapstructure:"exporterDir"`
	// Where to load source plugins from
	SourceDir string `mapstructure:"sourceDir"`
}

type Provider

type Provider struct {

	// A provider can have different accounts and scraping credentials and settings
	Accounts []Account `mapstructure:"accounts"`

	// The SDK Http Client transport configuration for the whole provider
	Transport TransportConfig `mapstructure:"transport"`
}

Defines the general configuration for a provider

type ProviderConfig

type ProviderConfig struct {
	// AWS: which profile to use
	Profile string `mapstructure:"profile"`

	// Where the file can be located
	FilePaths []string `mapstructure:"filePaths"`
}

func (ProviderConfig) IsPresent

func (pc ProviderConfig) IsPresent() bool

Whether the provider config has some values set

type ProvidersConfig

type ProvidersConfig struct {
	// How often we should scrape the data
	Interval time.Duration `mapstructure:"scrapingInterval"`
}

type ProxyConfig

type ProxyConfig struct {
	HTTPProxy  string `mapstructure:"httpProxy"`
	HTTPSProxy string `mapstructure:"httpsProxy"`
	NoProxy    string `mapstructure:"noProxy"`
}

Generic proxy configuration

type TransportConfig

type TransportConfig struct {
	// Proxy
	Proxy ProxyConfig `mapstructure:"proxy"`

	// Idle connection timeout
	IdleConnTimeout time.Duration `mapstructure:"idleConnTimeout"`

	// Max idle connections
	MaxIdleConns int `mapstructure:"maxIdleConns"`

	// maximum number of idle (keep-alive) connections per-host.
	MaxIdleConnsPerHost int `mapstructure:"maxIdleConnsPerHost"`

	// Timeout while reading headers
	ResponseHeaderTimeout time.Duration `mapstructure:"responseHeaderTimeout"`

	// maximum amount of time waiting for a TLS handshake to be completed
	TLSHandshakeTimeout time.Duration `mapstructure:"tlsHandshakeTimeout"`
}

Defines various Http Client transport settings

Jump to

Keyboard shortcuts

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