domain

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package domain provides services for managing Cloudflare Domain configurations.

Index

Constants

View Source
const (
	// ResourceTypeCloudflareDomain is the SyncState resource type for CloudflareDomain
	ResourceTypeCloudflareDomain = v1alpha2.SyncResourceCloudflareDomain
	// ResourceTypeOriginCACertificate is the SyncState resource type for OriginCACertificate
	ResourceTypeOriginCACertificate = v1alpha2.SyncResourceOriginCACertificate
	// ResourceTypeDomainRegistration is the SyncState resource type for DomainRegistration
	ResourceTypeDomainRegistration = v1alpha2.SyncResourceDomainRegistration

	// Priority constants
	PriorityCloudflareDomain    = 100
	PriorityOriginCACertificate = 100
	PriorityDomainRegistration  = 100
)

Resource Types for SyncState

View Source
const (
	ResultKeyOriginCACertificateID = "certificateId"
	ResultKeyOriginCACertificate   = "certificate"
	ResultKeyOriginCAExpiresAt     = "expiresAt"
	ResultKeyOriginCARequestType   = "requestType"
	ResultKeyOriginCAHostnames     = "hostnames"
)

Result data keys for OriginCACertificate SyncState.

View Source
const (
	ResultKeyDomainID         = "domainId"
	ResultKeyCurrentRegistrar = "currentRegistrar"
	ResultKeyRegistryStatuses = "registryStatuses"
	ResultKeyDomainLocked     = "locked"
	ResultKeyTransferInStatus = "transferInStatus"
	ResultKeyDomainExpiresAt  = "expiresAt"
	ResultKeyDomainCreatedAt  = "createdAt"
	ResultKeyDomainAutoRenew  = "autoRenew"
	ResultKeyDomainPrivacy    = "privacy"
)

Result data keys for DomainRegistration SyncState.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticatedOriginPullConfig added in v0.25.0

type AuthenticatedOriginPullConfig struct {
	// Enabled enables authenticated origin pulls (mTLS)
	Enabled bool `json:"enabled,omitempty"`
}

AuthenticatedOriginPullConfig configures client certificate authentication.

type CacheConfig

type CacheConfig struct {
	// Level is the cache level (aggressive, basic, simplified)
	Level string `json:"level,omitempty"`
	// BrowserTTL is the browser cache TTL in seconds
	BrowserTTL int `json:"browserTtl,omitempty"`
	// DevelopmentMode enables development mode
	DevelopmentMode *bool `json:"developmentMode,omitempty"`
	// AlwaysOnline enables always online
	AlwaysOnline *bool `json:"alwaysOnline,omitempty"`
	// TieredCache configures tiered caching
	TieredCache *TieredCacheConfig `json:"tieredCache,omitempty"`
	// CacheReserve configures persistent cache storage
	CacheReserve *CacheReserveConfig `json:"cacheReserve,omitempty"`
	// CacheByDeviceType caches content separately for mobile/desktop
	CacheByDeviceType *bool `json:"cacheByDeviceType,omitempty"`
	// SortQueryStringForCache treats query strings with same parameters
	// but different order as the same for caching purposes
	SortQueryStringForCache *bool `json:"sortQueryStringForCache,omitempty"`
}

CacheConfig contains cache configuration.

type CacheReserveConfig added in v0.25.0

type CacheReserveConfig struct {
	// Enabled enables Cache Reserve
	Enabled bool `json:"enabled,omitempty"`
}

CacheReserveConfig configures Cache Reserve (persistent cache).

type CloudflareDomainConfig

type CloudflareDomainConfig struct {
	// Domain is the domain name
	Domain string `json:"domain"`
	// SSL contains SSL/TLS configuration
	SSL *SSLConfig `json:"ssl,omitempty"`
	// Cache contains cache configuration
	Cache *CacheConfig `json:"cache,omitempty"`
	// Security contains security configuration
	Security *SecurityConfig `json:"security,omitempty"`
	// Performance contains performance configuration
	Performance *PerformanceConfig `json:"performance,omitempty"`
	// Verification contains domain verification settings
	Verification *VerificationConfig `json:"verification,omitempty"`
}

