Documentation ¶
Index ¶
- Variables
- func AddressDefaulter(logger logr.Logger, defaultRecAddr string, port int32, ...) (map[string]interface{}, error)
- func ComponentType(name string) string
- func ConstructServicePort(current *corev1.ServicePort, port int32) corev1.ServicePort
- func GetPortsForConfig(logger logr.Logger, config map[string]interface{}, retriever ParserRetriever) ([]corev1.ServicePort, error)
- func ParseSingleEndpoint(logger logr.Logger, name string, defaultPort *corev1.ServicePort, ...) ([]corev1.ServicePort, error)
- func ParseSingleEndpointSilent(logger logr.Logger, name string, defaultPort *corev1.ServicePort, ...) ([]corev1.ServicePort, error)
- func PortFromEndpoint(endpoint string) (int32, error)
- type Builder
- func NewBuilder[ComponentConfigType any]() Builder[ComponentConfigType]
- func NewProtocolBuilder(name string, port int32) Builder[*MultiProtocolEndpointConfig]
- func NewSilentSinglePortParserBuilder(name string, port int32) Builder[*SingleEndpointConfig]
- func NewSinglePortParserBuilder(name string, port int32) Builder[*SingleEndpointConfig]
- func (b Builder[ComponentConfigType]) Build() (*GenericParser[ComponentConfigType], error)
- func (b Builder[ComponentConfigType]) MustBuild() *GenericParser[ComponentConfigType]
- func (b Builder[ComponentConfigType]) WithAppProtocol(appProtocol *string) Builder[ComponentConfigType]
- func (b Builder[ComponentConfigType]) WithDefaultRecAddress(defaultRecAddr string) Builder[ComponentConfigType]
- func (b Builder[ComponentConfigType]) WithDefaultsApplier(defaultsApplier Defaulter[ComponentConfigType]) Builder[ComponentConfigType]
- func (b Builder[ComponentConfigType]) WithEnvVarGen(envVarGen EnvVarGenerator[ComponentConfigType]) Builder[ComponentConfigType]
- func (b Builder[ComponentConfigType]) WithLivenessGen(livenessGen ProbeGenerator[ComponentConfigType]) Builder[ComponentConfigType]
- func (b Builder[ComponentConfigType]) WithName(name string) Builder[ComponentConfigType]
- func (b Builder[ComponentConfigType]) WithNodePort(nodePort int32) Builder[ComponentConfigType]
- func (b Builder[ComponentConfigType]) WithPort(port int32) Builder[ComponentConfigType]
- func (b Builder[ComponentConfigType]) WithPortParser(portParser PortParser[ComponentConfigType]) Builder[ComponentConfigType]
- func (b Builder[ComponentConfigType]) WithProtocol(protocol corev1.Protocol) Builder[ComponentConfigType]
- func (b Builder[ComponentConfigType]) WithRbacGen(rbacGen RBACRuleGenerator[ComponentConfigType]) Builder[ComponentConfigType]
- func (b Builder[ComponentConfigType]) WithReadinessGen(readinessGen ProbeGenerator[ComponentConfigType]) Builder[ComponentConfigType]
- func (b Builder[ComponentConfigType]) WithTargetPort(targetPort int32) Builder[ComponentConfigType]
- type Defaulter
- type EnvVarGenerator
- type GenericParser
- func (g *GenericParser[T]) GetDefaultConfig(logger logr.Logger, config interface{}) (interface{}, error)
- func (g *GenericParser[T]) GetEnvironmentVariables(logger logr.Logger, config interface{}) ([]corev1.EnvVar, error)
- func (g *GenericParser[T]) GetLivenessProbe(logger logr.Logger, config interface{}) (*corev1.Probe, error)
- func (g *GenericParser[T]) GetRBACRules(logger logr.Logger, config interface{}) ([]rbacv1.PolicyRule, error)
- func (g *GenericParser[T]) GetReadinessProbe(logger logr.Logger, config interface{}) (*corev1.Probe, error)
- func (g *GenericParser[T]) ParserName() string
- func (g *GenericParser[T]) ParserType() string
- func (g *GenericParser[T]) Ports(logger logr.Logger, name string, config interface{}) ([]corev1.ServicePort, error)
- type MultiPortBuilder
- func (mp MultiPortBuilder[ComponentConfigType]) AddPortMapping(builder Builder[ComponentConfigType]) MultiPortBuilder[ComponentConfigType]
- func (mp MultiPortBuilder[ComponentConfigType]) Build() (*MultiPortReceiver, error)
- func (mp MultiPortBuilder[ComponentConfigType]) MustBuild() *MultiPortReceiver
- type MultiPortOption
- type MultiPortReceiver
- func (m *MultiPortReceiver) GetDefaultConfig(logger logr.Logger, config interface{}) (interface{}, error)
- func (m *MultiPortReceiver) GetEnvironmentVariables(logger logr.Logger, config interface{}) ([]corev1.EnvVar, error)
- func (m *MultiPortReceiver) GetLivenessProbe(logger logr.Logger, config interface{}) (*corev1.Probe, error)
- func (m *MultiPortReceiver) GetRBACRules(logr.Logger, interface{}) ([]rbacv1.PolicyRule, error)
- func (m *MultiPortReceiver) GetReadinessProbe(logger logr.Logger, config interface{}) (*corev1.Probe, error)
- func (m *MultiPortReceiver) ParserName() string
- func (m *MultiPortReceiver) ParserType() string
- func (m *MultiPortReceiver) Ports(logger logr.Logger, name string, config interface{}) ([]corev1.ServicePort, error)
- type MultiProtocolEndpointConfig
- type Parser
- type ParserOption
- type ParserRetriever
- type PortParser
- type PortRetriever
- type ProbeGenerator
- type RBACRuleGenerator
- type Settings
- type SingleEndpointConfig
Constants ¶
This section is empty.
Variables ¶
var ( GrpcProtocol = "grpc" HttpProtocol = "http" UnsetPort int32 = 0 PortNotFoundErr = errors.New("port should not be empty") )
Functions ¶
func AddressDefaulter ¶ added in v0.110.0
func ComponentType ¶
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 GetPortsForConfig ¶ added in v0.104.0
func GetPortsForConfig(logger logr.Logger, config map[string]interface{}, retriever ParserRetriever) ([]corev1.ServicePort, error)
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 ¶
Types ¶
type Builder ¶ added in v0.109.0
type Builder[ComponentConfigType any] []ParserOption[ComponentConfigType]
func NewBuilder ¶ added in v0.109.0
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 (Builder[ComponentConfigType]) WithDefaultRecAddress ¶ added in v0.110.0
func (Builder[ComponentConfigType]) WithDefaultsApplier ¶ added in v0.110.0
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]) WithNodePort ¶ added in v0.109.0
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 (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]) WithTargetPort ¶ added in v0.109.0
type Defaulter ¶ added in v0.110.0
type Defaulter[ComponentConfigType any] func(logger logr.Logger, defaultAddr string, defaultPort int32, config ComponentConfigType) (map[string]interface{}, 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 interface{}) (interface{}, error)
func (*GenericParser[T]) GetEnvironmentVariables ¶ added in v0.113.0
func (*GenericParser[T]) GetLivenessProbe ¶ added in v0.110.0
func (*GenericParser[T]) GetRBACRules ¶ added in v0.109.0
func (g *GenericParser[T]) GetRBACRules(logger logr.Logger, config interface{}) ([]rbacv1.PolicyRule, error)
func (*GenericParser[T]) GetReadinessProbe ¶ added in v0.110.0
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 interface{}) ([]corev1.ServicePort, error)
type MultiPortBuilder ¶ added in v0.109.0
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 interface{}) (interface{}, error)
func (*MultiPortReceiver) GetEnvironmentVariables ¶ added in v0.113.0
func (*MultiPortReceiver) GetLivenessProbe ¶ added in v0.110.0
func (*MultiPortReceiver) GetRBACRules ¶ added in v0.109.0
func (m *MultiPortReceiver) GetRBACRules(logr.Logger, interface{}) ([]rbacv1.PolicyRule, error)
func (*MultiPortReceiver) GetReadinessProbe ¶ added in v0.110.0
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 interface{}) ([]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. // NOTE: Config merging must be done by the caller if desired. GetDefaultConfig(logger logr.Logger, config interface{}) (interface{}, 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 interface{}) ([]corev1.ServicePort, error) // GetRBACRules returns the rbac rules for this component GetRBACRules(logger logr.Logger, config interface{}) ([]rbacv1.PolicyRule, error) // GetLivenessProbe returns a liveness probe set for the collector GetLivenessProbe(logger logr.Logger, config interface{}) (*corev1.Probe, error) // GetEnvironmentVariables returns a list of environment variables for the collector GetEnvironmentVariables(logger logr.Logger, config interface{}) ([]corev1.EnvVar, error) // GetReadinessProbe returns a readiness probe set for the collector GetReadinessProbe(logger logr.Logger, config interface{}) (*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 ParserRetriever ¶ added in v0.104.0
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 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 (*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"` }
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