Documentation
¶
Overview ¶
Package tunnel provides the TunnelConfigSyncController and aggregation logic for Cloudflare Tunnel configuration management.
Index ¶
- Constants
- func ExtractHostnames(config *AggregatedConfig) []string
- func GetRuleCount(syncState *v1alpha2.CloudflareSyncState) int
- func GetSourceCount(syncState *v1alpha2.CloudflareSyncState) int
- func ValidateAggregatedConfig(config *AggregatedConfig) error
- type AggregatedConfig
- type Controller
- type LifecycleController
- type SyncToCloudflareResult
Constants ¶
const (
// FinalizerName is the finalizer for Tunnel Configuration SyncState resources.
FinalizerName = "tunnelconfig.sync.cloudflare-operator.io/finalizer"
)
const (
// TunnelLifecycleFinalizerName is the finalizer for TunnelLifecycle SyncState resources.
TunnelLifecycleFinalizerName = "tunnellifecycle.sync.cloudflare-operator.io/finalizer"
)
Variables ¶
This section is empty.
Functions ¶
func ExtractHostnames ¶
func ExtractHostnames(config *AggregatedConfig) []string
ExtractHostnames extracts all unique hostnames from the aggregated config. This is useful for DNS record management and status reporting.
func GetRuleCount ¶
func GetRuleCount(syncState *v1alpha2.CloudflareSyncState) int
GetRuleCount returns the total number of rules across all sources.
func GetSourceCount ¶
func GetSourceCount(syncState *v1alpha2.CloudflareSyncState) int
GetSourceCount returns the number of sources in the SyncState.
func ValidateAggregatedConfig ¶
func ValidateAggregatedConfig(config *AggregatedConfig) error
ValidateAggregatedConfig validates the aggregated configuration. Returns an error if the configuration is invalid.
Types ¶
type AggregatedConfig ¶
type AggregatedConfig struct {
// WarpRouting controls WARP routing (from highest priority source)
WarpRouting *tunnelsvc.WarpRoutingConfig `json:"warp-routing,omitempty"`
// Ingress contains all merged ingress rules (sorted by specificity)
Ingress []tunnelsvc.IngressRule `json:"ingress"`
// OriginRequest contains global origin request settings
OriginRequest *tunnelsvc.OriginRequestConfig `json:"originRequest,omitempty"`
}
AggregatedConfig represents the final merged Tunnel configuration. This is the format that will be sent to the Cloudflare API.
func Aggregate ¶
func Aggregate(syncState *v1alpha2.CloudflareSyncState) (*AggregatedConfig, error)
Aggregate merges all sources in a SyncState into a single AggregatedConfig. The algorithm: 1. Sort sources by priority (lower number = higher priority) 2. Apply settings from highest priority source 3. Collect all rules from all sources 4. Sort rules by specificity (more specific paths first) 5. Add catch-all rule at the end
type Controller ¶
type Controller struct {
*common.BaseSyncController
}
Controller is the Sync Controller for Tunnel Configuration. It watches CloudflareSyncState resources of type TunnelConfiguration, aggregates configuration from multiple sources, and syncs to Cloudflare API.
func NewController ¶
func NewController(c client.Client) *Controller
NewController creates a new TunnelConfigSyncController
func (*Controller) Reconcile ¶
Reconcile processes a CloudflareSyncState resource for tunnel configuration. The reconciliation flow: 1. Get the SyncState resource 2. Handle deletion (clear config on Cloudflare) 3. Handle empty sources (clear ingress rules) 4. Debounce rapid changes 5. Aggregate configuration from all sources 6. Compute hash for change detection 7. If changed, sync to Cloudflare API 8. Update SyncState status
func (*Controller) SetupWithManager ¶
func (r *Controller) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type LifecycleController ¶ added in v0.24.0
type LifecycleController struct {
*common.BaseSyncController
}
LifecycleController is the Sync Controller for Tunnel Lifecycle operations. It watches CloudflareSyncState resources of type TunnelLifecycle and performs the actual Cloudflare API calls for tunnel creation, deletion, and adoption.
func NewLifecycleController ¶ added in v0.24.0
func NewLifecycleController(c client.Client) *LifecycleController
NewLifecycleController creates a new TunnelLifecycleSyncController
func (*LifecycleController) Reconcile ¶ added in v0.24.0
Reconcile processes a CloudflareSyncState resource for tunnel lifecycle operations.
func (*LifecycleController) SetupWithManager ¶ added in v0.24.0
func (r *LifecycleController) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type SyncToCloudflareResult ¶
type SyncToCloudflareResult struct {
// Version is the configuration version returned by Cloudflare
Version int
}
SyncToCloudflareResult contains the result of syncing to Cloudflare API