Documentation
¶
Overview ¶
Package ruleset provides services for managing Cloudflare Ruleset configurations.
Index ¶
- Constants
- type RedirectRuleConfig
- type RedirectRuleDefinitionConfig
- type RedirectRuleRegisterOptions
- type RedirectRuleService
- func (s *RedirectRuleService) Register(ctx context.Context, opts RedirectRuleRegisterOptions) error
- func (s *RedirectRuleService) Unregister(ctx context.Context, rulesetID string, source service.Source) error
- func (s *RedirectRuleService) UpdateRulesetID(ctx context.Context, source service.Source, rulesetID, zoneID string) error
- func (s *RedirectRuleService) UpdateStatus(ctx context.Context, rule *v1alpha2.RedirectRule, ...) error
- type RedirectRuleSyncResult
- type RedirectTargetConfig
- type RulesetRuleConfig
- type SyncResult
- type TransformRuleConfig
- type TransformRuleDefinitionConfig
- type TransformRuleRegisterOptions
- type TransformRuleService
- func (s *TransformRuleService) Register(ctx context.Context, opts TransformRuleRegisterOptions) error
- func (s *TransformRuleService) Unregister(ctx context.Context, rulesetID string, source service.Source) error
- func (s *TransformRuleService) UpdateRulesetID(ctx context.Context, source service.Source, rulesetID, zoneID string) error
- func (s *TransformRuleService) UpdateStatus(ctx context.Context, rule *v1alpha2.TransformRule, ...) error
- type TransformRuleSyncResult
- type WildcardRedirectRuleConfig
- type ZoneRulesetConfig
- type ZoneRulesetRegisterOptions
- type ZoneRulesetService
- func (s *ZoneRulesetService) Register(ctx context.Context, opts ZoneRulesetRegisterOptions) error
- func (s *ZoneRulesetService) Unregister(ctx context.Context, rulesetID string, source service.Source) error
- func (s *ZoneRulesetService) UpdateRulesetID(ctx context.Context, source service.Source, rulesetID, zoneID string) error
- func (s *ZoneRulesetService) UpdateStatus(ctx context.Context, ruleset *v1alpha2.ZoneRuleset, ...) error
- type ZoneRulesetSyncResult
Constants ¶
const ( // ResourceTypeZoneRuleset is the SyncState resource type for ZoneRuleset ResourceTypeZoneRuleset = v1alpha2.SyncResourceZoneRuleset // ResourceTypeTransformRule is the SyncState resource type for TransformRule ResourceTypeTransformRule = v1alpha2.SyncResourceTransformRule // ResourceTypeRedirectRule is the SyncState resource type for RedirectRule ResourceTypeRedirectRule = v1alpha2.SyncResourceRedirectRule // Priority constants PriorityZoneRuleset = 100 PriorityTransformRule = 100 PriorityRedirectRule = 100 )
Resource Types for SyncState - use constants from v1alpha2
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedirectRuleConfig ¶
type RedirectRuleConfig struct {
// Zone is the domain name
Zone string `json:"zone"`
// Description is an optional ruleset description
Description string `json:"description,omitempty"`
// Rules is the list of expression-based redirect rules
Rules []RedirectRuleDefinitionConfig `json:"rules,omitempty"`
// WildcardRules is the list of wildcard-based redirect rules
WildcardRules []WildcardRedirectRuleConfig `json:"wildcardRules,omitempty"`
}
RedirectRuleConfig contains the configuration for redirect rules.
type RedirectRuleDefinitionConfig ¶
type RedirectRuleDefinitionConfig struct {
// Name is the rule name
Name string `json:"name"`
// Expression is the wirefilter expression
Expression string `json:"expression"`
// Enabled indicates if the rule is enabled
Enabled bool `json:"enabled"`
// Target contains the redirect target
Target RedirectTargetConfig `json:"target"`
// StatusCode is the HTTP redirect status code (301, 302, 303, 307, 308)
StatusCode int `json:"statusCode,omitempty"`
// PreserveQueryString indicates whether to preserve query string
PreserveQueryString bool `json:"preserveQueryString,omitempty"`
}
RedirectRuleDefinitionConfig contains a single redirect rule definition.
type RedirectRuleRegisterOptions ¶
type RedirectRuleRegisterOptions struct {
// AccountID is the Cloudflare account ID
AccountID string
// ZoneID is the Cloudflare zone ID
ZoneID string
// RulesetID is the existing ruleset ID (empty for new)
RulesetID string
// Source is the K8s resource source
Source service.Source
// Config is the redirect rule configuration
Config RedirectRuleConfig
// CredentialsRef references the CloudflareCredentials resource
CredentialsRef v1alpha2.CredentialsReference
}
RedirectRuleRegisterOptions contains options for registering a RedirectRule.
type RedirectRuleService ¶
type RedirectRuleService struct {
*service.BaseService
}
RedirectRuleService manages RedirectRule configurations via CloudflareSyncState.
func NewRedirectRuleService ¶
func NewRedirectRuleService(c client.Client) *RedirectRuleService
NewRedirectRuleService creates a new RedirectRule service.
func (*RedirectRuleService) Register ¶
func (s *RedirectRuleService) Register(ctx context.Context, opts RedirectRuleRegisterOptions) error
Register registers a RedirectRule configuration with the SyncState.
func (*RedirectRuleService) Unregister ¶
func (s *RedirectRuleService) Unregister(ctx context.Context, rulesetID string, source service.Source) error
Unregister removes a configuration from the SyncState.
func (*RedirectRuleService) UpdateRulesetID ¶
func (s *RedirectRuleService) UpdateRulesetID(ctx context.Context, source service.Source, rulesetID, zoneID string) error
UpdateRulesetID updates the SyncState to use the actual ruleset ID after the ruleset is created.
func (*RedirectRuleService) UpdateStatus ¶
func (s *RedirectRuleService) UpdateStatus( ctx context.Context, rule *v1alpha2.RedirectRule, result *RedirectRuleSyncResult, ) error
UpdateStatus updates the K8s RedirectRule resource status based on sync result.
type RedirectRuleSyncResult ¶
type RedirectRuleSyncResult struct {
SyncResult
// RulesetID is the actual ruleset ID
RulesetID string
// ZoneID is the zone ID
ZoneID string
// RuleCount is the number of rules
RuleCount int
}
RedirectRuleSyncResult contains RedirectRule-specific sync result.
type RedirectTargetConfig ¶
type RedirectTargetConfig struct {
// URL is a static target URL
URL string `json:"url,omitempty"`
// Expression is a dynamic target URL expression
Expression string `json:"expression,omitempty"`
}
RedirectTargetConfig contains redirect target configuration.
type RulesetRuleConfig ¶
type RulesetRuleConfig struct {
// Action is the rule action (e.g., block, challenge, skip, execute)
Action string `json:"action"`
// Expression is the wirefilter expression
Expression string `json:"expression"`
// Description is the rule description
Description string `json:"description,omitempty"`
// Enabled indicates if the rule is enabled
Enabled bool `json:"enabled"`
// Ref is an optional reference string
Ref string `json:"ref,omitempty"`
// ActionParameters contains action-specific parameters
ActionParameters *v1alpha2.RulesetRuleActionParameters `json:"actionParameters,omitempty"`
// RateLimit contains rate limiting configuration
RateLimit *v1alpha2.RulesetRuleRateLimit `json:"rateLimit,omitempty"`
}
RulesetRuleConfig contains a single ruleset rule configuration.
type SyncResult ¶
type SyncResult struct {
// ID is the Cloudflare resource ID
ID string
// AccountID is the Cloudflare account ID
AccountID string
}
SyncResult contains the result of a sync operation.
type TransformRuleConfig ¶
type TransformRuleConfig struct {
// Zone is the domain name
Zone string `json:"zone"`
// Type is the transform rule type (url_rewrite, request_header, response_header)
Type string `json:"type"`
// Description is an optional ruleset description
Description string `json:"description,omitempty"`
// Rules is the list of transform rules
Rules []TransformRuleDefinitionConfig `json:"rules"`
}
TransformRuleConfig contains the configuration for transform rules.
type TransformRuleDefinitionConfig ¶
type TransformRuleDefinitionConfig struct {
// Name is the rule name
Name string `json:"name"`
// Expression is the wirefilter expression
Expression string `json:"expression"`
// Enabled indicates if the rule is enabled
Enabled bool `json:"enabled"`
// URLRewrite contains URL rewrite configuration
URLRewrite *v1alpha2.URLRewriteConfig `json:"urlRewrite,omitempty"`
// Headers contains header modification rules
Headers []v1alpha2.HeaderModification `json:"headers,omitempty"`
}
TransformRuleDefinitionConfig contains a single transform rule definition.
type TransformRuleRegisterOptions ¶
type TransformRuleRegisterOptions struct {
// AccountID is the Cloudflare account ID
AccountID string
// ZoneID is the Cloudflare zone ID
ZoneID string
// RulesetID is the existing ruleset ID (empty for new)
RulesetID string
// Source is the K8s resource source
Source service.Source
// Config is the transform rule configuration
Config TransformRuleConfig
// CredentialsRef references the CloudflareCredentials resource
CredentialsRef v1alpha2.CredentialsReference
}
TransformRuleRegisterOptions contains options for registering a TransformRule.
type TransformRuleService ¶
type TransformRuleService struct {
*service.BaseService
}
TransformRuleService manages TransformRule configurations via CloudflareSyncState.
func NewTransformRuleService ¶
func NewTransformRuleService(c client.Client) *TransformRuleService
NewTransformRuleService creates a new TransformRule service.
func (*TransformRuleService) Register ¶
func (s *TransformRuleService) Register(ctx context.Context, opts TransformRuleRegisterOptions) error
Register registers a TransformRule configuration with the SyncState.
func (*TransformRuleService) Unregister ¶
func (s *TransformRuleService) Unregister(ctx context.Context, rulesetID string, source service.Source) error
Unregister removes a configuration from the SyncState.
func (*TransformRuleService) UpdateRulesetID ¶
func (s *TransformRuleService) UpdateRulesetID(ctx context.Context, source service.Source, rulesetID, zoneID string) error
UpdateRulesetID updates the SyncState to use the actual ruleset ID after the ruleset is created.
func (*TransformRuleService) UpdateStatus ¶
func (s *TransformRuleService) UpdateStatus( ctx context.Context, rule *v1alpha2.TransformRule, result *TransformRuleSyncResult, ) error
UpdateStatus updates the K8s TransformRule resource status based on sync result.
type TransformRuleSyncResult ¶
type TransformRuleSyncResult struct {
SyncResult
// RulesetID is the actual ruleset ID
RulesetID string
// ZoneID is the zone ID
ZoneID string
// RuleCount is the number of rules
RuleCount int
}
TransformRuleSyncResult contains TransformRule-specific sync result.
type WildcardRedirectRuleConfig ¶
type WildcardRedirectRuleConfig struct {
// Name is the rule name
Name string `json:"name"`
// Enabled indicates if the rule is enabled
Enabled bool `json:"enabled"`
// SourceURL is the source URL pattern with wildcards
SourceURL string `json:"sourceUrl"`
// TargetURL is the target URL pattern
TargetURL string `json:"targetUrl"`
// StatusCode is the HTTP redirect status code
StatusCode int `json:"statusCode,omitempty"`
// PreserveQueryString indicates whether to preserve query string
PreserveQueryString bool `json:"preserveQueryString,omitempty"`
// IncludeSubdomains applies the redirect to subdomains
IncludeSubdomains bool `json:"includeSubdomains,omitempty"`
// SubpathMatching enables matching of subpaths
SubpathMatching bool `json:"subpathMatching,omitempty"`
}
WildcardRedirectRuleConfig contains wildcard redirect rule configuration.
type ZoneRulesetConfig ¶
type ZoneRulesetConfig struct {
// Zone is the domain name
Zone string `json:"zone"`
// Phase is the ruleset phase (e.g., http_request_firewall_custom)
Phase string `json:"phase"`
// Description is an optional ruleset description
Description string `json:"description,omitempty"`
// Rules is the list of ruleset rules
Rules []RulesetRuleConfig `json:"rules"`
}
ZoneRulesetConfig contains the configuration for a zone ruleset.
type ZoneRulesetRegisterOptions ¶
type ZoneRulesetRegisterOptions struct {
// AccountID is the Cloudflare account ID
AccountID string
// ZoneID is the Cloudflare zone ID
ZoneID string
// RulesetID is the existing ruleset ID (empty for new)
RulesetID string
// Source is the K8s resource source
Source service.Source
// Config is the ruleset configuration
Config ZoneRulesetConfig
// CredentialsRef references the CloudflareCredentials resource
CredentialsRef v1alpha2.CredentialsReference
}
ZoneRulesetRegisterOptions contains options for registering a ZoneRuleset.
type ZoneRulesetService ¶
type ZoneRulesetService struct {
*service.BaseService
}
ZoneRulesetService manages ZoneRuleset configurations via CloudflareSyncState.
func NewZoneRulesetService ¶
func NewZoneRulesetService(c client.Client) *ZoneRulesetService
NewZoneRulesetService creates a new ZoneRuleset service.
func (*ZoneRulesetService) Register ¶
func (s *ZoneRulesetService) Register(ctx context.Context, opts ZoneRulesetRegisterOptions) error
Register registers a ZoneRuleset configuration with the SyncState.
func (*ZoneRulesetService) Unregister ¶
func (s *ZoneRulesetService) Unregister(ctx context.Context, rulesetID string, source service.Source) error
Unregister removes a configuration from the SyncState.
func (*ZoneRulesetService) UpdateRulesetID ¶
func (s *ZoneRulesetService) UpdateRulesetID(ctx context.Context, source service.Source, rulesetID, zoneID string) error
UpdateRulesetID updates the SyncState to use the actual ruleset ID after the ruleset is created.
func (*ZoneRulesetService) UpdateStatus ¶
func (s *ZoneRulesetService) UpdateStatus( ctx context.Context, ruleset *v1alpha2.ZoneRuleset, result *ZoneRulesetSyncResult, ) error
UpdateStatus updates the K8s ZoneRuleset resource status based on sync result.
type ZoneRulesetSyncResult ¶
type ZoneRulesetSyncResult struct {
SyncResult
// RulesetID is the actual ruleset ID
RulesetID string
// RulesetVersion is the ruleset version
RulesetVersion string
// ZoneID is the zone ID
ZoneID string
// RuleCount is the number of rules
RuleCount int
}
ZoneRulesetSyncResult contains ZoneRuleset-specific sync result.