Documentation
¶
Overview ¶
Package resolver provides hostname to CloudflareDomain resolution using longest suffix match.
Index ¶
- type DomainInfo
- type DomainResolver
- func (r *DomainResolver) GetDefaultDomain(ctx context.Context) (*DomainInfo, error)
- func (r *DomainResolver) GetZoneID(ctx context.Context, hostname string) (string, error)
- func (r *DomainResolver) InvalidateCache()
- func (r *DomainResolver) ListDomains(ctx context.Context) ([]networkingv1alpha2.CloudflareDomain, error)
- func (r *DomainResolver) MustResolve(ctx context.Context, hostname string) (*DomainInfo, error)
- func (r *DomainResolver) Resolve(ctx context.Context, hostname string) (*DomainInfo, error)
- func (r *DomainResolver) ResolveMultiple(ctx context.Context, hostnames []string) (map[string]*DomainInfo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DomainInfo ¶
type DomainInfo struct {
// Domain is the domain name
Domain string
// ZoneID is the Cloudflare Zone ID
ZoneID string
// AccountID is the Cloudflare Account ID
AccountID string
// CredentialsRef is the reference to CloudflareCredentials (optional)
CredentialsRef *networkingv1alpha2.CredentialsReference
// CloudflareDomainName is the name of the CloudflareDomain resource
CloudflareDomainName string
}
DomainInfo contains resolved domain information for DNS operations
type DomainResolver ¶
type DomainResolver struct {
// contains filtered or unexported fields
}
DomainResolver resolves hostnames to CloudflareDomain resources using longest suffix match. It provides Zone ID lookup for DNS operations across all controllers.
func NewDomainResolver ¶
func NewDomainResolver(client client.Client, log logr.Logger) *DomainResolver
NewDomainResolver creates a new DomainResolver
func (*DomainResolver) GetDefaultDomain ¶
func (r *DomainResolver) GetDefaultDomain(ctx context.Context) (*DomainInfo, error)
GetDefaultDomain returns the default CloudflareDomain if one exists
func (*DomainResolver) GetZoneID ¶
GetZoneID is a convenience method to get just the Zone ID for a hostname. Returns empty string if no matching domain is found.
func (*DomainResolver) InvalidateCache ¶
func (r *DomainResolver) InvalidateCache()
InvalidateCache invalidates the domain cache, forcing a refresh on next Resolve call
func (*DomainResolver) ListDomains ¶
func (r *DomainResolver) ListDomains(ctx context.Context) ([]networkingv1alpha2.CloudflareDomain, error)
ListDomains returns all CloudflareDomain resources (refreshes cache if needed)
func (*DomainResolver) MustResolve ¶
func (r *DomainResolver) MustResolve(ctx context.Context, hostname string) (*DomainInfo, error)
MustResolve resolves a hostname and returns an error if no matching domain is found.
func (*DomainResolver) Resolve ¶
func (r *DomainResolver) Resolve(ctx context.Context, hostname string) (*DomainInfo, error)
Resolve finds the best matching CloudflareDomain for a hostname. It uses longest suffix match: for "api.staging.example.com": - "example.com" matches (suffix) - "staging.example.com" matches better (longer suffix)
Returns nil if no matching domain is found.
func (*DomainResolver) ResolveMultiple ¶
func (r *DomainResolver) ResolveMultiple(ctx context.Context, hostnames []string) (map[string]*DomainInfo, error)
ResolveMultiple resolves multiple hostnames and returns a map of hostname to DomainInfo. This is useful for batch operations like Ingress reconciliation.