components

package
v0.108.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

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 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, o *Option, singleEndpointConfig *SingleEndpointConfig) ([]corev1.ServicePort, error)

func ParseSingleEndpointSilent added in v0.108.0

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

func PortFromEndpoint

func PortFromEndpoint(endpoint string) (int32, error)

Types

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 NewGenericParser added in v0.108.0

func NewGenericParser[T any](name string, port int32, parser PortParser[T], opts ...PortBuilderOption) *GenericParser[T]

func NewSilentSinglePortParser added in v0.104.0

func NewSilentSinglePortParser(name string, port int32, opts ...PortBuilderOption) *GenericParser[*SingleEndpointConfig]

NewSilentSinglePortParser returns a ParseSingleEndpoint that errors silently on failure to find a port.

func NewSinglePortParser

func NewSinglePortParser(name string, port int32, opts ...PortBuilderOption) *GenericParser[*SingleEndpointConfig]

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 MultiPortOption

type MultiPortOption func(parser *MultiPortReceiver)

MultiPortOption allows the setting of options for a MultiPortReceiver.

func WithPortMapping

func WithPortMapping(name string, port int32, opts ...PortBuilderOption) MultiPortOption

type MultiPortReceiver

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

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

func NewMultiPortReceiver

func NewMultiPortReceiver(name string, opts ...MultiPortOption) *MultiPortReceiver

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 Option added in v0.108.0

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

func NewOption added in v0.108.0

func NewOption(name string, port int32) *Option

func (*Option) Apply added in v0.108.0

func (o *Option) Apply(opts ...PortBuilderOption)

func (*Option) GetServicePort added in v0.108.0

func (o *Option) GetServicePort() *corev1.ServicePort

type Parser added in v0.108.0

type Parser interface {
	// 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)

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

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

type ParserRetriever added in v0.104.0

type ParserRetriever func(string) Parser

type PortBuilderOption

type PortBuilderOption func(*Option)

func WithAppProtocol

func WithAppProtocol(proto *string) PortBuilderOption

func WithProtocol

func WithProtocol(proto corev1.Protocol) PortBuilderOption

func WithTargetPort

func WithTargetPort(targetPort int32) PortBuilderOption

type PortParser added in v0.108.0

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

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

type PortRetriever

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

type SingleEndpointConfig

type SingleEndpointConfig struct {
	Endpoint      string `mapstructure:"endpoint,omitempty"`
	ListenAddress string `mapstructure:"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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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