Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zone_settings_overrid: Remap 0rtt attribute name to zero_rtt #557

Merged
merged 1 commit into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
**Improvements:**

* `resource/cloudflare_zone_settings_override`: Add `non_identity` to allowed `decision` schema ([#541](https://github.com/terraform-providers/terraform-provider-cloudflare/issues/541))
* `resource/cloudflare_zone_settings_override`: Add support for `0rtt` and `http3` settings ([#542](https://github.com/terraform-providers/terraform-provider-cloudflare/issues/542))
* `resource/cloudflare_zone_settings_override`: Add support for `zero_rtt` and `http3` settings ([#542](https://github.com/terraform-providers/terraform-provider-cloudflare/issues/542))
* `resource/cloudflare_load_balancer_monitor`: Allow empty string for `expected_body` ([#539](https://github.com/terraform-providers/terraform-provider-cloudflare/issues/539))
* `resource/cloudflare_worker_script`: Add support for Worker KV Namespace Bindings ([#544](https://github.com/terraform-providers/terraform-provider-cloudflare/issues/544))
* `data_source/waf_rules`, `resource/cloudflare_waf_rule`, Support allowed modes for WAF Rules ([#550](https://github.com/terraform-providers/terraform-provider-cloudflare/issues/550))
Expand Down
11 changes: 10 additions & 1 deletion cloudflare/resource_cloudflare_zone_settings_override.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ var resourceCloudflareZoneSettingsSchema = map[string]*schema.Schema{
Computed: true,
},

"0rtt": {
"zero_rtt": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"on", "off"}, false),
Optional: true,
Expand Down Expand Up @@ -585,6 +585,10 @@ func resourceCloudflareZoneSettingsOverrideRead(d *schema.ResourceData, meta int
func flattenZoneSettings(d *schema.ResourceData, settings []cloudflare.ZoneSetting, flattenAll bool) []map[string]interface{} {
cfg := map[string]interface{}{}
for _, s := range settings {
if s.ID == "0rtt" { // NOTE: 0rtt is an invalid attribute in HCLs grammar. Remap to `zero_rtt`
s.ID = "zero_rtt"
}

if !settingInSchema(s.ID) {
log.Printf("[WARN] Value not in schema returned from API zone settings (is it new?) - %q : %#v", s.ID, s.Value)
continue
Expand Down Expand Up @@ -690,6 +694,11 @@ func expandOverriddenZoneSettings(d *schema.ResourceData, settingsKey string, re
return zoneSettings, err
}

// Remap zero_rtt key back to Cloudflare's setting name, 0rtt
if k == "zero_rtt" {
k = "0rtt"
}

if zoneSettingValue != nil {
newZoneSetting := cloudflare.ZoneSetting{
ID: k,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ func TestAccCloudflareZoneSettingsOverride_Full(t *testing.T) {
name, "settings.0.security_level", "high"),
resource.TestCheckResourceAttr(
name, "settings.0.h2_prioritization", "on"),
resource.TestCheckResourceAttr(
name, "settings.0.zero_rtt", "off"),
),
},
},
Expand Down Expand Up @@ -230,6 +232,7 @@ resource "cloudflare_zone_settings_override" "test" {
security_header {
enabled = true
}
zero_rtt = "off"
}
}`, zoneID)
}
2 changes: 1 addition & 1 deletion website/docs/r/zone_settings_override.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ These can be specified as "on" or "off" string. Similar to boolean values, but h
* `waf` (default: `off`)
* `webp` (default: `off`). Note that the value specified will be ignored unless `polish` is turned on (i.e. is "lossless" or "lossy")
* `websockets` (default: `off`)
* `0rtt` (default: `off`)
* `zero_rtt` (default: `off`)

### String Values

Expand Down