components

package
v0.148.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRecAddress = "0.0.0.0"

Variables

View Source
var (
	GrpcProtocol    = "grpc"
	HttpProtocol    = "http"
	UnsetPort       int32
	PortNotFoundErr = errors.New("port should not be empty")
)

Functions

func AddressDefaulter added in v0.110.0

func AddressDefaulter(_ logr.Logger, defaultCfg *DefaultConfig, defaultRecAddr string, port int32, config *SingleEndpointConfig) (map[string]any, error)

func ComponentType

func ComponentType(name string) string

ComponentType returns the type for a given component name. components have a name like: - mycomponent/custom - mycomponent we extract the "mycomponent" part and see if we have a parser for the component.

func ConstructServicePort

func ConstructServicePort(current *corev1.ServicePort, port int32) corev1.ServicePort

func ParseSingleEndpoint added in v0.108.0

func ParseSingleEndpoint(logger logr.Logger, name string, defaultPort *corev1.ServicePort, singleEndpointConfig *SingleEndpointConfig) ([]corev1.ServicePort, error)

func ParseSingleEndpointSilent added in v0.108.0

func ParseSingleEndpointSilent(logger logr.Logger, name string, defaultPort *corev1.ServicePort, singleEndpointConfig *SingleEndpointConfig) ([]corev1.ServicePort, error)

func PortFromEndpoint

func PortFromEndpoint(endpoint string) (int32, error)

func TLSVersionToCollectorFormat added in v0.146.0

func TLSVersionToCollectorFormat(version uint16) string

TLSVersionToCollectorFormat converts a TLS version constant to collector format string.

Types

type Builder added in v0.109.0

type Builder[ComponentConfigType any] []ParserOption[ComponentConfigType]

func NewBuilder added in v0.109.0

func NewBuilder[ComponentConfigType any]() Builder[ComponentConfigType]

func NewProtocolBuilder added in v0.109.0

func NewProtocolBuilder(name string, port int32) Builder[*MultiProtocolEndpointConfig]

func NewSilentSinglePortParserBuilder added in v0.109.0

func NewSilentSinglePortParserBuilder(name string, port int32) Builder[*SingleEndpointConfig]

func NewSinglePortParserBuilder added in v0.109.0

func NewSinglePortParserBuilder(name string, port int32) Builder[*SingleEndpointConfig]

func (Builder[ComponentConfigType]) Build added in v0.109.0

func (b Builder[ComponentConfigType]) Build() (*GenericParser[ComponentConfigType], error)

func (Builder[ComponentConfigType]) MustBuild added in v0.109.0

func (b Builder[ComponentConfigType]) MustBuild() *GenericParser[ComponentConfigType]

func (Builder[ComponentConfigType]) WithAppProtocol added in v0.109.0

func (b Builder[ComponentConfigType]) WithAppProtocol(appProtocol *string) Builder[ComponentConfigType]

func (Builder[ComponentConfigType]) WithDefaultRecAddress added in v0.110.0

func (b Builder[ComponentConfigType]) WithDefaultRecAddress(defaultRecAddr string) Builder[ComponentConfigType]

func (Builder[ComponentConfigType]) WithDefaultsApplier added in v0.110.0

func (b Builder[ComponentConfigType]) WithDefaultsApplier(defaultsApplier Defaulter[ComponentConfigType]) Builder[ComponentConfigType]

func (Builder[ComponentConfigType]) WithEnvVarGen added in v0.113.0

func (b Builder[ComponentConfigType]) WithEnvVarGen(envVarGen EnvVarGenerator[ComponentConfigType]) Builder[ComponentConfigType]

func (Builder[ComponentConfigType]) WithLivenessGen added in v0.110.0

func (b Builder[ComponentConfigType]) WithLivenessGen(livenessGen ProbeGenerator[ComponentConfigType]) Builder[ComponentConfigType]

func (Builder[ComponentConfigType]) WithName added in v0.109.0

func (b Builder[ComponentConfigType]) WithName(name string) Builder[ComponentConfigType]

func (Builder[ComponentConfigType]) WithNodePort added in v0.109.0

func (b Builder[ComponentConfigType]) WithNodePort(nodePort int32) Builder[ComponentConfigType]

func (Builder[ComponentConfigType]) WithPort added in v0.109.0

func (b Builder[ComponentConfigType]) WithPort(port int32) Builder[ComponentConfigType]

func (Builder[ComponentConfigType]) WithPortParser added in v0.109.0

func (b Builder[ComponentConfigType]) WithPortParser(portParser PortParser[ComponentConfigType]) Builder[ComponentConfigType]

func (Builder[ComponentConfigType]) WithProtocol added in v0.109.0