CloudflareDomainConfig contains the configuration for a Cloudflare Domain.

type CloudflareDomainRegisterOptions

type CloudflareDomainRegisterOptions struct {
	// AccountID is the Cloudflare account ID
	AccountID string
	// ZoneID is the Cloudflare zone ID
	ZoneID string
	// Source is the K8s resource source
	Source service.Source
	// Config is the domain configuration
	Config CloudflareDomainConfig
	// CredentialsRef references the CloudflareCredentials resource
	CredentialsRef v1alpha2.CredentialsReference
}

CloudflareDomainRegisterOptions contains options for registering a CloudflareDomain.

type CloudflareDomainService

type CloudflareDomainService struct {
	*service.BaseService
}

CloudflareDomainService manages CloudflareDomain configurations via CloudflareSyncState.

func NewCloudflareDomainService

func NewCloudflareDomainService(c client.Client) *CloudflareDomainService

NewCloudflareDomainService creates a new CloudflareDomain service.

func (*CloudflareDomainService) Register

Register registers a CloudflareDomain configuration with the SyncState.

func (*CloudflareDomainService) Unregister

func (s *CloudflareDomainService) Unregister(ctx context.Context, zoneID string, source service.Source) error

Unregister removes a CloudflareDomain configuration from the SyncState.

func (*CloudflareDomainService) UpdateStatus

UpdateStatus updates the K8s CloudflareDomain resource status based on sync result.

func (*CloudflareDomainService) UpdateZoneID

func (s *CloudflareDomainService) UpdateZoneID(ctx context.Context, source service.Source, zoneID, accountID string) error

UpdateZoneID updates the SyncState to use the actual zone ID.

type CloudflareDomainSyncResult

type CloudflareDomainSyncResult struct {
	// ZoneID is the Cloudflare zone ID
	ZoneID string
	// ZoneName is the zone name
	ZoneName string
	// Status is the domain status (maps to CloudflareDomainState)
	Status string
}

CloudflareDomainSyncResult contains CloudflareDomain-specific sync result.

type DNSVerificationRecord

type DNSVerificationRecord struct {
	// Type is the DNS record type (TXT, CNAME)
	Type string `json:"type,omitempty"`
	// Name is the record name
	Name string `json:"name,omitempty"`
	// Value is the record value
	Value string `json:"value,omitempty"`
}

DNSVerificationRecord contains DNS verification record details.

type DomainRegistrationAction added in v0.24.0

type DomainRegistrationAction string

DomainRegistrationAction defines the action to perform on a domain registration.

const (
	// DomainRegistrationActionSync syncs domain information from Cloudflare
	DomainRegistrationActionSync DomainRegistrationAction = "sync"
	// DomainRegistrationActionUpdate updates domain configuration in Cloudflare
	DomainRegistrationActionUpdate DomainRegistrationAction = "update"
)

type DomainRegistrationConfiguration added in v0.24.0

type DomainRegistrationConfiguration struct {
	// AutoRenew enables auto-renewal
	AutoRenew bool `json:"autoRenew,omitempty"`
	// Privacy enables WHOIS privacy
	Privacy bool `json:"privacy,omitempty"`
	// Locked enables registrar lock
	Locked bool `json:"locked,omitempty"`
	// NameServers is the list of name servers
	NameServers []string `json:"nameServers,omitempty"`
}

DomainRegistrationConfiguration contains domain registration configuration settings.

type DomainRegistrationLifecycleConfig added in v0.24.0

type DomainRegistrationLifecycleConfig struct {
	// Action is the lifecycle operation to perform
	Action DomainRegistrationAction `json:"action"`
	// DomainName is the domain name to manage
	DomainName string `json:"domainName"`
	// Configuration is the optional domain configuration to apply
	Configuration *DomainRegistrationConfiguration `json:"configuration,omitempty"`
}

DomainRegistrationLifecycleConfig contains lifecycle operation configuration for domain registration.

type DomainRegistrationRegisterOptions added in v0.24.0

