]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/commitdiff
Add support for StatusCake trigger rate
authorRui Gonçalves <ruippeixotog@gmail.com>
Tue, 4 Apr 2017 15:58:11 +0000 (16:58 +0100)
committerstack72 <public@paulstack.co.uk>
Mon, 10 Apr 2017 12:38:26 +0000 (15:38 +0300)
resource_statuscaketest.go
resource_statuscaketest_test.go

index 4912758d4049fb39dbf9e5fed196e36ea12cfdb5..101ee83582caa4b409ae71f237ebda0ee8ed8769 100644 (file)
@@ -70,6 +70,12 @@ func resourceStatusCakeTest() *schema.Resource {
                                Type:     schema.TypeInt,
                                Optional: true,
                        },
+
+                       "trigger_rate": {
+                               Type:     schema.TypeInt,
+                               Optional: true,
+                               Default:  5,
+                       },
                },
        }
 }
@@ -87,6 +93,7 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error {
                ContactID:    d.Get("contact_id").(int),
                Confirmation: d.Get("confirmations").(int),
                Port:         d.Get("port").(int),
+               TriggerRate:  d.Get("trigger_rate").(int),
        }
 
        log.Printf("[DEBUG] Creating new StatusCake Test: %s", d.Get("website_name").(string))
@@ -151,6 +158,7 @@ func ReadTest(d *schema.ResourceData, meta interface{}) error {
        d.Set("contact_id", testResp.ContactID)
        d.Set("confirmations", testResp.Confirmation)
        d.Set("port", testResp.Port)
+       d.Set("trigger_rate", testResp.TriggerRate)
 
        return nil
 }
@@ -193,6 +201,9 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
        if v, ok := d.GetOk("port"); ok {
                test.Port = v.(int)
        }
+       if v, ok := d.GetOk("trigger_rate"); ok {
+               test.TriggerRate = v.(int)
+       }
 
        defaultStatusCodes := "204, 205, 206, 303, 400, 401, 403, 404, 405, 406, " +
                "408, 410, 413, 444, 429, 494, 495, 496, 499, 500, 501, 502, 503, " +
index d38dc1c33e44ee17376282845856ba8fa7893462..f07fcc55a3c30c9d5c9bf680a6d2b48f5d2f2ddf 100644 (file)
@@ -73,6 +73,7 @@ func TestAccStatusCake_withUpdate(t *testing.T) {
                                        resource.TestCheckResourceAttr("statuscake_test.google", "timeout", "40"),
                                        resource.TestCheckResourceAttr("statuscake_test.google", "contact_id", "0"),
                                        resource.TestCheckResourceAttr("statuscake_test.google", "confirmations", "0"),
+                                       resource.TestCheckResourceAttr("statuscake_test.google", "trigger_rate", "20"),
                                ),
                        },
                },
@@ -139,6 +140,8 @@ func testAccTestCheckAttributes(rn string, test *statuscake.Test) resource.TestC
                                err = check(key, value, strconv.Itoa(test.ContactID))
                        case "confirmations":
                                err = check(key, value, strconv.Itoa(test.Confirmation))
+                       case "trigger_rate":
+                               err = check(key, value, strconv.Itoa(test.TriggerRate))
                        }
 
                        if err != nil {
@@ -170,6 +173,7 @@ resource "statuscake_test" "google" {
        timeout = 10
        contact_id = 43402
        confirmations = 1
+       trigger_rate = 10
 }
 `
 
@@ -180,6 +184,7 @@ resource "statuscake_test" "google" {
        test_type = "HTTP"
        check_rate = 500
        paused = true
+       trigger_rate = 20
 }
 `