func (b Builder[ComponentConfigType]) WithProtocol(protocol corev1.Protocol) Builder[ComponentConfigType]

func (Builder[ComponentConfigType]) WithRbacGen added in v0.109.0

func (b Builder[ComponentConfigType]) WithRbacGen(rbacGen RBACRuleGenerator[ComponentConfigType]) Builder[ComponentConfigType]

func (Builder[ComponentConfigType]) WithReadinessGen added in v0.110.0

func (b Builder[ComponentConfigType]) WithReadinessGen(readinessGen ProbeGenerator[ComponentConfigType]) Builder[ComponentConfigType]

func (Builder[ComponentConfigType]) WithStartupGen added in v0.137.0

func (b Builder[ComponentConfigType]) WithStartupGen(startupGen ProbeGenerator[ComponentConfigType]) Builder[ComponentConfigType]

func (Builder[ComponentConfigType]) WithTargetPort added in v0.109.0

func (b Builder[ComponentConfigType]) WithTargetPort(targetPort int32) Builder[ComponentConfigType]

type DefaultConfig added in v0.146.0

type DefaultConfig struct {
	// TLSProfile provides TLS settings to inject into components with tls: blocks.
	TLSProfile TLSProfile
}

DefaultConfig holds configuration options for applying defaults to components.

type DefaultOption added in v0.146.0

type DefaultOption func(*DefaultConfig)

DefaultOption is a functional option for configuring defaults behavior.

func WithTLSProfile added in v0.146.0

func WithTLSProfile(tls TLSProfile) DefaultOption

WithTLSProfile sets the TLS profile to use when applying defaults. When set, TLS settings (min_version, cipher_suites) are injected into components that have a tls: block with cert_file configured.

type Defaulter added in v0.110.0

type Defaulter[ComponentConfigType any] func(logger logr.Logger, defaultCfg *DefaultConfig, defaultAddr string, defaultPort int32, config ComponentConfigType) (map[string]any, error)

Defaulter is a function that applies given defaults to the passed Config. It's expected that type Config is the configuration used by a parser.

type EnvVarGenerator added in v0.113.0

type EnvVarGenerator[ComponentConfigType any] func(logger logr.Logger, config ComponentConfigType) ([]corev1.EnvVar, error)

EnvVarGenerator is a function that generates a list of environment variables for a given config. It's expected that type Config is the configuration used by a parser.

type GenericParser added in v0.108.0

type GenericParser[T any] struct {
	// contains filtered or unexported fields
}

GenericParser serves as scaffolding for custom parsing logic by isolating functionality to idempotent functions.

func (*GenericParser[T]) GetDefaultConfig added in v0.110.0

func (g *GenericParser[T]) GetDefaultConfig(logger logr.Logger, config any, opts ...DefaultOption) (any, error)

func (*GenericParser[T]) GetEnvironmentVariables added in v0.113.0

func (g *GenericParser[T]) GetEnvironmentVariables(logger logr.Logger, config any) ([]corev1.EnvVar, error)

func (*GenericParser[T]) GetLivenessProbe added in v0.110.0

func (g *GenericParser[T]) GetLivenessProbe(logger logr.Logger, config any) (*corev1.Probe, error)

func (*GenericParser[T]) GetRBACRules added in v0.109.0

func (g *GenericParser[T]) GetRBACRules(logger logr.Logger, config any) ([]rbacv1.PolicyRule, error)

func (*GenericParser[T]) GetReadinessProbe added in v0.110.0

func (g *GenericParser[T]) GetReadinessProbe(logger logr.Logger, config any) (*corev1.Probe, error)

func (*GenericParser[T]) GetStartupProbe added in v0.137.0

func (g *GenericParser[T]) GetStartupProbe(logger logr.Logger, config any) (*corev1.Probe, error)

func (*GenericParser[T]) ParserName added in v0.108.0

func (g *GenericParser[T]) ParserName() string

func (*GenericParser[T]) ParserType added in v0.108.0

func (g *GenericParser[T]) ParserType() string

func (*GenericParser[T]) Ports added in v0.108.0

func (g *GenericParser[T]) Ports(logger logr.Logger, name string, config any) ([]corev1.ServicePort, error)

type MultiPortBuilder added in v0.109.0

type MultiPortBuilder[ComponentConfigType any] []Builder[ComponentConfigType]

func NewMultiPortReceiverBuilder added in v0.109.0

func NewMultiPortReceiverBuilder(name string) MultiPortBuilder[*MultiProtocolEndpointConfig]

func (MultiPortBuilder[ComponentConfigType]) AddPortMapping added in v0.109.0

func (mp MultiPortBuilder[ComponentConfigType]) AddPortMapping(builder Builder[ComponentConfigType]) MultiPortBuilder[ComponentConfigType]