type DomainRegistrationRegisterOptions struct {
	// AccountID is the Cloudflare account ID
	AccountID string
	// Source identifies the K8s resource
	Source service.Source
	// CredentialsRef references the CloudflareCredentials to use
	CredentialsRef v1alpha2.CredentialsReference
	// DomainName is the domain name to manage
	DomainName string
	// Configuration is the optional domain configuration to apply
	Configuration *DomainRegistrationConfiguration
}

DomainRegistrationRegisterOptions contains options for registering a DomainRegistration.

type DomainRegistrationService added in v0.24.0

type DomainRegistrationService struct {
	*service.BaseService
}

DomainRegistrationService manages DomainRegistration configurations via CloudflareSyncState.

func NewDomainRegistrationService added in v0.24.0

func NewDomainRegistrationService(c client.Client) *DomainRegistrationService

NewDomainRegistrationService creates a new DomainRegistration service.

func (*DomainRegistrationService) CleanupSyncState added in v0.24.0

func (s *DomainRegistrationService) CleanupSyncState(ctx context.Context, domainName string) error

CleanupSyncState removes the SyncState for a domain registration after successful deletion.

func (*DomainRegistrationService) GetLifecycleError added in v0.24.0

func (s *DomainRegistrationService) GetLifecycleError(ctx context.Context, domainName string) (string, error)

GetLifecycleError returns the error message if the sync operation failed.

func (*DomainRegistrationService) GetLifecycleResult added in v0.24.0

func (s *DomainRegistrationService) GetLifecycleResult(ctx context.Context, domainName string) (*DomainRegistrationSyncResult, error)

GetLifecycleResult retrieves the result of a sync operation from SyncState. Returns nil if the operation hasn't completed yet.

func (*DomainRegistrationService) IsLifecycleCompleted added in v0.24.0

func (s *DomainRegistrationService) IsLifecycleCompleted(ctx context.Context, domainName string) (bool, error)

IsLifecycleCompleted checks if the sync operation has completed.

func (*DomainRegistrationService) RequestSync added in v0.24.0

RequestSync requests a sync of domain registration information from Cloudflare. Returns the SyncState name that can be watched for completion.

func (*DomainRegistrationService) Unregister added in v0.24.0

func (s *DomainRegistrationService) Unregister(ctx context.Context, domainName string, source service.Source) error

Unregister removes a domain registration configuration from the SyncState.

type DomainRegistrationSyncResult added in v0.24.0

type DomainRegistrationSyncResult struct {
	// DomainID is the domain ID
	DomainID string
	// CurrentRegistrar is the current registrar
	CurrentRegistrar string
	// RegistryStatuses are the registry statuses (comma-separated string from Cloudflare)
	RegistryStatuses string
	// Locked indicates if the domain is locked
	Locked bool
	// TransferInStatus is the transfer in status
	TransferInStatus string
	// ExpiresAt is the expiration time
	ExpiresAt metav1.Time
	// CreatedAt is the creation time
	CreatedAt metav1.Time
	// AutoRenew indicates if auto-renewal is enabled
	AutoRenew bool
	// Privacy indicates if WHOIS privacy is enabled
	Privacy bool
}

DomainRegistrationSyncResult contains the result of a domain registration sync.

type MinifyConfig

type MinifyConfig struct {
	// HTML enables HTML minification
	HTML *bool `json:"html,omitempty"`
	// CSS enables CSS minification
	CSS *bool `json:"css,omitempty"`
	// JS enables JavaScript minification
	JS *bool `json:"js,omitempty"`
}

MinifyConfig contains minification settings.

type OriginCACertificateAction added in v0.24.0

type OriginCACertificateAction string

OriginCACertificateAction defines the action to perform on a certificate.

const (
	// OriginCACertificateActionCreate creates a new certificate
	OriginCACertificateActionCreate OriginCACertificateAction = "create"
	// OriginCACertificateActionRevoke revokes an existing certificate
	OriginCACertificateActionRevoke OriginCACertificateAction = "revoke"
	// OriginCACertificateActionRenew renews an existing certificate
	OriginCACertificateActionRenew OriginCACertificateAction = "renew"
)

type OriginCACertificateConfig

