feature

package
v1.0.0-rc.10 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package feature provide the framework to manage Feature in a generic way.

Index

Constants

View Source
const (
	// DefaultIDType enable default component feature.
	DefaultIDType IDType = "default"
	// DogstatsdIDType Dogstatsd feature.
	DogstatsdIDType = "dogstatsd"
	// EventCollectionIDType Event Collection feature.
	EventCollectionIDType = "event_collection"
	// ExternalMetricsIDType External metrics feature.
	ExternalMetricsIDType = "external_metrics"
	// KubernetesStateCoreIDType Kubernetes state core check feature.
	KubernetesStateCoreIDType = "ksm"
	// LiveContainerIDType Live Container feature.
	LiveContainerIDType = "live_container"
	// LiveProcessIDType Live Process feature.
	LiveProcessIDType = "live_process"
	// OrchestratorExplorerIDType Orchestrator Explorer feature.
	OrchestratorExplorerIDType = "orchestrator_explorer"
	// LogCollectionIDType Log Collection feature.
	LogCollectionIDType = "log_collection"
	// NPMIDType NPM feature.
	NPMIDType = "npm"
	// CSPMIDType CSPM feature.
	CSPMIDType = "cspm"
	// CWSIDType CWS feature.
	CWSIDType = "cws"
	// USMIDType USM feature.
	USMIDType = "usm"
	// OOMKillIDType OOM Kill check feature
	OOMKillIDType = "oom_kill"
	// PrometheusScrapeIDType Prometheus Scrape feature
	PrometheusScrapeIDType = "prometheus_scrape"
	// TCPQueueLengthIDType TCP Queue length check feature
	TCPQueueLengthIDType = "tcp_queue_length"
	// ClusterChecksIDType Cluster checks feature
	ClusterChecksIDType = "cluster_checks"
	// APMIDType APM feature
	APMIDType = "apm"
	// AdmissionControllerIDType Admission controller feature
	AdmissionControllerIDType = "admission_controller"
	// OTLPIDType OTLP ingest feature
	OTLPIDType = "otlp"
	// DummyIDType Dummy feature.
	DummyIDType = "dummy"
)

Variables

This section is empty.

Functions

func BuildFeatures

func BuildFeatures(dda *v2alpha1.DatadogAgent, options *Options) ([]Feature, RequiredComponents)

BuildFeatures use to build a list features depending of the v1alpha1.DatadogAgent instance

func BuildFeaturesV1

func BuildFeaturesV1(dda *v1alpha1.DatadogAgent, options *Options) ([]Feature, RequiredComponents)

BuildFeaturesV1 use to build a list features depending of the v1alpha1.DatadogAgent instance

func Register

func Register(id IDType, buildFunc BuildFunc) error

Register use to register a Feature to the Feature factory.

Types

type BuildFunc

type BuildFunc func(options *Options) Feature

BuildFunc function type used by each Feature during its factory registration. It returns the Feature interface.

type Feature

type Feature interface {
	// ID returns the ID of the Feature
	ID() IDType
	// Configure use to configure the internal of a Feature
	// It should return `true` if the feature is enabled, else `false`.
	Configure(dda *v2alpha1.DatadogAgent) RequiredComponents
	// ConfigureV1 use to configure the internal of a Feature from v1alpha1.DatadogAgent
	// It should return `true` if the feature is enabled, else `false`.
	ConfigureV1(dda *v1alpha1.DatadogAgent) RequiredComponents
	// ManageDependencies allows a feature to manage its dependencies.
	// Feature's dependencies should be added in the store.
	ManageDependencies(managers ResourceManagers, components RequiredComponents) error
	// ManageClusterAgent allows a feature to configure the ClusterAgent's corev1.PodTemplateSpec
	// It should do nothing if the feature doesn't need to configure it.
	ManageClusterAgent(managers PodTemplateManagers) error
	// ManageNodeAget allows a feature to configure the Node Agent's corev1.PodTemplateSpec
	// It should do nothing if the feature doesn't need to configure it.
	ManageNodeAgent(managers PodTemplateManagers) error
	// ManageClusterChecksRunner allows a feature to configure the ClusterChecksRunnerAgent's corev1.PodTemplateSpec
	// It should do nothing if the feature doesn't need to configure it.
	ManageClusterChecksRunner(managers PodTemplateManagers) error
}

