Documentation
¶
Overview ¶
Package route provides shared utilities for building cloudflared ingress rules from various Kubernetes resources (Ingress, Gateway API routes, TunnelBinding).
Index ¶
- Constants
- func BuildServiceURL(protocol, serviceName, namespace, port string) string
- func BuildServiceURLFromPort(protocol, serviceName, namespace string, port int32) string
- func ConvertGatewayPathType(path string, pathType *gatewayv1.PathMatchType) string
- func ConvertIngressPathType(path string, pathType *networkingv1.PathType) string
- func InferProtocolFromPort(port string) string
- func InferProtocolFromPortNumber(port int32) string
- func ProtocolFromGatewayProtocol(protocol gatewayv1.ProtocolType) string
- type Aggregator
- type Builder
- type OriginRequestBuilder
- func (b *OriginRequestBuilder) Build() cf.OriginRequestConfig
- func (b *OriginRequestBuilder) SetBastionMode(v *bool) *OriginRequestBuilder
- func (b *OriginRequestBuilder) SetCAPool(caPool string) *OriginRequestBuilder
- func (b *OriginRequestBuilder) SetConnectTimeout(d *time.Duration) *OriginRequestBuilder
- func (b *OriginRequestBuilder) SetDisableChunkedEncoding(v *bool) *OriginRequestBuilder
- func (b *OriginRequestBuilder) SetHTTP2Origin(v *bool) *OriginRequestBuilder
- func (b *OriginRequestBuilder) SetHTTPHostHeader(v string) *OriginRequestBuilder
- func (b *OriginRequestBuilder) SetKeepAliveConnections(n *int) *OriginRequestBuilder
- func (b *OriginRequestBuilder) SetKeepAliveTimeout(d *time.Duration) *OriginRequestBuilder
- func (b *OriginRequestBuilder) SetNoTLSVerify(v *bool) *OriginRequestBuilder
- func (b *OriginRequestBuilder) SetOriginServerName(v string) *OriginRequestBuilder
- func (b *OriginRequestBuilder) SetProxyAddress(v string) *OriginRequestBuilder
- func (b *OriginRequestBuilder) SetProxyPort(port uint) *OriginRequestBuilder
- func (b *OriginRequestBuilder) SetProxyType(v string) *OriginRequestBuilder
- func (b *OriginRequestBuilder) SetTLSTimeout(d *time.Duration) *OriginRequestBuilder
- func (b *OriginRequestBuilder) WithDefaults(defaults *networkingv1alpha2.OriginRequestSpec) *OriginRequestBuilder
Constants ¶
const ( ProtocolHTTP = "http" ProtocolHTTPS = "https" ProtocolTCP = "tcp" ProtocolUDP = "udp" ProtocolSSH = "ssh" ProtocolRDP = "rdp" ProtocolSMB = "smb" )
Protocol constants
Variables ¶
This section is empty.
Functions ¶
func BuildServiceURL ¶
BuildServiceURL constructs a service URL for cloudflared ingress rules. Parameters:
- protocol: the protocol (http, https, tcp, udp, ssh, rdp, smb)
- serviceName: the Kubernetes service name
- namespace: the Kubernetes namespace
- port: the port number as string
func BuildServiceURLFromPort ¶
BuildServiceURLFromPort constructs a service URL using a numeric port.
func ConvertGatewayPathType ¶
func ConvertGatewayPathType(path string, pathType *gatewayv1.PathMatchType) string
ConvertGatewayPathType converts Gateway API PathMatchType to cloudflared path regex. This supports the Gateway API's path matching semantics.
func ConvertIngressPathType ¶
func ConvertIngressPathType(path string, pathType *networkingv1.PathType) string
ConvertIngressPathType converts Kubernetes Ingress PathType to cloudflared path regex. Cloudflared uses regex for path matching, so we need to convert the Kubernetes path types. nolint:revive // Cognitive complexity for path conversion logic
func InferProtocolFromPort ¶
InferProtocolFromPort determines the protocol based on port number. This is used when no explicit protocol annotation is provided.
func InferProtocolFromPortNumber ¶
InferProtocolFromPortNumber determines the protocol based on numeric port.
func ProtocolFromGatewayProtocol ¶
func ProtocolFromGatewayProtocol(protocol gatewayv1.ProtocolType) string
ProtocolFromGatewayProtocol converts Gateway API ProtocolType to cloudflared protocol.
Types ¶
type Aggregator ¶
type Aggregator struct {
// Builders are the rule builders to aggregate
Builders []Builder
// FallbackTarget is the target for the catch-all fallback rule
// Default is "http_status:404"
FallbackTarget string
}
Aggregator aggregates rules from multiple builders and adds a fallback rule.
func NewAggregator ¶
func NewAggregator(fallbackTarget string) *Aggregator
NewAggregator creates a new rule aggregator with the given fallback target.
func (*Aggregator) AddAll ¶
func (a *Aggregator) AddAll(builders ...Builder)
AddAll adds multiple builders to the aggregator.
func (*Aggregator) Build ¶
func (a *Aggregator) Build(ctx context.Context) ([]cf.UnvalidatedIngressRule, error)
Build aggregates rules from all builders, sorts them, and adds a fallback rule. Rules are sorted by hostname, then by path for deterministic configuration.
func (*Aggregator) BuildWithoutFallback ¶
func (a *Aggregator) BuildWithoutFallback(ctx context.Context) ([]cf.UnvalidatedIngressRule, error)
BuildWithoutFallback aggregates rules from all builders without adding a fallback rule. This is useful when the caller wants to add a custom fallback or combine with other rules.
type Builder ¶
type Builder interface {
// Build generates cloudflared ingress rules from the resource.
// Returns a slice of rules (can be empty if resource has no routes).
Build(ctx context.Context) ([]cf.UnvalidatedIngressRule, error)
}
Builder is an interface for building cloudflared ingress rules. Different resource types (Ingress, HTTPRoute, TCPRoute, TunnelBinding) implement this interface to convert their rules to cloudflared format.
type OriginRequestBuilder ¶
type OriginRequestBuilder struct {
// contains filtered or unexported fields
}
OriginRequestBuilder helps build OriginRequestConfig from various sources.
func NewOriginRequestBuilder ¶
func NewOriginRequestBuilder() *OriginRequestBuilder
NewOriginRequestBuilder creates a new OriginRequestBuilder.
func (*OriginRequestBuilder) Build ¶
func (b *OriginRequestBuilder) Build() cf.OriginRequestConfig
Build returns the constructed OriginRequestConfig.
func (*OriginRequestBuilder) SetBastionMode ¶
func (b *OriginRequestBuilder) SetBastionMode(v *bool) *OriginRequestBuilder
SetBastionMode sets the BastionMode option.
func (*OriginRequestBuilder) SetCAPool ¶
func (b *OriginRequestBuilder) SetCAPool(caPool string) *OriginRequestBuilder
SetCAPool sets the CAPool option (converts to path).
func (*OriginRequestBuilder) SetConnectTimeout ¶
func (b *OriginRequestBuilder) SetConnectTimeout(d *time.Duration) *OriginRequestBuilder
SetConnectTimeout sets the ConnectTimeout option.
func (*OriginRequestBuilder) SetDisableChunkedEncoding ¶
func (b *OriginRequestBuilder) SetDisableChunkedEncoding(v *bool) *OriginRequestBuilder
SetDisableChunkedEncoding sets the DisableChunkedEncoding option.
func (*OriginRequestBuilder) SetHTTP2Origin ¶
func (b *OriginRequestBuilder) SetHTTP2Origin(v *bool) *OriginRequestBuilder
SetHTTP2Origin sets the HTTP2Origin option.
func (*OriginRequestBuilder) SetHTTPHostHeader ¶
func (b *OriginRequestBuilder) SetHTTPHostHeader(v string) *OriginRequestBuilder
SetHTTPHostHeader sets the HTTPHostHeader option.
func (*OriginRequestBuilder) SetKeepAliveConnections ¶
func (b *OriginRequestBuilder) SetKeepAliveConnections(n *int) *OriginRequestBuilder
SetKeepAliveConnections sets the KeepAliveConnections option.
func (*OriginRequestBuilder) SetKeepAliveTimeout ¶
func (b *OriginRequestBuilder) SetKeepAliveTimeout(d *time.Duration) *OriginRequestBuilder
SetKeepAliveTimeout sets the KeepAliveTimeout option.
func (*OriginRequestBuilder) SetNoTLSVerify ¶
func (b *OriginRequestBuilder) SetNoTLSVerify(v *bool) *OriginRequestBuilder
SetNoTLSVerify sets the NoTLSVerify option.
func (*OriginRequestBuilder) SetOriginServerName ¶
func (b *OriginRequestBuilder) SetOriginServerName(v string) *OriginRequestBuilder
SetOriginServerName sets the OriginServerName option.
func (*OriginRequestBuilder) SetProxyAddress ¶
func (b *OriginRequestBuilder) SetProxyAddress(v string) *OriginRequestBuilder
SetProxyAddress sets the ProxyAddress option.
func (*OriginRequestBuilder) SetProxyPort ¶
func (b *OriginRequestBuilder) SetProxyPort(port uint) *OriginRequestBuilder
SetProxyPort sets the ProxyPort option.
func (*OriginRequestBuilder) SetProxyType ¶
func (b *OriginRequestBuilder) SetProxyType(v string) *OriginRequestBuilder
SetProxyType sets the ProxyType option.
func (*OriginRequestBuilder) SetTLSTimeout ¶
func (b *OriginRequestBuilder) SetTLSTimeout(d *time.Duration) *OriginRequestBuilder
SetTLSTimeout sets the TLSTimeout option.
func (*OriginRequestBuilder) WithDefaults ¶
func (b *OriginRequestBuilder) WithDefaults(defaults *networkingv1alpha2.OriginRequestSpec) *OriginRequestBuilder
WithDefaults applies defaults from OriginRequestSpec. nolint:revive // Cognitive complexity is expected for mapping all fields