utils

package
v0.0.0-...-f4cfdf3 Latest Latest
Warning

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

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

Documentation

Overview

Package utils implements helper methods used in the Autodiscovery code.

Index

Constants

View Source
const (
	// KubeAnnotationPrefix is the prefix used by AD in Kubernetes
	// annotations.
	KubeAnnotationPrefix = "ad.datadoghq.com/"
)

Variables

This section is empty.

Functions

func AddContainerCollectAllConfigs

func AddContainerCollectAllConfigs(configs []integration.Config, adIdentifier string) []integration.Config

AddContainerCollectAllConfigs adds a config template containing an empty LogsConfig when `logs_config.container_collect_all` is set. This config will be filtered out during config resolution if another config template also has logs configuration.

func BuildTemplates

func BuildTemplates(adID string, checkNames []string, initConfigs, instances [][]integration.Data, ignoreAutodiscoveryTags bool, checkCard string) []integration.Config

BuildTemplates returns check configurations configured according to the passed in AD identifier, check names, init, instance configs and their `ignoreAutoDiscoveryTags`, `CheckTagCardinality` fields.

func ExtractCheckIDFromPodAnnotations

func ExtractCheckIDFromPodAnnotations(annotations map[string]string, containerName string) (string, bool)

ExtractCheckIDFromPodAnnotations returns whether there is a custom check ID for a given container based on the pod annotations

func ExtractCheckNamesFromContainerLabels

func ExtractCheckNamesFromContainerLabels(labels map[string]string) ([]string, error)

ExtractCheckNamesFromContainerLabels returns check names from a map of container annotations. It prefers annotations v2 where available, otherwise falling back to v1.

func ExtractCheckNamesFromPodAnnotations

func ExtractCheckNamesFromPodAnnotations(annotations map[string]string, adIdentifier string) ([]string, error)

ExtractCheckNamesFromPodAnnotations returns check names from a map of pod annotations. In order of priority, it prefers annotations v2, v1, and legacy.

func ExtractTemplatesFromAnnotations

func ExtractTemplatesFromAnnotations(entityName string, annotations map[string]string, adIdentifier string) ([]integration.Config, []error)

ExtractTemplatesFromAnnotations looks for autodiscovery configurations in a map of annotations and returns them if found. In order of priority, it prefers annotations v2, v1, and legacy.

func ExtractTemplatesFromContainerLabels

func ExtractTemplatesFromContainerLabels(entityName string, labels map[string]string) ([]integration.Config, []error)

ExtractTemplatesFromContainerLabels looks for autodiscovery configurations in a map of labels and returns them if found. In order of priority, it prefers annotations v2, and then v1.

func ExtractTemplatesFromMap

func ExtractTemplatesFromMap(key string, input map[string]string, prefix string) ([]integration.Config, []error)

ExtractTemplatesFromMap looks for autodiscovery configurations in a given map and returns them if found.

func ParseCheckNames

func ParseCheckNames(names string) (res []string, err error)

ParseCheckNames returns a slice of check names parsed from a JSON array

func ParseJSONValue

func ParseJSONValue(value string) ([][]integration.Data, error)

ParseJSONValue returns a slice of slice of ConfigData parsed from the JSON contained in the `value` parameter

func ValidateAnnotationsMatching

func ValidateAnnotationsMatching(annotations map[string]string, containerIdentifiers map[string]struct{}, containerNames map[string]struct{}) []error

ValidateAnnotationsMatching detects if annotations using the new AD annotation format don't match a valid container identifier

Types

This section is empty.

Jump to

Keyboard shortcuts

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