type OriginCACertificateConfig struct {
	// Hostnames is the list of hostnames to cover
	Hostnames []string `json:"hostnames"`
	// RequestType is the certificate request type (origin-rsa, origin-ecc)
	RequestType string `json:"requestType,omitempty"`
	// ValidityDays is the certificate validity in days
	ValidityDays int `json:"validityDays,omitempty"`
	// CSR is the Certificate Signing Request (if provided)
	CSR string `json:"csr,omitempty"`
}

OriginCACertificateConfig contains the configuration for an Origin CA Certificate.

type OriginCACertificateCreateOptions added in v0.24.0

type OriginCACertificateCreateOptions struct {
	// AccountID is the Cloudflare account ID
	AccountID string
	// ZoneID is the Cloudflare zone ID
	ZoneID string
	// Source identifies the K8s resource
	Source service.Source
	// CredentialsRef references the CloudflareCredentials to use
	CredentialsRef v1alpha2.CredentialsReference
	// Hostnames is the list of hostnames to cover
	Hostnames []string
	// RequestType is the certificate request type (origin-rsa, origin-ecc)
	RequestType string
	// ValidityDays is the certificate validity in days
	ValidityDays int
	// CSR is the Certificate Signing Request
	CSR string
}

OriginCACertificateCreateOptions contains options for creating an Origin CA certificate.

type OriginCACertificateLifecycleConfig added in v0.24.0

type OriginCACertificateLifecycleConfig struct {
	// Action is the lifecycle operation to perform
	Action OriginCACertificateAction `json:"action"`
	// CertificateID is the existing certificate ID (for revoke/renew)
	CertificateID string `json:"certificateId,omitempty"`
	// Hostnames is the list of hostnames to cover (for create/renew)
	Hostnames []string `json:"hostnames,omitempty"`
	// RequestType is the certificate request type (origin-rsa, origin-ecc)
	RequestType string `json:"requestType,omitempty"`
	// ValidityDays is the certificate validity in days
	ValidityDays int `json:"validityDays,omitempty"`
	// CSR is the Certificate Signing Request
	CSR string `json:"csr,omitempty"`
}

OriginCACertificateLifecycleConfig contains lifecycle operation configuration.

type OriginCACertificateRegisterOptions

type OriginCACertificateRegisterOptions struct {
	// AccountID is the Cloudflare account ID
	AccountID string
	// ZoneID is the Cloudflare zone ID
	ZoneID string
	// CertificateID is the existing certificate ID (empty for new)
	CertificateID string
	// Source is the K8s resource source
	Source service.Source
	// Config is the certificate configuration
	Config OriginCACertificateConfig
	// CredentialsRef references the CloudflareCredentials resource
	CredentialsRef v1alpha2.CredentialsReference
}

OriginCACertificateRegisterOptions contains options for registering an OriginCACertificate.

type OriginCACertificateRenewOptions added in v0.24.0

type OriginCACertificateRenewOptions struct {
	// AccountID is the Cloudflare account ID
	AccountID string
	// ZoneID is the Cloudflare zone ID
	ZoneID string
	// Source identifies the K8s resource
	Source service.Source
	// CredentialsRef references the CloudflareCredentials to use
	CredentialsRef v1alpha2.CredentialsReference
	// CertificateID is the existing certificate ID to revoke
	CertificateID string
	// Hostnames is the list of hostnames to cover
	Hostnames []string
	// RequestType is the certificate request type (origin-rsa, origin-ecc)
	RequestType string
	// ValidityDays is the certificate validity in days
	ValidityDays int
	// CSR is the Certificate Signing Request
	CSR string
}

OriginCACertificateRenewOptions contains options for renewing an Origin CA certificate.

type OriginCACertificateRevokeOptions added in v0.24.0

type OriginCACertificateRevokeOptions struct {
	// AccountID is the Cloudflare account ID
	AccountID string
	// ZoneID is the Cloudflare zone ID
	ZoneID string
	// Source identifies the K8s resource
	Source service.Source
	// CredentialsRef references the CloudflareCredentials to use
	CredentialsRef v1alpha2.CredentialsReference
	// CertificateID is the ID of the certificate to revoke
	CertificateID string
}

OriginCACertificateRevokeOptions contains options for revoking an Origin CA certificate.

type OriginCACertificateService