func (MultiPortBuilder[ComponentConfigType]) Build added in v0.109.0

func (mp MultiPortBuilder[ComponentConfigType]) Build() (*MultiPortReceiver, error)

func (MultiPortBuilder[ComponentConfigType]) MustBuild added in v0.109.0

func (mp MultiPortBuilder[ComponentConfigType]) MustBuild() *MultiPortReceiver

type MultiPortOption

type MultiPortOption func(parser *MultiPortReceiver)

MultiPortOption allows the setting of options for a MultiPortReceiver.

type MultiPortReceiver

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

MultiPortReceiver is a special parser for components with endpoints for each protocol.

func (*MultiPortReceiver) GetDefaultConfig added in v0.110.0

func (m *MultiPortReceiver) GetDefaultConfig(logger logr.Logger, config any, opts ...DefaultOption) (any, error)

func (*MultiPortReceiver) GetEnvironmentVariables added in v0.113.0

func (*MultiPortReceiver) GetEnvironmentVariables(logr.Logger, any) ([]corev1.EnvVar, error)

func (*MultiPortReceiver) GetLivenessProbe added in v0.110.0

func (*MultiPortReceiver) GetLivenessProbe(logr.Logger, any) (*corev1.Probe, error)

func (*MultiPortReceiver) GetRBACRules added in v0.109.0

func (*MultiPortReceiver) GetRBACRules(logr.Logger, any) ([]rbacv1.PolicyRule, error)

func (*MultiPortReceiver) GetReadinessProbe added in v0.110.0

func (*MultiPortReceiver) GetReadinessProbe(logr.Logger, any) (*corev1.Probe, error)

func (*MultiPortReceiver) GetStartupProbe added in v0.137.0

func (*MultiPortReceiver) GetStartupProbe(logr.Logger, any) (*corev1.Probe, error)

func (*MultiPortReceiver) ParserName

func (m *MultiPortReceiver) ParserName() string

func (*MultiPortReceiver) ParserType

func (m *MultiPortReceiver) ParserType() string

func (*MultiPortReceiver) Ports

func (m *MultiPortReceiver) Ports(logger logr.Logger, name string, config any) ([]corev1.ServicePort, error)

type MultiProtocolEndpointConfig

type MultiProtocolEndpointConfig struct {
	Protocols map[string]*SingleEndpointConfig `mapstructure:"protocols"`
}

MultiProtocolEndpointConfig represents the minimal struct for a given YAML configuration input containing a map to a struct with either endpoint or listen_address.

type Parser added in v0.108.0

type Parser interface {
	// GetDefaultConfig returns a config with set default values.
	// Optional DefaultOption arguments can customize behavior (e.g., WithTLSProfile for TLS defaults).
	// NOTE: Config merging must be done by the caller if desired.
	GetDefaultConfig(logger logr.Logger, config any, opts ...DefaultOption) (any, error)

	// Ports returns the service ports parsed based on the component's configuration where name is the component's name
	// of the form "name" or "type/name"
	Ports(logger logr.Logger, name string, config any) ([]corev1.ServicePort, error)

	// GetRBACRules returns the rbac rules for this component
	GetRBACRules(logger logr.Logger, config any) ([]rbacv1.PolicyRule, error)

	// GetLivenessProbe returns a liveness probe set for the collector
	GetLivenessProbe(logger logr.Logger, config any) (*corev1.Probe, error)

	// GetEnvironmentVariables returns a list of environment variables for the collector
	GetEnvironmentVariables(logger logr.Logger, config any) ([]corev1.EnvVar, error)

	// GetReadinessProbe returns a readiness probe set for the collector
	GetReadinessProbe(logger logr.Logger, config any) (*corev1.Probe, error)

	// GetStartupProbe returns a startup probe set for the collector
	GetStartupProbe(logger logr.Logger, config any) (*corev1.Probe, error)

	// ParserType returns the type of this parser
	ParserType() string

	// ParserName is an internal name for the parser
	ParserName() string
}

type ParserOption added in v0.109.0

type ParserOption[ComponentConfigType any] func(*Settings[ComponentConfigType])

type ParserRetriever added in v0.104.0

type ParserRetriever func(string) Parser

type PortParser added in v0.108.0

type PortParser[ComponentConfigType any] func(logger logr.Logger, name string, defaultPort *corev1.ServicePort, config ComponentConfigType) ([]corev1.ServicePort, error)

PortParser is a function that returns a list of servicePorts given a config of type Config.

type PortRetriever

type PortRetriever interface {
	GetPortNum() (int32, error)
	GetPortNumOrDefault(logr.Logger, int32) int32
}

type ProbeGenerator added in v0.110.0

