common

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAKSNameSuffix

func ApplyAKSNameSuffix(cluster types.KubeCluster)

ApplyAKSNameSuffix applies the Azure AKS Discovery name suffix to the given kube cluster. Format: <name>-aks-<region>-<resource group>-<subscription ID>.

func ApplyAWSDatabaseNameSuffix

func ApplyAWSDatabaseNameSuffix(db types.Database, matcherType string)

ApplyAWSDatabaseNameSuffix applies the AWS Database Discovery name suffix to the given database. Format: <name>-<matcher type>-<region>-<account ID>.

func ApplyAzureDatabaseNameSuffix

func ApplyAzureDatabaseNameSuffix(db types.Database, matcherType string)

ApplyAzureDatabaseNameSuffix applies the Azure Database Discovery name suffix to the given database. Format: <name>-<matcher type>-<region>-<resource group>-<subscription ID>.

func ApplyEKSNameSuffix

func ApplyEKSNameSuffix(cluster types.KubeCluster)

ApplyEKSNameSuffix applies the AWS EKS Discovery name suffix to the given kube cluster. Format: <name>-eks-<region>-<account ID>.

func ApplyGKENameSuffix

func ApplyGKENameSuffix(cluster types.KubeCluster)

ApplyGKENameSuffix applies the GCP GKE Discovery name suffix to the given kube cluster. Format: <name>-gke-<location>-<project ID>.

func StaticFetchers

func StaticFetchers(fs []Fetcher) func() []Fetcher

StaticFetchers converts a list of Fetchers into a function that returns them. Used to convert a static set of Fetchers into a FetchersFn generator.

Types

type Fetcher

type Fetcher interface {
	// Get returns the list of resources from the cloud after applying the filters.
	Get(ctx context.Context) (types.ResourcesWithLabels, error)
	// ResourceType identifies the resource type the fetcher is returning.
	ResourceType() string
	// FetcherType identifies the Fetcher Type (cloud resource name).
	// Eg, ec2, rds, aks, gce
	FetcherType() string
	// Cloud returns the cloud the fetcher is operating.
	Cloud() string
}

Fetcher defines the common methods across all fetchers.

type Watcher

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

Watcher monitors cloud resources with provided fetchers.

func NewWatcher

func NewWatcher(ctx context.Context, config WatcherConfig) (*Watcher, error)

NewWatcher returns a new instance of a common discovery watcher.

func (*Watcher) ResourcesC

func (w *Watcher) ResourcesC() <-chan types.ResourcesWithLabels

Resources returns a channel that receives fetched cloud resources.

func (*Watcher) Start

func (w *Watcher) Start()

Start starts fetching cloud resources and sending them to the channel.

type WatcherConfig

type WatcherConfig struct {
	// FetchersFn is a function that returns the fetchers used for this watcher.
	FetchersFn func() []Fetcher
	// Interval is the interval between fetches.
	Interval time.Duration
	// TriggerFetchC can be used to force an instant Poll, instead of waiting for the next poll Interval.
	TriggerFetchC chan struct{}
	// Log is the watcher logger.
	Log logrus.FieldLogger
	// Clock is used to control time.
	Clock clockwork.Clock
	// DiscoveryGroup is the name of the discovery group that the current
	// discovery service is a part of.
	// It is used to filter out discovered resources that belong to another
	// discovery services. When running in high availability mode and the agents
	// have access to the same cloud resources, this field value must be the same
	// for all discovery services. If different agents are used to discover different
	// sets of cloud resources, this field must be different for each set of agents.
	DiscoveryGroup string
	// Origin is used to specify what type of origin watcher's resources are
	Origin string
}

WatcherConfig is the common discovery watcher configuration.

func (*WatcherConfig) CheckAndSetDefaults

func (c *WatcherConfig) CheckAndSetDefaults() error

CheckAndSetDefaults validates the config.

Jump to

Keyboard shortcuts

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