metadata

package
v1.31.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 31 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (

	// default timeout for metadata operations
	DefaultOperationTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

func EncodeKey added in v1.28.0

func EncodeKey(kind, namespace, name string) string

EncodeKey returns "<kind>/<namespace>/<name>".

Types

type CRDInstance added in v1.22.0

type CRDInstance struct {
	Kind        string            `json:"kind"`
	Name        string            `json:"name"`
	Namespace   string            `json:"namespace"`
	APIVersion  string            `json:"api_version"`
	UID         string            `json:"uid"`
	Spec        any               `json:"spec"`
	Labels      map[string]string `json:"labels,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
}

type CRDMetadata added in v1.22.0

type CRDMetadata struct {
	// Shared
	OperatorVersion   string `json:"operator_version"`
	KubernetesVersion string `json:"kubernetes_version"`
	ClusterID         string `json:"cluster_id"`

	CRDKind            string `json:"crd_kind"`
	CRDName            string `json:"crd_name"`
	CRDNamespace       string `json:"crd_namespace"`
	CRDAPIVersion      string `json:"crd_api_version"`
	CRDUID             string `json:"crd_uid"`
	CRDSpecFull        string `json:"crd_spec_full"`
	CRDLabelsJSON      string `json:"crd_labels,omitempty"`
	CRDAnnotationsJSON string `json:"crd_annotations,omitempty"`
}

type CRDMetadataForwarder added in v1.22.0

type CRDMetadataForwarder struct {
	*SharedMetadata
	// contains filtered or unexported fields
}

func NewCRDMetadataForwarder added in v1.22.0

func NewCRDMetadataForwarder(
	logger logr.Logger,
	mgr manager.Manager,
	kubernetesVersion string,
	operatorVersion string,
	credsManager *config.CredentialManager,
	cfg EnabledCRDKindsConfig,
) *CRDMetadataForwarder

NewCRDMetadataForwarder creates a new CRD metadata forwarder. The forwarder must be registered with the manager via mgr.Add(...) by the caller.

func (*CRDMetadataForwarder) NeedLeaderElection added in v1.28.0

func (cmf *CRDMetadataForwarder) NeedLeaderElection() bool

NeedLeaderElection implements manager.LeaderElectionRunnable. CRD metadata sends must be deduplicated across operator replicas.

func (*CRDMetadataForwarder) Start added in v1.22.0

func (cmf *CRDMetadataForwarder) Start(ctx context.Context) error

Start implements manager.Runnable. Registers informer watches for each enabled CRD kind and then runs the InformerWorkQueue until ctx is cancelled.

type CRDMetadataPayload added in v1.22.0

type CRDMetadataPayload struct {
	UUID      string      `json:"uuid"`
	Timestamp int64       `json:"timestamp"`
	ClusterID string      `json:"cluster_id"`
	Metadata  CRDMetadata `json:"datadog_operator_crd_metadata"`
}

type DeleteFunc added in v1.28.0

type DeleteFunc func(kind, namespace, name string)

DeleteFunc is invoked for delete events.

type EnabledCRDKindsConfig added in v1.22.0

type EnabledCRDKindsConfig struct {
	DatadogAgentEnabled         bool
	DatadogAgentInternalEnabled bool
	DatadogAgentProfileEnabled  bool
}

EnabledCRDKindsConfig specifies which CRD kinds are enabled for metadata collection.

type HeartbeatFunc added in v1.28.0

type HeartbeatFunc func(ctx context.Context)

HeartbeatFunc is invoked on every heartbeat tick. nil disables the ticker.

type HelmMetadata added in v1.21.0

type HelmMetadata struct {
	// Shared
	OperatorVersion   string `json:"operator_version"`
	KubernetesVersion string `json:"kubernetes_version"`
	ClusterID         string `json:"cluster_id"`

	ChartName                 string `json:"chart_name"`
	ChartReleaseName          string `json:"chart_release_name"`
	ChartAppVersion           string `json:"chart_app_version"`
	ChartVersion              string `json:"chart_version"`
	ChartNamespace            string `json:"chart_namespace"`
	ChartConfigMapUID         string `json:"chart_configmap_uid"`
	HelmProvidedConfiguration string `json:"helm_provided_configuration"` // User-provided values only
	HelmFullConfiguration     string `json:"helm_full_configuration"`     // Includes defaults
}

type HelmMetadataForwarder added in v1.21.0

type HelmMetadataForwarder struct {
	*SharedMetadata
	// contains filtered or unexported fields
}

func NewHelmMetadataForwarderWithManager added in v1.24.0

func NewHelmMetadataForwarderWithManager(logger logr.Logger, mgr manager.Manager, k8sClient client.Reader, kubernetesVersion string, operatorVersion string, credsManager *config.CredentialManager) *HelmMetadataForwarder

NewHelmMetadataForwarderWithManager creates a new instance of the helm metadata forwarder

func (*HelmMetadataForwarder) NeedLeaderElection added in v1.24.0

func (hmf *HelmMetadataForwarder) NeedLeaderElection() bool

NeedLeaderElection implements manager.LeaderElectionRunnable

func (*HelmMetadataForwarder) Start added in v1.21.0

func (hmf *HelmMetadataForwarder) Start(ctx context.Context) error

Start implements manager.Runnable.

type HelmMetadataPayload added in v1.21.0

type HelmMetadataPayload struct {
	UUID      string       `json:"uuid"`
	Timestamp int64        `json:"timestamp"`
	ClusterID string       `json:"cluster_id"`
	Metadata  HelmMetadata `json:"datadog_operator_helm_metadata"`
}

type HelmReleaseData added in v1.21.0

type HelmReleaseData struct {
	ReleaseName    string
	Namespace      string
	ChartName      string
	ChartVersion   string
	AppVersion     string
	ConfigMapUID   string
	ProvidedValues string // User-provided values only
	FullValues     string // Includes defaults
	Revision       int
	Status         string
}

HelmReleaseData contains all data for a single Helm release

type HelmReleaseMinimal added in v1.21.0

type HelmReleaseMinimal struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Info      struct {
		Status string `json:"status"`
	} `json:"info"`
	Config map[string]any `json:"config"` // User-provided values only
	Chart  struct {
		Metadata struct {
			Name       string `json:"name"`
			Version    string `json:"version"`
			AppVersion string `json:"appVersion"`
		} `json:"metadata"`
		Values map[string]any `json:"values"` // Defaults
	} `json:"chart"`
	Version int `json:"version"` // Revision number
}

HelmReleaseMinimal represents the minimal structure we care about from Helm release

type InformerWorkQueue added in v1.28.0

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

InformerWorkQueue is the shared engine for event-driven metadata forwarders. It owns a rate-limited workqueue, a worker pool that drains it, and an optional heartbeat ticker. Callers register informers via AddWatch and supply ProcessFunc / DeleteFunc / HeartbeatFunc callbacks.

func NewInformerWorkQueue added in v1.28.0

func NewInformerWorkQueue(
	logger logr.Logger,
	mgr manager.Manager,
	numWorkers int,
	heartbeatInterval time.Duration,
	processFn ProcessFunc,
	deleteFn DeleteFunc,
	heartbeatFn HeartbeatFunc,
) *InformerWorkQueue

NewInformerWorkQueue constructs a runner. heartbeatInterval = 0 disables the ticker.

func (*InformerWorkQueue) AddWatch added in v1.28.0

func (r *InformerWorkQueue) AddWatch(ctx context.Context, target WatchTarget) bool

AddWatch registers an informer for the target. Returns true if RBAC and informer setup both succeeded; false (with a logged warning) otherwise. Failure is non-fatal: the caller may continue running with a subset of watches enabled.

func (*InformerWorkQueue) Enqueue added in v1.28.0

func (r *InformerWorkQueue) Enqueue(kind, namespace, name string)

Enqueue adds a key for an add/update event.

func (*InformerWorkQueue) EnqueueDelete added in v1.28.0

func (r *InformerWorkQueue) EnqueueDelete(kind, namespace, name string)

EnqueueDelete adds a key for a delete event.

func (*InformerWorkQueue) QueueLen added in v1.28.0

func (r *InformerWorkQueue) QueueLen() int

QueueLen exposes the queue length for tests and metrics.

func (*InformerWorkQueue) Run added in v1.28.0

func (r *InformerWorkQueue) Run(ctx context.Context)

Run blocks until ctx is done. It spawns numWorkers goroutines that drain the queue, plus a heartbeat ticker if heartbeatInterval > 0 and heartbeatFn != nil.

type OperatorMetadata

type OperatorMetadata struct {
	// Shared
	OperatorVersion   string `json:"operator_version"`
	KubernetesVersion string `json:"kubernetes_version"`
	ClusterID         string `json:"cluster_id"`

	InstallMethodTool             string         `json:"install_method_tool"`
	InstallMethodToolVersion      string         `json:"install_method_tool_version"`
	IsLeader                      bool           `json:"is_leader"`
	DatadogAgentEnabled           bool           `json:"datadogagent_enabled"`
	DatadogMonitorEnabled         bool           `json:"datadogmonitor_enabled"`
	DatadogDashboardEnabled       bool           `json:"datadogdashboard_enabled"`
	DatadogSLOEnabled             bool           `json:"datadogslo_enabled"`
	DatadogGenericResourceEnabled bool           `json:"datadoggenericresource_enabled"`
	DatadogAgentProfileEnabled    bool           `json:"datadogagentprofile_enabled"`
	DatadogAgentInternalEnabled   bool           `json:"datadogagentinternal_enabled"`
	LeaderElectionEnabled         bool           `json:"leader_election_enabled"`
	RemoteConfigEnabled           bool           `json:"remote_config_enabled"`
	RemoteUpdatesEnabled          bool           `json:"remote_updates_enabled"`
	IntrospectionEnabled          bool           `json:"introspection_enabled"`
	ConfigDDURL                   string         `json:"config_dd_url"`
	ConfigDDSite                  string         `json:"config_site"`
	ResourceCounts                map[string]int `json:"resource_count"`
}

type OperatorMetadataForwarder added in v1.21.0

type OperatorMetadataForwarder struct {
	*SharedMetadata

	OperatorMetadata OperatorMetadata
	// contains filtered or unexported fields
}

func NewOperatorMetadataForwarder added in v1.21.0

func NewOperatorMetadataForwarder(logger logr.Logger, k8sClient client.Reader, kubernetesVersion, operatorVersion string, credsManager *config.CredentialManager) *OperatorMetadataForwarder

NewOperatorMetadataForwarder creates a new instance of the operator metadata forwarder

func (*OperatorMetadataForwarder) GetPayload added in v1.21.0

func (omf *OperatorMetadataForwarder) GetPayload(clusterUID string) []byte

func (*OperatorMetadataForwarder) Start added in v1.21.0

func (omf *OperatorMetadataForwarder) Start()

Start starts the operator metadata forwarder

type OperatorMetadataPayload

type OperatorMetadataPayload struct {
	UUID      string           `json:"uuid"`
	Timestamp int64            `json:"timestamp"`
	ClusterID string           `json:"cluster_id"`
	Metadata  OperatorMetadata `json:"datadog_operator_metadata"`
}

type ProcessFunc added in v1.28.0

type ProcessFunc func(ctx context.Context, kind, namespace, name string) error

ProcessFunc is invoked for add/update events. The runner has already split the queue key into (kind, namespace, name) for the caller.

type ReleaseEntry added in v1.24.0

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

ReleaseEntry wraps a ReleaseSnapshot with a mutex for safe concurrent access

type ReleaseSnapshot added in v1.24.0

type ReleaseSnapshot struct {
	Release        *HelmReleaseMinimal
	ReleaseName    string
	Namespace      string
	ChartName      string
	ChartVersion   string
	AppVersion     string
	ConfigMapUID   string
	ProvidedValues string
	FullValues     string
	Revision       int
	Status         string
}

ReleaseSnapshot holds a snapshot of a Helm release

type SharedMetadata added in v1.21.0

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

SharedMetadata contains the common metadata shared across all forwarders

func NewSharedMetadata added in v1.21.0

func NewSharedMetadata(logger logr.Logger, k8sClient client.Reader, kubernetesVersion string, operatorVersion string, credsManager *config.CredentialManager) *SharedMetadata

NewSharedMetadata creates a new instance of shared metadata

func (*SharedMetadata) GetHeaders added in v1.21.0

func (sm *SharedMetadata) GetHeaders(apiKey string) http.Header

GetHeaders returns the common HTTP headers for API requests.

func (*SharedMetadata) GetOrCreateClusterUID added in v1.21.0

func (sm *SharedMetadata) GetOrCreateClusterUID(ctx context.Context) (string, error)

GetOrCreateClusterUID retrieves the cluster UID from kube-system namespace

type WatchTarget added in v1.28.0

type WatchTarget struct {
	// Object is a typed example of the resource to watch (e.g. &corev1.ConfigMap{}).
	Object client.Object
	// Group is the API group for RBAC checks (e.g. "datadoghq.com"). Empty string
	// means the core/legacy API group ("" matches v1 core resources like ConfigMap).
	Group string
	// Resource is the lowercase plural resource name used for RBAC checks (e.g. "configmaps").
	Resource string
	// Kind is the prefix used for queue keys produced by this watch (e.g. "ConfigMap").
	Kind string
	// Filter, if non-nil, gates whether an event is enqueued.
	Filter func(obj any) bool
	// MetaKey extracts (namespace, name) from the object. If nil, controller-runtime's
	// MetaNamespaceKeyFunc is used and the result split on "/".
	MetaKey func(obj any) (namespace, name string, ok bool)
}

WatchTarget describes one informer registration.

Jump to

Keyboard shortcuts

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