type OriginCACertificateService struct {
	*service.BaseService
}

OriginCACertificateService manages OriginCACertificate configurations via CloudflareSyncState.

func NewOriginCACertificateService

func NewOriginCACertificateService(c client.Client) *OriginCACertificateService

NewOriginCACertificateService creates a new OriginCACertificate service.

func (*OriginCACertificateService) CleanupSyncState added in v0.24.0

func (s *OriginCACertificateService) CleanupSyncState(ctx context.Context, namespace, name string) error

CleanupSyncState removes the SyncState for a certificate after successful deletion.

func (*OriginCACertificateService) GetLifecycleError added in v0.24.0

func (s *OriginCACertificateService) GetLifecycleError(ctx context.Context, namespace, name string) (string, error)

GetLifecycleError returns the error message if the lifecycle operation failed.

func (*OriginCACertificateService) GetLifecycleResult added in v0.24.0

func (s *OriginCACertificateService) GetLifecycleResult(ctx context.Context, namespace, name string) (*OriginCACertificateSyncResult, error)

GetLifecycleResult retrieves the result of a lifecycle operation from SyncState. Returns nil if the operation hasn't completed yet.

func (*OriginCACertificateService) IsLifecycleCompleted added in v0.24.0

func (s *OriginCACertificateService) IsLifecycleCompleted(ctx context.Context, namespace, name string) (bool, error)

IsLifecycleCompleted checks if the lifecycle operation has completed.

func (*OriginCACertificateService) Register

Register registers an OriginCACertificate configuration with the SyncState.

func (*OriginCACertificateService) RequestCreate added in v0.24.0

RequestCreate requests creation of a new Origin CA certificate. The actual creation is performed by the OriginCACertificateSyncController. Returns the SyncState name that can be watched for completion.

func (*OriginCACertificateService) RequestRenew added in v0.24.0

RequestRenew requests renewal of an existing Origin CA certificate. The actual renewal is performed by the OriginCACertificateSyncController. Returns the SyncState name that can be watched for completion.

func (*OriginCACertificateService) RequestRevoke added in v0.24.0

RequestRevoke requests revocation of an existing Origin CA certificate. The actual revocation is performed by the OriginCACertificateSyncController. Returns the SyncState name that can be watched for completion.

func (*OriginCACertificateService) Unregister

func (s *OriginCACertificateService) Unregister(ctx context.Context, certificateID string, source service.Source) error

Unregister removes a configuration from the SyncState.

func (*OriginCACertificateService) UpdateCertificateID

func (s *OriginCACertificateService) UpdateCertificateID(ctx context.Context, source service.Source, certificateID, accountID, zoneID string) error

UpdateCertificateID updates the SyncState to use the actual certificate ID.

func (*OriginCACertificateService) UpdateStatus

UpdateStatus updates the K8s OriginCACertificate resource status based on sync result.

type OriginCACertificateSyncResult

type OriginCACertificateSyncResult struct {
	// CertificateID is the certificate ID
	CertificateID string
	// ExpiresAt is the expiration time
	ExpiresAt *metav1.Time
	// Certificate is the certificate PEM
	Certificate string
	// PrivateKey is the private key PEM (only on creation)
	PrivateKey string
}

OriginCACertificateSyncResult contains OriginCACertificate-specific sync result.

type PerformanceConfig

type PerformanceConfig struct {
	// Minify contains minification settings
	Minify *MinifyConfig `json:"minify,omitempty"`
	// Polish is the image optimization setting (lossy, lossless, off)
	Polish string `json:"polish,omitempty"`
	// WebP enables WebP image conversion
	WebP *bool `json:"webp,omitempty"`
	// Mirage enables Mirage (image optimization for mobile)
	Mirage *bool `json:"mirage,omitempty"`
	// Brotli enables Brotli compression
	Brotli *bool `json:"brotli,omitempty"`
	// EarlyHints enables Early Hints
	EarlyHints *bool `json:"earlyHints,omitempty"`
	// HTTP2 enables HTTP/2
	HTTP2 *bool `json:"http2,omitempty"`
	// HTTP3 enables HTTP/3
	HTTP3 *bool `json:"http3,omitempty"`
	// ZeroRTT enables 0-RTT Connection Resumption
	ZeroRTT *bool `json:"zeroRtt,omitempty"`
	// RocketLoader enables Rocket Loader
	RocketLoader *bool `json:"rocketLoader,omitempty"`
	// PrefetchPreload enables prefetch and preload
	PrefetchPreload *bool `json:"prefetchPreload,omitempty"`
	// IPGeolocation adds visitor's country to request headers
	IPGeolocation *bool `json:"ipGeolocation,omitempty"`
	// Websockets enables WebSocket support
	Websockets *bool `json:"websockets,omitempty"`
}