Feature Feature interface It returns `true` if the Feature is used, else it return `false`.

type IDType

type IDType string

IDType use to identify a Feature

type Options

type Options struct {
	SupportExtendedDaemonset bool

	Logger logr.Logger
}

Options option that can be pass to the Interface.Configure function

type PodTemplateManagers

type PodTemplateManagers interface {
	// PodTemplateSpec used to access directly the PodTemplateSpec.
	PodTemplateSpec() *corev1.PodTemplateSpec
	// EnvVar used to access the EnvVarManager to manage the Environment variable defined in the PodTemplateSpec.
	EnvVar() merger.EnvVarManager
	// Volume used to access the VolumeManager to manage the Volume defined in the PodTemplateSpec.
	Volume() merger.VolumeManager
	// VolumeMount used to access the VolumeMountManager to manage the VolumeMount defined in the PodTemplateSpec.
	VolumeMount() merger.VolumeMountManager
	// SecurityContext is used to access the SecurityContextManager to manage container Security Context defined in the PodTemplateSpec.
	SecurityContext() merger.SecurityContextManager
	// Annotation is used access the AnnotationManager to manage PodTemplateSpec annotations.
	Annotation() merger.AnnotationManager
	// Ports used to access PortManager that allows to manage the Ports defined in the PodTemplateSpec.
	Port() merger.PortManager
}

PodTemplateManagers used to access the different PodTemplateSpec manager.

func NewPodTemplateManagers

func NewPodTemplateManagers(podTmpl *corev1.PodTemplateSpec) PodTemplateManagers

NewPodTemplateManagers use to create a new instance of PodTemplateManagers from a corev1.PodTemplateSpec argument

type RequiredComponent

type RequiredComponent struct {
	IsRequired *bool
	Containers []apicommonv1.AgentContainerName
}

RequiredComponent use to know how if a component is required and which containers are required. If set Required to:

  • true: the feature needs the corresponding component.
  • false: the corresponding component needs to ne disabled for this feature.
  • nil: the feature doesn't need the corresponding component.

func (*RequiredComponent) IsEnabled

func (rc *RequiredComponent) IsEnabled() bool

IsEnabled return true if the Feature need the current RequiredComponent

func (*RequiredComponent) Merge

Merge use to merge 2 RequiredComponents merge priority: false > true > nil *

type RequiredComponents

type RequiredComponents struct {
	ClusterAgent        RequiredComponent
	Agent               RequiredComponent
	ClusterChecksRunner RequiredComponent
}

RequiredComponents use to know which component need to be enabled for the feature

func (*RequiredComponents) IsEnabled

func (rc *RequiredComponents) IsEnabled() bool

IsEnabled return true if the Feature need to be enabled

func (*RequiredComponents) Merge

Merge use to merge 2 RequiredComponents merge priority: false > true > nil *

type ResourceManagers

type ResourceManagers interface {
	Store() dependencies.StoreClient
	RBACManager() merger.RBACManager
	PodSecurityManager() merger.PodSecurityManager
	SecretManager() merger.SecretManager
	NetworkPolicyManager() merger.NetworkPolicyManager
	ServiceManager() merger.ServiceManager
	CiliumPolicyManager() merger.CiliumPolicyManager
	ConfigMapManager() merger.ConfigMapManager
	APIServiceManager() merger.APIServiceManager
}

ResourceManagers used to access the different resources manager.

func NewResourceManagers

func NewResourceManagers(store dependencies.StoreClient) ResourceManagers

NewResourceManagers return new instance of the ResourceManagers interface

Jump to

Keyboard shortcuts

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