config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TraceLoggingName is the environment variable used to enable tracing in logs,
	// when the application uses the default logger instead of injecting its own.
	TraceLoggingName = `BEARER_TRACE`

	// DefaultConfigEndpoint is the default configuration endpoint for Bearer.
	DefaultConfigEndpoint = "https://config.bearer.sh/config"

	// DefaultFetchInterval is the default rate at which the Fetcher will
	// asynchronously fetch configuration refreshes from Bearer.
	DefaultFetchInterval = 5 * time.Second

	// DefaultReportEndpoint is the default reporting endpoint for Bearer.
	DefaultReportEndpoint = "https://agent.bearer.sh/logs"

	// DefaultReportOutstanding it the default maximum number of pending data
	// collection writes in flight at any given time. When that limit is
	// exceeded, records are no longer sent to Bearer to avoid saturating the
	// client.
	DefaultReportOutstanding = 1000
)

Variables

View Source
var TraceLogging = false

TraceLogging is set in init() and enabled the default logger for Trace level.

Functions

func DefaultLogger

func DefaultLogger() *zerolog.Logger

DefaultLogger builds a logger to os.Stderr that won't log Trace information.

func IsSecretKeyWellFormed

func IsSecretKeyWellFormed(secretKey string) bool

IsSecretKeyWellFormed verifies whether the secret key matches the expected format.

Types

type Description

type Description struct {
	DataCollectionRules []interception.DataCollectionRuleDescription
	Filters             map[string]filters.FilterDescription
	Rules               []struct {
		FilterHash   string
		ID           int
		Remediations []interface{}
		RuleType     string
	}
	Error map[string]string
}

Description is a serialization-friendly description of the parts of Config which may come from the config server.

func (Description) FilterDescriptions

func (d Description) FilterDescriptions() (map[string]*filters.FilterDescription, error)

FilterDescriptions walks the Description.Filters to collate the filter descriptions.

func (*Description) ResolveDCRs

func (d *Description) ResolveDCRs(filterMap filters.FilterMap) ([]*interception.DataCollectionRule, error)

ResolveDCRs creates a slice of DataCollectionRule values from a resolved filters.FilterMap.

func (Description) ResolveHashes

func (d Description) ResolveHashes(descriptions map[string]*filters.FilterDescription) (filters.FilterMap, error)

ResolveHashes builds a filters.FilterMap from the filter descriptions it receives, resolving dependencies to allow instantiation. The function detects cyclic dependencies, and returns errors accordingly.

Algorithm inspired by: https://www.electricmonk.nl/docs/dependency_resolving_algorithm/dependency_resolving_algorithm.html

func (Description) String

func (d Description) String() string

type Fetcher

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

Fetcher describes the data used to perform the background configuration refresh.

func NewFetcher

func NewFetcher(transport http.RoundTripper, logger *zerolog.Logger, version string, fetchEndpoint string, fetchInterval time.Duration, environmentType string, secretKey string) *Fetcher

NewFetcher builds an un-started Fetcher.

func (*Fetcher) Fetch

func (f *Fetcher) Fetch() (*Description, error)

Fetch fetches a fresh configuration from the Bearer platform and assigns it to the current config. As per Agent spec, all config fetch errors are logged and ignored.

func (*Fetcher) Start

func (f *Fetcher) Start(configSetter func(*Description))

Start activates the fetcher background operation.

func (*Fetcher) Stop

func (f *Fetcher) Stop()

Stop deactivates the fetcher background operation.

Jump to

Keyboard shortcuts

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