Skip to content

Commit 2ada740

Browse files
Merge branch 'next' into ruleset/rules-actions
2 parents f15aefd + a7b748f commit 2ada740

File tree

7 files changed

+74
-14
lines changed

7 files changed

+74
-14
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1793
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1f0c1fa90a0cdf9565414a74668e7cd9001db95af2f7f2e074889d41cc8da502.yml
3-
openapi_spec_hash: d078f398289bf170b9ce9d433bb58187
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d40243b4192f76fb833e15210572c738f55fa868103caf6995ad710b15bae202.yml
3+
openapi_spec_hash: 37b7cfe9904bfd4e13a5b269266df631
44
config_hash: de4c81cee29cd7dd907279e8916b334f

internal/apiform/tag.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ type parsedStructTag struct {
1818
// otherwise this flag will have no effect
1919
// NOTE: won't work if update behavior is 'patch'
2020
forceEncode bool
21+
// Don't skip this value, even if it's computed (no-op for computed optional fields)
22+
// If encodeStateForUnknown is set on a computed field, this flag should also be set;
23+
// otherwise this flag will have no effect
24+
// NOTE: won't work if update behavior is 'patch'
2125
}
2226

2327
func parseFormStructTag(field reflect.StructField) (tag parsedStructTag, ok bool) {

internal/services/zero_trust_gateway_policy/data_source_schema.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ func DataSourceSchema(ctx context.Context) schema.Schema {
7070
Computed: true,
7171
},
7272
"device_posture": schema.StringAttribute{
73-
Description: "The wirefilter expression used for device posture check matching.",
73+
Description: "The wirefilter expression used for device posture check matching. The API automatically formats and sanitizes this expression. This returns a normalized version that may differ from your input and cause Terraform state drift.",
7474
Computed: true,
7575
},
7676
"enabled": schema.BoolAttribute{
7777
Description: "True if the rule is enabled.",
7878
Computed: true,
7979
},
8080
"identity": schema.StringAttribute{
81-
Description: "The wirefilter expression used for identity matching.",
81+
Description: "The wirefilter expression used for identity matching. The API automatically formats and sanitizes this expression. This returns a normalized version that may differ from your input and cause Terraform state drift.",
8282
Computed: true,
8383
},
8484
"name": schema.StringAttribute{
@@ -102,7 +102,7 @@ func DataSourceSchema(ctx context.Context) schema.Schema {
102102
Computed: true,
103103
},
104104
"traffic": schema.StringAttribute{
105-
Description: "The wirefilter expression used for traffic matching.",
105+
Description: "The wirefilter expression used for traffic matching. The API automatically formats and sanitizes this expression. This returns a normalized version that may differ from your input and cause Terraform state drift.",
106106
Computed: true,
107107
},
108108
"updated_at": schema.StringAttribute{
@@ -306,7 +306,7 @@ func DataSourceSchema(ctx context.Context) schema.Schema {
306306
CustomType: customfield.NewNestedObjectType[ZeroTrustGatewayPolicyRuleSettingsCheckSessionDataSourceModel](ctx),
307307
Attributes: map[string]schema.Attribute{
308308
"duration": schema.StringAttribute{
309-
Description: "Configure how fresh the session needs to be to be considered valid.",
309+
Description: "Configure how fresh the session needs to be to be considered valid. The API automatically formats and sanitizes this expression. This returns a normalized version that may differ from your input and cause Terraform state drift.",
310310
Computed: true,
311311
},
312312
"enforce": schema.BoolAttribute{

internal/services/zero_trust_gateway_policy/list_data_source_schema.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func ListDataSourceSchema(ctx context.Context) schema.Schema {
9191
Computed: true,
9292
},
9393
"traffic": schema.StringAttribute{
94-
Description: "The wirefilter expression used for traffic matching.",
94+
Description: "The wirefilter expression used for traffic matching. The API automatically formats and sanitizes this expression. This returns a normalized version that may differ from your input and cause Terraform state drift.",
9595
Computed: true,
9696
},
9797
"id": schema.StringAttribute{
@@ -112,7 +112,7 @@ func ListDataSourceSchema(ctx context.Context) schema.Schema {
112112
Computed: true,
113113
},
114114
"device_posture": schema.StringAttribute{
115-
Description: "The wirefilter expression used for device posture check matching.",
115+
Description: "The wirefilter expression used for device posture check matching. The API automatically formats and sanitizes this expression. This returns a normalized version that may differ from your input and cause Terraform state drift.",
116116
Computed: true,
117117
},
118118
"expiration": schema.SingleNestedAttribute{
@@ -139,7 +139,7 @@ func ListDataSourceSchema(ctx context.Context) schema.Schema {
139139
},
140140
},
141141
"identity": schema.StringAttribute{
142-
Description: "The wirefilter expression used for identity matching.",
142+
Description: "The wirefilter expression used for identity matching. The API automatically formats and sanitizes this expression. This returns a normalized version that may differ from your input and cause Terraform state drift.",
143143
Computed: true,
144144
},
145145
"not_sharable": schema.BoolAttribute{
@@ -299,7 +299,7 @@ func ListDataSourceSchema(ctx context.Context) schema.Schema {
299299
CustomType: customfield.NewNestedObjectType[ZeroTrustGatewayPoliciesRuleSettingsCheckSessionDataSourceModel](ctx),
300300
Attributes: map[string]schema.Attribute{
301301
"duration": schema.StringAttribute{
302-
Description: "Configure how fresh the session needs to be to be considered valid.",
302+
Description: "Configure how fresh the session needs to be to be considered valid. The API automatically formats and sanitizes this expression. This returns a normalized version that may differ from your input and cause Terraform state drift.",
303303
Computed: true,
304304
},
305305
"enforce": schema.BoolAttribute{

internal/services/zero_trust_gateway_policy/schema.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func ResourceSchema(ctx context.Context) schema.Schema {
8787
ElementType: types.StringType,
8888
},
8989
"device_posture": schema.StringAttribute{
90-
Description: "The wirefilter expression used for device posture check matching.",
90+
Description: "The wirefilter expression used for device posture check matching. The API automatically formats and sanitizes this expression. This returns a normalized version that may differ from your input and cause Terraform state drift.",
9191
Computed: true,
9292
Optional: true,
9393
Default: stringdefault.StaticString(""),
@@ -99,13 +99,13 @@ func ResourceSchema(ctx context.Context) schema.Schema {
9999
Default: booldefault.StaticBool(false),
100100
},
101101
"identity": schema.StringAttribute{
102-
Description: "The wirefilter expression used for identity matching.",
102+
Description: "The wirefilter expression used for identity matching. The API automatically formats and sanitizes this expression. This returns a normalized version that may differ from your input and cause Terraform state drift.",
103103
Computed: true,
104104
Optional: true,
105105
Default: stringdefault.StaticString(""),
106106
},
107107
"traffic": schema.StringAttribute{
108-
Description: "The wirefilter expression used for traffic matching.",
108+
Description: "The wirefilter expression used for traffic matching. The API automatically formats and sanitizes this expression. This returns a normalized version that may differ from your input and cause Terraform state drift.",
109109
Computed: true,
110110
Optional: true,
111111
Default: stringdefault.StaticString(""),
@@ -294,7 +294,7 @@ func ResourceSchema(ctx context.Context) schema.Schema {
294294
Optional: true,
295295
Attributes: map[string]schema.Attribute{
296296
"duration": schema.StringAttribute{
297-
Description: "Configure how fresh the session needs to be to be considered valid.",
297+
Description: "Configure how fresh the session needs to be to be considered valid. The API automatically formats and sanitizes this expression. This returns a normalized version that may differ from your input and cause Terraform state drift.",
298298
Optional: true,
299299
},
300300
"enforce": schema.BoolAttribute{

internal/services/zone_setting/resource_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,53 @@ func TestAccCloudflareZoneSetting_Ciphers(t *testing.T) {
256256
})
257257
}
258258

259+
// Regression test for https://github.com/cloudflare/terraform-provider-cloudflare/issues/5795
260+
// where certain zone settings have inconsistent "editable" values between plan and apply
261+
func TestAccCloudflareZoneSetting_EditableInconsistency(t *testing.T) {
262+
zoneID := os.Getenv("CLOUDFLARE_ZONE_ID")
263+
264+
// Test the problematic settings that have editable inconsistency issues
265+
problematicSettings := []struct {
266+
settingID string
267+
value string
268+
}{
269+
{"advanced_ddos", "on"},
270+
{"http2", "on"},
271+
{"long_lived_grpc", "on"},
272+
{"origin_error_page_pass_thru", "on"},
273+
{"prefetch_preload", "on"},
274+
{"proxy_read_timeout", "300"},
275+
{"response_buffering", "on"},
276+
{"sort_query_string_for_cache", "on"},
277+
{"true_client_ip_header", "on"},
278+
}
279+
280+
for _, setting := range problematicSettings {
281+
t.Run(setting.settingID, func(t *testing.T) {
282+
rnd := utils.GenerateRandomResourceName()
283+
resourceName := fmt.Sprintf("cloudflare_zone_setting.%s", rnd)
284+
285+
valueCheck := knownvalue.StringExact(setting.value)
286+
287+
resource.Test(t, resource.TestCase{
288+
PreCheck: func() { acctest.TestAccPreCheck(t) },
289+
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
290+
CheckDestroy: testAccCheckCloudflareZoneSettingDestroy,
291+
Steps: []resource.TestStep{
292+
{
293+
Config: testCloudflareZoneSettingEditableInconsistency(rnd, zoneID, setting.settingID, setting.value),
294+
ConfigStateChecks: []statecheck.StateCheck{
295+
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New(consts.ZoneIDSchemaKey), knownvalue.StringExact(zoneID)),
296+
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("setting_id"), knownvalue.StringExact(setting.settingID)),
297+
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("value"), valueCheck),
298+
},
299+
},
300+
},
301+
})
302+
})
303+
}
304+
}
305+
259306
func testCloudflareZoneSettingConfigOnOff(resourceID, zoneID string) string {
260307
return acctest.LoadTestCase("on_off.tf", resourceID, zoneID)
261308
}
@@ -288,6 +335,10 @@ func testCloudflareZoneSettingConfigCiphers(resourceID, zoneID string) string {
288335
return acctest.LoadTestCase("ciphers.tf", resourceID, zoneID)
289336
}
290337

338+
func testCloudflareZoneSettingEditableInconsistency(resourceID, zoneID, settingID, value string) string {
339+
return acctest.LoadTestCase("editable_inconsistency.tf", resourceID, zoneID, settingID, value)
340+
}
341+
291342
func testAccCheckCloudflareZoneSettingDestroy(s *terraform.State) error {
292343
client := acctest.SharedClient()
293344

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
resource "cloudflare_zone_setting" "%[1]s" {
2+
zone_id = "%[2]s"
3+
setting_id = "%[3]s"
4+
value = "%[4]s"
5+
}

0 commit comments

Comments
 (0)