Documentation
¶
Overview ¶
Package tunnel provides the TunnelConfigSyncController and aggregation logic for Cloudflare Tunnel configuration management.
Index ¶
- 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 SyncToCloudflareResult
Constants ¶
This section is empty.
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. Debounce rapid changes 3. Aggregate configuration from all sources 4. Compute hash for change detection 5. If changed, sync to Cloudflare API 6. Update SyncState status
func (*Controller) SetupWithManager ¶
func (r *Controller) 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