components

package
v0.104.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 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 PortFromEndpoint

func PortFromEndpoint(endpoint string) (int32, error)

Types

type ComponentPortParser

type ComponentPortParser 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 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 NopParser added in v0.104.0

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

SingleEndpointParser is a special parser for a generic receiver that has an endpoint or listen_address in its configuration. It doesn't self-register and should be created/used directly.

func NewNopParser added in v0.104.0

func NewNopParser(name string, port int32, opts ...PortBuilderOption) *NopParser

func (*NopParser) ParserName added in v0.104.0

func (n *NopParser) ParserName() string

func (*NopParser) ParserType added in v0.104.0

func (n *NopParser) ParserType() string

func (*NopParser) Ports added in v0.104.0

func (n *NopParser) Ports(logger logr.Logger, name string, config interface{}) ([]corev1.ServicePort, error)

type ParserRetriever added in v0.104.0

type ParserRetriever func(string) ComponentPortParser

type PortBuilderOption

type PortBuilderOption func(*corev1.ServicePort)

func WithAppProtocol

func WithAppProtocol(proto *string) PortBuilderOption

func WithProtocol

func WithProtocol(proto corev1.Protocol) PortBuilderOption

func WithTargetPort

func WithTargetPort(targetPort int32) PortBuilderOption

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

type SingleEndpointParser

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

SingleEndpointParser is a special parser for a generic receiver that has an endpoint or listen_address in its configuration. It doesn't self-register and should be created/used directly.

func NewSilentSinglePortParser added in v0.104.0

func NewSilentSinglePortParser(name string, port int32, opts ...PortBuilderOption) *SingleEndpointParser

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

func NewSinglePortParser

func NewSinglePortParser(name string, port int32, opts ...PortBuilderOption) *SingleEndpointParser

func (*SingleEndpointParser) ParserName

func (s *SingleEndpointParser) ParserName() string

func (*SingleEndpointParser) ParserType

func (s *SingleEndpointParser) ParserType() string

func (*SingleEndpointParser) Ports

func (s *SingleEndpointParser) Ports(logger logr.Logger, name string, config interface{}) ([]corev1.ServicePort, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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