Skip to content

Commit

Permalink
Add Origin Cache Control option to Rulesets API schema
Browse files Browse the repository at this point in the history
  • Loading branch information
iveelsm committed Sep 11, 2023
1 parent 6acb2e8 commit 00fa1a2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/data-sources/rulesets.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Read-Only:
- `mirage` (Boolean)
- `opportunistic_encryption` (Boolean)
- `origin` (List of Object) (see [below for nested schema](#nestedobjatt--rulesets--rules--action_parameters--origin))
- `origin_cache_control` (Boolean)
- `origin_error_page_passthru` (Boolean)
- `overrides` (List of Object) (see [below for nested schema](#nestedobjatt--rulesets--rules--action_parameters--overrides))
- `phases` (Set of String)
Expand Down
1 change: 1 addition & 0 deletions docs/resources/ruleset.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ Optional:
- `mirage` (Boolean) Turn on or off Cloudflare Mirage of the Cloudflare Speed app.
- `opportunistic_encryption` (Boolean) Turn on or off the Cloudflare Opportunistic Encryption feature of the Edge Certificates tab in the Cloudflare SSL/TLS app.
- `origin` (Block List) List of properties to change request origin. (see [below for nested schema](#nestedblock--rules--action_parameters--origin))
- `origin_cache_control` (Boolean)
- `origin_error_page_passthru` (Boolean) Pass-through error page for origin.
- `overrides` (Block List) List of override configurations to apply to the ruleset. (see [below for nested schema](#nestedblock--rules--action_parameters--overrides))
- `phases` (Set of String) Point in the request/response lifecycle where the ruleset will be created. Available values: `ddos_l4`, `ddos_l7`, `http_config_settings`, `http_custom_errors`, `http_log_custom_fields`, `http_ratelimit`, `http_request_cache_settings`, `http_request_dynamic_redirect`, `http_request_firewall_custom`, `http_request_firewall_managed`, `http_request_late_transform`, `http_request_origin`, `http_request_redirect`, `http_request_sanitize`, `http_request_sbfm`, `http_request_transform`, `http_response_compression`, `http_response_firewall_managed`, `http_response_headers_transform`, `magic_transit`.
Expand Down
1 change: 1 addition & 0 deletions internal/framework/service/rulesets/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type ActionParametersModel struct {
Mirage types.Bool `tfsdk:"mirage"`
OpportunisticEncryption types.Bool `tfsdk:"opportunistic_encryption"`
Origin []*ActionParameterOriginModel `tfsdk:"origin"`
OriginCacheControl types.Bool `tfsdk:"origin_cache_control"`
OriginErrorPagePassthru types.Bool `tfsdk:"origin_error_page_passthru"`
Overrides []*ActionParameterOverridesModel `tfsdk:"overrides"`
Phases types.Set `tfsdk:"phases"`
Expand Down
2 changes: 2 additions & 0 deletions internal/framework/service/rulesets/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,7 @@ func TestAccCloudflareRuleset_CacheSettingsAllEnabled(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "rules.0.action_parameters.0.cache_key.0.custom_key.0.user.0.device_type", "true"),
resource.TestCheckResourceAttr(resourceName, "rules.0.action_parameters.0.cache_key.0.custom_key.0.user.0.geo", "false"),
resource.TestCheckResourceAttr(resourceName, "rules.0.action_parameters.0.cache_key.0.custom_key.0.host.0.resolved", "true"),
resource.TestCheckResourceAttr(resourceName, "rules.0.action_parameters.0.origin_cache_control", "true"),
resource.TestCheckResourceAttr(resourceName, "rules.0.action_parameters.0.origin_error_page_passthru", "false"),
),
},
Expand Down Expand Up @@ -3918,6 +3919,7 @@ func testAccCloudflareRulesetCacheSettingsAllEnabled(rnd, accountID, zoneID stri
}
}
}
origin_cache_control = true
origin_error_page_passthru = false
}
expression = "true"
Expand Down
4 changes: 4 additions & 0 deletions internal/framework/service/rulesets/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ func (r *RulesetResource) Schema(ctx context.Context, req resource.SchemaRequest
Optional: true,
MarkdownDescription: "Turn on or off the Cloudflare Opportunistic Encryption feature of the Edge Certificates tab in the Cloudflare SSL/TLS app.",
},
"origin_cache_control": schema.BoolAttribute{
Optional: true,
MarkdownDescription: "Enable or disable the use of a more compliant Cache Control parsing mechanism, enabled by default for most zones.",
},
"phases": schema.SetAttribute{
ElementType: types.StringType,
Optional: true,
Expand Down
5 changes: 5 additions & 0 deletions internal/sdkv2provider/data_source_rulesets.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,11 @@ func resourceCloudflareRulesetSchema() map[string]*schema.Schema {
},
},
},
"origin_cache_control": {
Type: schema.TypeBool,
Optional: true,
Description: "Sets a more compliant mode for parsing Cache Control headers",
},
"origin_error_page_passthru": {
Type: schema.TypeBool,
Optional: true,
Expand Down

0 comments on commit 00fa1a2

Please sign in to comment.