Skip to content

Commit 726b8e7

Browse files
committed
feat(ruleset): add content_converter support to configuration rules
Add the content_converter boolean field to the cloudflare_ruleset resource and data source for the set_config action (http_config_settings phase). This allows users to enable content conversion via Configuration Rules. Changes: - Add ContentConverter field to resource and data source models - Add content_converter schema attribute with set_config validator - Add content_converter to migration tool simpleFields - Update SetConfigRules test fixtures and assertions - Update docs for ruleset resource and data source
1 parent 8045a6e commit 726b8e7

10 files changed

Lines changed: 39 additions & 1 deletion

File tree

cmd/migrate/cloudflare_ruleset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func transformCloudflareRulesetStateJSON(json string, instancePath string) strin
8888
// Note: disable_railgun was removed in v5, so we exclude it
8989
simpleFields := []string{
9090
"additional_cacheable_ports", "automatic_https_rewrites", "bic", "cache",
91-
"content", "content_type", "disable_apps", "disable_zaraz",
91+
"content", "content_converter", "content_type", "disable_apps", "disable_zaraz",
9292
"disable_rum", "fonts", "email_obfuscation", "host_header", "hotlink_protection",
9393
"id", "increment", "mirage", "opportunistic_encryption", "origin_cache_control",
9494
"polish", "products", "read_timeout", "respect_strong_etags",

docs/data-sources/ruleset.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Read-Only:
6969
- `automatic_https_rewrites` (Boolean) Whether to enable Automatic HTTPS Rewrites.
7070
- `autominify` (Attributes) Which file extensions to minify automatically. (see [below for nested schema](#nestedatt--rules--action_parameters--autominify))
7171
- `bic` (Boolean) Whether to enable Browser Integrity Check (BIC).
72+
- `content_converter` (Boolean) Whether to enable content conversion (e.g., HTML to Markdown).
7273
- `browser_ttl` (Attributes) How long client browsers should cache the response. Cloudflare cache purge will not purge content cached on client browsers, so high browser TTLs may lead to stale content. (see [below for nested schema](#nestedatt--rules--action_parameters--browser_ttl))
7374
- `cache` (Boolean) Whether the request's response from the origin is eligible for caching. Caching itself will still depend on the cache control header and your other caching configurations.
7475
- `cache_key` (Attributes) Which components of the request are included in or excluded from the cache key Cloudflare uses to store the response in cache. (see [below for nested schema](#nestedatt--rules--action_parameters--cache_key))

docs/resources/ruleset.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Optional:
8787
- `automatic_https_rewrites` (Boolean) Whether to enable Automatic HTTPS Rewrites.
8888
- `autominify` (Attributes) Which file extensions to minify automatically. (see [below for nested schema](#nestedatt--rules--action_parameters--autominify))
8989
- `bic` (Boolean) Whether to enable Browser Integrity Check (BIC).
90+
- `content_converter` (Boolean) Whether to enable content conversion (e.g., HTML to Markdown).
9091
- `browser_ttl` (Attributes) How long client browsers should cache the response. Cloudflare cache purge will not purge content cached on client browsers, so high browser TTLs may lead to stale content. (see [below for nested schema](#nestedatt--rules--action_parameters--browser_ttl))
9192
- `cache` (Boolean) Whether the request's response from the origin is eligible for caching. Caching itself will still depend on the cache control header and your other caching configurations.
9293
- `cache_key` (Attributes) Which components of the request are included in or excluded from the cache key Cloudflare uses to store the response in cache. (see [below for nested schema](#nestedatt--rules--action_parameters--cache_key))

internal/services/ruleset/data_source_model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ type RulesetRulesActionParametersDataSourceModel struct {
7878
AutomaticHTTPSRewrites types.Bool `tfsdk:"automatic_https_rewrites" json:"automatic_https_rewrites,computed"`
7979
Autominify customfield.NestedObject[RulesetRulesActionParametersAutominifyDataSourceModel] `tfsdk:"autominify" json:"autominify,computed"`
8080
BIC types.Bool `tfsdk:"bic" json:"bic,computed"`
81+
ContentConverter types.Bool `tfsdk:"content_converter" json:"content_converter,computed"`
8182
DisableApps types.Bool `tfsdk:"disable_apps" json:"disable_apps,computed"`
8283
DisableRUM types.Bool `tfsdk:"disable_rum" json:"disable_rum,computed"`
8384
DisableZaraz types.Bool `tfsdk:"disable_zaraz" json:"disable_zaraz,computed"`

internal/services/ruleset/data_source_schema.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,16 @@ func DataSourceSchema(ctx context.Context) schema.Schema {
782782
),
783783
},
784784
},
785+
"content_converter": schema.BoolAttribute{
786+
Description: "Whether to enable content conversion (e.g., HTML to Markdown).",
787+
Computed: true,
788+
Validators: []validator.Bool{
789+
customvalidator.RequiresOtherStringAttributeToBe(
790+
path.MatchRelative().AtParent().AtParent().AtName("action"),
791+
"set_config",
792+
),
793+
},
794+
},
785795
"disable_apps": schema.BoolAttribute{
786796
Description: "Whether to disable Cloudflare Apps.",
787797
Computed: true,

internal/services/ruleset/model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type RulesetRulesActionParametersModel struct {
6868
AutomaticHTTPSRewrites types.Bool `tfsdk:"automatic_https_rewrites" json:"automatic_https_rewrites,optional"`
6969
Autominify customfield.NestedObject[RulesetRulesActionParametersAutominifyModel] `tfsdk:"autominify" json:"autominify,optional"`
7070
BIC types.Bool `tfsdk:"bic" json:"bic,optional"`
71+
ContentConverter types.Bool `tfsdk:"content_converter" json:"content_converter,optional"`
7172
DisableApps types.Bool `tfsdk:"disable_apps" json:"disable_apps,optional"`
7273
DisableRUM types.Bool `tfsdk:"disable_rum" json:"disable_rum,optional"`
7374
DisableZaraz types.Bool `tfsdk:"disable_zaraz" json:"disable_zaraz,optional"`

internal/services/ruleset/ruleset_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6622,6 +6622,7 @@ func TestAccCloudflareRuleset_SetConfigRules(t *testing.T) {
66226622
"automatic_https_rewrites": knownvalue.Bool(false),
66236623
"autominify": knownvalue.Null(),
66246624
"bic": knownvalue.Null(),
6625+
"content_converter": knownvalue.Null(),
66256626
"disable_apps": knownvalue.Null(),
66266627
"disable_rum": knownvalue.Null(),
66276628
"disable_zaraz": knownvalue.Null(),
@@ -6653,6 +6654,7 @@ func TestAccCloudflareRuleset_SetConfigRules(t *testing.T) {
66536654
"automatic_https_rewrites": knownvalue.Bool(false),
66546655
"autominify": knownvalue.Null(),
66556656
"bic": knownvalue.Null(),
6657+
"content_converter": knownvalue.Null(),
66566658
"disable_apps": knownvalue.Null(),
66576659
"disable_rum": knownvalue.Null(),
66586660
"disable_zaraz": knownvalue.Null(),
@@ -6681,6 +6683,7 @@ func TestAccCloudflareRuleset_SetConfigRules(t *testing.T) {
66816683
"automatic_https_rewrites": knownvalue.Bool(false),
66826684
"autominify": knownvalue.Null(),
66836685
"bic": knownvalue.Null(),
6686+
"content_converter": knownvalue.Null(),
66846687
"disable_apps": knownvalue.Null(),
66856688
"disable_rum": knownvalue.Null(),
66866689
"disable_zaraz": knownvalue.Null(),
@@ -6724,6 +6727,7 @@ func TestAccCloudflareRuleset_SetConfigRules(t *testing.T) {
67246727
"js": knownvalue.Bool(false),
67256728
}),
67266729
"bic": knownvalue.Bool(false),
6730+
"content_converter": knownvalue.Bool(true),
67276731
"disable_apps": knownvalue.Bool(true),
67286732
"disable_rum": knownvalue.Bool(true),
67296733
"disable_zaraz": knownvalue.Bool(true),
@@ -6759,6 +6763,7 @@ func TestAccCloudflareRuleset_SetConfigRules(t *testing.T) {
67596763
"js": knownvalue.Bool(false),
67606764
}),
67616765
"bic": knownvalue.Bool(false),
6766+
"content_converter": knownvalue.Bool(true),
67626767
"disable_apps": knownvalue.Bool(true),
67636768
"disable_rum": knownvalue.Bool(true),
67646769
"disable_zaraz": knownvalue.Bool(true),
@@ -6791,6 +6796,7 @@ func TestAccCloudflareRuleset_SetConfigRules(t *testing.T) {
67916796
"js": knownvalue.Bool(false),
67926797
}),
67936798
"bic": knownvalue.Bool(false),
6799+
"content_converter": knownvalue.Bool(true),
67946800
"disable_apps": knownvalue.Bool(true),
67956801
"disable_rum": knownvalue.Bool(true),
67966802
"disable_zaraz": knownvalue.Bool(true),
@@ -6834,6 +6840,7 @@ func TestAccCloudflareRuleset_SetConfigRules(t *testing.T) {
68346840
"js": knownvalue.Bool(false),
68356841
}),
68366842
"bic": knownvalue.Bool(true),
6843+
"content_converter": knownvalue.Bool(true),
68376844
"disable_apps": knownvalue.Null(),
68386845
"disable_rum": knownvalue.Null(),
68396846
"disable_zaraz": knownvalue.Null(),
@@ -6869,6 +6876,7 @@ func TestAccCloudflareRuleset_SetConfigRules(t *testing.T) {
68696876
"js": knownvalue.Bool(false),
68706877
}),
68716878
"bic": knownvalue.Bool(true),
6879+
"content_converter": knownvalue.Bool(true),
68726880
"disable_apps": knownvalue.Null(),
68736881
"disable_rum": knownvalue.Null(),
68746882
"disable_zaraz": knownvalue.Null(),
@@ -6901,6 +6909,7 @@ func TestAccCloudflareRuleset_SetConfigRules(t *testing.T) {
69016909
"js": knownvalue.Bool(false),
69026910
}),
69036911
"bic": knownvalue.Bool(true),
6912+
"content_converter": knownvalue.Bool(true),
69046913
"disable_apps": knownvalue.Null(),
69056914
"disable_rum": knownvalue.Null(),
69066915
"disable_zaraz": knownvalue.Null(),
@@ -6944,6 +6953,7 @@ func TestAccCloudflareRuleset_SetConfigRules(t *testing.T) {
69446953
"js": knownvalue.Bool(true),
69456954
}),
69466955
"bic": knownvalue.Null(),
6956+
"content_converter": knownvalue.Null(),
69476957
"disable_apps": knownvalue.Null(),
69486958
"disable_rum": knownvalue.Null(),
69496959
"disable_zaraz": knownvalue.Null(),
@@ -6979,6 +6989,7 @@ func TestAccCloudflareRuleset_SetConfigRules(t *testing.T) {
69796989
"js": knownvalue.Bool(true),
69806990
}),
69816991
"bic": knownvalue.Null(),
6992+
"content_converter": knownvalue.Null(),
69826993
"disable_apps": knownvalue.Null(),
69836994
"disable_rum": knownvalue.Null(),
69846995
"disable_zaraz": knownvalue.Null(),
@@ -7011,6 +7022,7 @@ func TestAccCloudflareRuleset_SetConfigRules(t *testing.T) {
70117022
"js": knownvalue.Bool(true),
70127023
}),
70137024
"bic": knownvalue.Null(),
7025+
"content_converter": knownvalue.Null(),
70147026
"disable_apps": knownvalue.Null(),
70157027
"disable_rum": knownvalue.Null(),
70167028
"disable_zaraz": knownvalue.Null(),

internal/services/ruleset/schema.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,16 @@ func ResourceSchema(ctx context.Context) schema.Schema {
793793
),
794794
},
795795
},
796+
"content_converter": schema.BoolAttribute{
797+
Description: "Whether to enable content conversion (e.g., HTML to Markdown).",
798+
Optional: true,
799+
Validators: []validator.Bool{
800+
customvalidator.RequiresOtherStringAttributeToBe(
801+
path.MatchRelative().AtParent().AtParent().AtName("action"),
802+
"set_config",
803+
),
804+
},
805+
},
796806
"disable_apps": schema.BoolAttribute{
797807
Description: "Whether to disable Cloudflare Apps.",
798808
Optional: true,

internal/services/ruleset/testdata/TestAccCloudflareRuleset_SetConfigRules/2.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ resource "cloudflare_ruleset" "my_ruleset" {
1313
automatic_https_rewrites = true
1414
autominify = {}
1515
bic = false
16+
content_converter = true
1617
disable_apps = true
1718
disable_rum = true
1819
disable_zaraz = true

internal/services/ruleset/testdata/TestAccCloudflareRuleset_SetConfigRules/3.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ resource "cloudflare_ruleset" "my_ruleset" {
1616
js = false
1717
}
1818
bic = true
19+
content_converter = true
1920
email_obfuscation = true
2021
fonts = true
2122
hotlink_protection = true

0 commit comments

Comments
 (0)