From 1f520bcd3b46c914ee4273b50c55c822876d1a98 Mon Sep 17 00:00:00 2001 From: Marcin Suterski Date: Wed, 18 Jan 2017 08:43:09 -0500 Subject: [PATCH] Add request_condition to backend definistion (#11238) --- builtin/providers/fastly/resource_fastly_service_v1.go | 8 ++++++++ .../providers/fastly/resource_fastly_service_v1_test.go | 2 ++ .../docs/providers/fastly/r/service_v1.html.markdown | 1 + 3 files changed, 11 insertions(+) diff --git a/builtin/providers/fastly/resource_fastly_service_v1.go b/builtin/providers/fastly/resource_fastly_service_v1.go index afa104aca68b..13e397ebc446 100644 --- a/builtin/providers/fastly/resource_fastly_service_v1.go +++ b/builtin/providers/fastly/resource_fastly_service_v1.go @@ -166,6 +166,12 @@ func resourceServiceV1() *schema.Resource { Default: 80, Description: "The port number Backend responds on. Default 80", }, + "request_condition": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "", + Description: "Condition, which if met, will select this backend during a request.", + }, "shield": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -833,6 +839,7 @@ func resourceServiceV1Update(d *schema.ResourceData, meta interface{}) error { FirstByteTimeout: uint(df["first_byte_timeout"].(int)), MaxConn: uint(df["max_conn"].(int)), Weight: uint(df["weight"].(int)), + RequestCondition: df["request_condition"].(string), } log.Printf("[DEBUG] Create Backend Opts: %#v", opts) @@ -1510,6 +1517,7 @@ func flattenBackends(backendList []*gofastly.Backend) []map[string]interface{} { "ssl_check_cert": gofastly.CBool(b.SSLCheckCert), "ssl_hostname": b.SSLHostname, "weight": int(b.Weight), + "request_condition": b.RequestCondition, } bl = append(bl, nb) diff --git a/builtin/providers/fastly/resource_fastly_service_v1_test.go b/builtin/providers/fastly/resource_fastly_service_v1_test.go index 68cc6faae714..0dba2f8a64ba 100644 --- a/builtin/providers/fastly/resource_fastly_service_v1_test.go +++ b/builtin/providers/fastly/resource_fastly_service_v1_test.go @@ -70,6 +70,7 @@ func TestResourceFastlyFlattenBackend(t *testing.T) { ErrorThreshold: uint(0), FirstByteTimeout: uint(15000), MaxConn: uint(200), + RequestCondition: "", SSLCheckCert: true, SSLHostname: "", Shield: "New York", @@ -87,6 +88,7 @@ func TestResourceFastlyFlattenBackend(t *testing.T) { "error_threshold": 0, "first_byte_timeout": 15000, "max_conn": 200, + "request_condition": "", "ssl_check_cert": gofastly.CBool(true), "ssl_hostname": "", "shield": "New York", diff --git a/website/source/docs/providers/fastly/r/service_v1.html.markdown b/website/source/docs/providers/fastly/r/service_v1.html.markdown index 78934ea3a59c..bad6022911e6 100644 --- a/website/source/docs/providers/fastly/r/service_v1.html.markdown +++ b/website/source/docs/providers/fastly/r/service_v1.html.markdown @@ -174,6 +174,7 @@ Default `1000` * `max_conn` - (Optional) Maximum number of connections for this Backend. Default `200`. * `port` - (Optional) The port number on which the Backend responds. Default `80`. +* `request_condition` - (Optional, string) Condition, which if met, will select this backend during a request. * `ssl_check_cert` - (Optional) Be strict about checking SSL certs. Default `true`. * `ssl_hostname` - (Optional) Used for both SNI during the TLS handshake and to validate the cert. * `shield` - (Optional) The POP of the shield designated to reduce inbound load.