type ProbeGenerator[ComponentConfigType any] func(logger logr.Logger, config ComponentConfigType) (*corev1.Probe, error)

ProbeGenerator is a function that generates a valid probe for a container given Config It's expected that type Config is the configuration used by a parser.

type RBACRuleGenerator added in v0.109.0

type RBACRuleGenerator[ComponentConfigType any] func(logger logr.Logger, config ComponentConfigType) ([]rbacv1.PolicyRule, error)

RBACRuleGenerator is a function that generates a list of RBAC Rules given a configuration of type Config It's expected that type Config is the configuration used by a parser.

type Settings added in v0.109.0

type Settings[ComponentConfigType any] struct {
	// contains filtered or unexported fields
}

func NewEmptySettings added in v0.109.0

func NewEmptySettings[ComponentConfigType any]() *Settings[ComponentConfigType]

func (*Settings[ComponentConfigType]) Apply added in v0.109.0

func (o *Settings[ComponentConfigType]) Apply(opts ...ParserOption[ComponentConfigType])

func (*Settings[ComponentConfigType]) GetServicePort added in v0.109.0

func (o *Settings[ComponentConfigType]) GetServicePort() *corev1.ServicePort

type SingleEndpointConfig

type SingleEndpointConfig struct {
	Endpoint      string     `mapstructure:"endpoint,omitempty" yaml:"endpoint,omitempty"`
	ListenAddress string     `mapstructure:"listen_address,omitempty" yaml:"listen_address,omitempty"`
	TLS           *TLSConfig `mapstructure:"tls,omitempty"`
}

SingleEndpointConfig represents the minimal struct for a given YAML configuration input containing either endpoint or listen_address.

func (*SingleEndpointConfig) GetPortNum

func (g *SingleEndpointConfig) GetPortNum() (int32, error)

GetPortNum attempts to get the port for the given config. If it cannot, the UnsetPort and the given missingPortError are returned.

func (*SingleEndpointConfig) GetPortNumOrDefault

func (g *SingleEndpointConfig) GetPortNumOrDefault(logger logr.Logger, p int32) int32

type StaticTLSProfile added in v0.146.0

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

func NewStaticTLSProfile added in v0.146.0

func NewStaticTLSProfile(minVersion uint16, ciphers []uint16) StaticTLSProfile

func (StaticTLSProfile) CipherSuiteNames added in v0.146.0

func (p StaticTLSProfile) CipherSuiteNames() []string

func (StaticTLSProfile) CipherSuites added in v0.146.0

func (p StaticTLSProfile) CipherSuites() []uint16

func (StaticTLSProfile) MinTLSVersion added in v0.146.0

func (p StaticTLSProfile) MinTLSVersion() uint16

func (StaticTLSProfile) MinTLSVersionGolang added in v0.146.0

func (p StaticTLSProfile) MinTLSVersionGolang() string

func (StaticTLSProfile) MinTLSVersionOTEL added in v0.146.0

func (p StaticTLSProfile) MinTLSVersionOTEL() string

type StaticTLSProfileProvider added in v0.146.0

type StaticTLSProfileProvider struct {
	Profile TLSProfile
}

func (StaticTLSProfileProvider) GetTLSProfile added in v0.146.0

type TLSConfig added in v0.146.0

type TLSConfig struct {
	Ciphers    []string `mapstructure:"cipher_suites,omitempty"`
	MinVersion string   `mapstructure:"min_version,omitempty"`
}

type TLSProfile added in v0.146.0

type TLSProfile interface {
	// MinTLSVersionOTEL returns the minimum TLS version in OpenTelemetry collector format (e.g., "1.2").
	MinTLSVersionOTEL() string
	// MinTLSVersion returns the minimum TLS version as a Go crypto/tls constant.
	MinTLSVersion() uint16
	// CipherSuites returns the cipher suites as Go crypto/tls constants.
	// For TLS 1.3, this returns nil as cipher suites are not configurable.
	CipherSuites() []uint16
	// CipherSuiteNames returns the cipher suite names in Go/IANA format.
	// For TLS 1.3, this returns nil as cipher suites are not configurable.
	CipherSuiteNames() []string
}

TLSProfile holds the TLS configuration to inject into collector components. These settings are derived from the cluster's TLS security profile.

type TLSProfileProvider added in v0.146.0

type TLSProfileProvider interface {
	// GetTLSProfile fetches the TLS profile from the cluster.
	// This is a blocking call that fetches the current TLS security profile.
	// Returns nil profile if TLS profile is not configured or not available.
	GetTLSProfile(ctx context.Context) (TLSProfile, error)
}

TLSProfileProvider provides TLS settings for component configuration. This interface is implemented by TLSObserver to provide cluster-wide TLS settings.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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