PerformanceConfig contains performance configuration.

type SSLConfig

type SSLConfig struct {
	// Mode is the SSL mode (off, flexible, full, full_strict)
	Mode string `json:"mode,omitempty"`
	// MinVersion is the minimum TLS version (1.0, 1.1, 1.2, 1.3)
	MinVersion string `json:"minVersion,omitempty"`
	// TLS13 enables TLS 1.3 (on, off)
	TLS13 string `json:"tls13,omitempty"`
	// AlwaysUseHTTPS enables automatic HTTPS redirect
	AlwaysUseHTTPS *bool `json:"alwaysUseHttps,omitempty"`
	// AutomaticHTTPSRewrites enables automatic HTTPS rewrites
	AutomaticHTTPSRewrites *bool `json:"automaticHttpsRewrites,omitempty"`
	// OpportunisticEncryption enables opportunistic encryption
	OpportunisticEncryption *bool `json:"opportunisticEncryption,omitempty"`
	// AuthenticatedOriginPull configures mTLS between Cloudflare and origin
	AuthenticatedOriginPull *AuthenticatedOriginPullConfig `json:"authenticatedOriginPull,omitempty"`
}

SSLConfig contains SSL/TLS configuration.

type SecurityConfig

type SecurityConfig struct {
	// Level is the security level (essentially_off, low, medium, high, under_attack)
	Level string `json:"level,omitempty"`
	// BrowserIntegrityCheck enables browser integrity check
	BrowserIntegrityCheck *bool `json:"browserIntegrityCheck,omitempty"`
	// EmailObfuscation enables email obfuscation
	EmailObfuscation *bool `json:"emailObfuscation,omitempty"`
	// ServerSideExclude enables server-side excludes
	ServerSideExclude *bool `json:"serverSideExclude,omitempty"`
	// HotlinkProtection enables hotlink protection
	HotlinkProtection *bool `json:"hotlinkProtection,omitempty"`
	// ChallengePassage sets how long a visitor can access the site
	// after completing a challenge (in seconds)
	ChallengePassage *int `json:"challengePassage,omitempty"`
	// WAF contains WAF configuration
	WAF *WAFConfig `json:"waf,omitempty"`
}

SecurityConfig contains security configuration.

type TieredCacheConfig added in v0.25.0

type TieredCacheConfig struct {
	// Enabled enables tiered caching
	Enabled bool `json:"enabled,omitempty"`
	// Topology sets the tiered cache topology (smart, generic)
	Topology string `json:"topology,omitempty"`
}

TieredCacheConfig configures tiered caching.

type VerificationConfig

type VerificationConfig struct {
	// Method is the verification method (dns, http)
	Method string `json:"method,omitempty"`
	// DNSRecord contains DNS verification settings
	DNSRecord *DNSVerificationRecord `json:"dnsRecord,omitempty"`
}

VerificationConfig contains domain verification settings.

type WAFConfig

type WAFConfig struct {
	// Enabled enables the WAF
	Enabled *bool `json:"enabled,omitempty"`
	// RuleGroups contains rule group settings
	RuleGroups []WAFRuleGroup `json:"ruleGroups,omitempty"`
}

WAFConfig contains WAF configuration.

type WAFRuleGroup

type WAFRuleGroup struct {
	// ID is the rule group ID
	ID string `json:"id,omitempty"`
	// Mode is the rule group mode (on, off, anomaly, traditional)
	Mode string `json:"mode,omitempty"`
}

WAFRuleGroup contains a WAF rule group configuration.

Jump to

Keyboard shortcuts

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