Skip to content

Commit

Permalink
Add idle_timeout to mlb_policy_v1 (Data Source)
Browse files Browse the repository at this point in the history
  • Loading branch information
hico-horiuchi committed Feb 19, 2024
1 parent ec8820b commit 969445f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ecl/data_source_ecl_mlb_policy_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ func dataSourceMLBPolicyV1() *schema.Resource {
Optional: true,
Computed: true,
},
"idle_timeout": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"sorry_page_url": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -136,6 +141,10 @@ func dataSourceMLBPolicyV1Read(d *schema.ResourceData, meta interface{}) error {
listOpts.Persistence = v.(string)
}

if v, ok := d.GetOk("idle_timeout"); ok {
listOpts.IDleTimeout = v.(int)

Check failure on line 145 in ecl/data_source_ecl_mlb_policy_v1.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, 0.12.x)

listOpts.IDleTimeout undefined (type policies.ListOpts has no field or method IDleTimeout)

Check failure on line 145 in ecl/data_source_ecl_mlb_policy_v1.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, 0.12.x)

listOpts.IDleTimeout undefined (type policies.ListOpts has no field or method IDleTimeout)

Check failure on line 145 in ecl/data_source_ecl_mlb_policy_v1.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, 1.1.x)

listOpts.IDleTimeout undefined (type policies.ListOpts has no field or method IDleTimeout)

Check failure on line 145 in ecl/data_source_ecl_mlb_policy_v1.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, 1.1.x)

listOpts.IDleTimeout undefined (type policies.ListOpts has no field or method IDleTimeout)

Check failure on line 145 in ecl/data_source_ecl_mlb_policy_v1.go

View workflow job for this annotation

GitHub Actions / test (1.18.x, 0.12.x)

listOpts.IDleTimeout undefined (type policies.ListOpts has no field or method IDleTimeout)

Check failure on line 145 in ecl/data_source_ecl_mlb_policy_v1.go

View workflow job for this annotation

GitHub Actions / test (1.18.x, 1.1.x)

listOpts.IDleTimeout undefined (type policies.ListOpts has no field or method IDleTimeout)
}

if v, ok := d.GetOk("sorry_page_url"); ok {
listOpts.SorryPageUrl = v.(string)
}
Expand Down Expand Up @@ -212,6 +221,7 @@ func dataSourceMLBPolicyV1Read(d *schema.ResourceData, meta interface{}) error {
d.Set("tenant_id", policy.TenantID)
d.Set("algorithm", policy.Algorithm)
d.Set("persistence", policy.Persistence)
d.Set("idle_timeout", policy.IDleTimeout)

Check failure on line 224 in ecl/data_source_ecl_mlb_policy_v1.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, 0.12.x)

policy.IDleTimeout undefined (type policies.Policy has no field or method IDleTimeout)

Check failure on line 224 in ecl/data_source_ecl_mlb_policy_v1.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, 0.12.x)

policy.IDleTimeout undefined (type policies.Policy has no field or method IDleTimeout)

Check failure on line 224 in ecl/data_source_ecl_mlb_policy_v1.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, 1.1.x)

policy.IDleTimeout undefined (type policies.Policy has no field or method IDleTimeout)

Check failure on line 224 in ecl/data_source_ecl_mlb_policy_v1.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, 1.1.x)

policy.IDleTimeout undefined (type policies.Policy has no field or method IDleTimeout)

Check failure on line 224 in ecl/data_source_ecl_mlb_policy_v1.go

View workflow job for this annotation

GitHub Actions / test (1.18.x, 0.12.x)

policy.IDleTimeout undefined (type policies.Policy has no field or method IDleTimeout)

Check failure on line 224 in ecl/data_source_ecl_mlb_policy_v1.go

View workflow job for this annotation

GitHub Actions / test (1.18.x, 1.1.x)

policy.IDleTimeout undefined (type policies.Policy has no field or method IDleTimeout)
d.Set("sorry_page_url", policy.SorryPageUrl)
d.Set("source_nat", policy.SourceNat)
d.Set("certificate_id", policy.CertificateID)
Expand Down
2 changes: 2 additions & 0 deletions ecl/data_source_ecl_mlb_policy_v1_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestMockedAccMLBV1PolicyDataSource(t *testing.T) {
resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
Expand Down Expand Up @@ -83,6 +84,7 @@ response:
"tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
"algorithm": "round-robin",
"persistence": "cookie",
"idle_timeout": 600,
"sorry_page_url": "https://example.com/sorry",
"source_nat": "enable",
"certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
Expand Down
8 changes: 8 additions & 0 deletions website/docs/d/mlb_policy_v1.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ data "ecl_mlb_policy_v1" "policy" {
* `"none"`
* `"source-ip"`
* `"cookie"`
* `idle_timeout` - (Optional) The duration (in seconds) during which a session is allowed to remain inactive
* `sorry_page_url` - (Optional) URL of the sorry page to which accesses are redirected if all members in the target group are down
* `source_nat` - (Optional) Source NAT setting of the policy
* Must be one of these values:
Expand Down Expand Up @@ -106,6 +107,13 @@ In addition, the following attributes are exported:
* `algorithm` - Load balancing algorithm (method) of the policy
* `persistence` - Persistence setting of the policy
* If `listener.protocol` is `"http"` or `"https"`, `"cookie"` is available
* `idle_timeout` - The duration (in seconds) during which a session is allowed to remain inactive
* There may be a time difference up to 60 seconds, between the set value and the actual timeout
* If `listener.protocol` is `"tcp"` or `"udp"`
* Default value is 120
* If `listener.protocol` is `"http"` or `"https"`
* Default value is 600
* On session timeout, the load balancer sends TCP RST packets to both the client and the real server
* `sorry_page_url` - URL of the sorry page to which accesses are redirected if all members in the target group are down
* If protocol is not `"http"` or `"https"`, returns `""`
* `source_nat` - Source NAT setting of the policy
Expand Down

0 comments on commit 969445f

Please sign in to comment.