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

fix(request_settings): don't send empty string for request_condition #722

Merged
merged 1 commit into from
Jun 30, 2023
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 docs/resources/service_vcl.md
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ Optional:
- `geo_headers` (Boolean, Deprecated) Injects Fastly-Geo-Country, Fastly-Geo-City, and Fastly-Geo-Region into the request headers
- `hash_keys` (String) Comma separated list of varnish request object fields that should be in the hash key
- `max_stale_age` (Number) How old an object is allowed to be to serve `stale-if-error` or `stale-while-revalidate`, in seconds
- `request_condition` (String) Name of already defined `condition` to determine if this request setting should be applied
- `request_condition` (String) Name of already defined `condition` to determine if this request setting should be applied (should be unique across multiple instances of `request_setting`)
- `timer_support` (Boolean) Injects the X-Timer info into the request for viewing origin fetch durations
- `xff` (String) X-Forwarded-For, should be `clear`, `leave`, `append`, `append_all`, or `overwrite`. Default `append`

Expand Down
25 changes: 14 additions & 11 deletions fastly/block_fastly_service_requestsetting.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (h *RequestSettingServiceAttributeHandler) GetSchema() *schema.Schema {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: "Name of already defined `condition` to determine if this request setting should be applied",
Description: "Name of already defined `condition` to determine if this request setting should be applied (should be unique across multiple instances of `request_setting`)",
},
"timer_support": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -270,16 +270,19 @@ func flattenRequestSettings(remoteState []*gofastly.RequestSetting) []map[string
func buildRequestSetting(requestSettingMap any) (*gofastly.CreateRequestSettingInput, error) {
resource := requestSettingMap.(map[string]any)
opts := gofastly.CreateRequestSettingInput{
Name: gofastly.String(resource["name"].(string)),
MaxStaleAge: gofastly.Int(resource["max_stale_age"].(int)),
ForceMiss: gofastly.CBool(resource["force_miss"].(bool)),
ForceSSL: gofastly.CBool(resource["force_ssl"].(bool)),
BypassBusyWait: gofastly.CBool(resource["bypass_busy_wait"].(bool)),
HashKeys: gofastly.String(resource["hash_keys"].(string)),
TimerSupport: gofastly.CBool(resource["timer_support"].(bool)),
GeoHeaders: gofastly.CBool(resource["geo_headers"].(bool)),
DefaultHost: gofastly.String(resource["default_host"].(string)),
RequestCondition: gofastly.String(resource["request_condition"].(string)),
Name: gofastly.String(resource["name"].(string)),
MaxStaleAge: gofastly.Int(resource["max_stale_age"].(int)),
ForceMiss: gofastly.CBool(resource["force_miss"].(bool)),
ForceSSL: gofastly.CBool(resource["force_ssl"].(bool)),
BypassBusyWait: gofastly.CBool(resource["bypass_busy_wait"].(bool)),
HashKeys: gofastly.String(resource["hash_keys"].(string)),
TimerSupport: gofastly.CBool(resource["timer_support"].(bool)),
GeoHeaders: gofastly.CBool(resource["geo_headers"].(bool)),
DefaultHost: gofastly.String(resource["default_host"].(string)),
}

if v := resource["request_condition"].(string); v != "" {
opts.RequestCondition = gofastly.String(v)
}

act := strings.ToLower(resource["action"].(string))
Expand Down