]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/commitdiff
Add support for StatusCake confirmation servers (#11179)
authorSam Crang <sam.crang@gmail.com>
Fri, 13 Jan 2017 11:35:15 +0000 (11:35 +0000)
committerPaul Stack <public@paulstack.co.uk>
Fri, 13 Jan 2017 11:35:15 +0000 (11:35 +0000)
* Add support for StatusCake confirmation servers

* Add documentation for new StatusCake confirmations argument

resource_statuscaketest.go
resource_statuscaketest_test.go

index 08ace9785b256e63651afeb97a6ce46ab8e35b00..6c340d86978e89970aea5049be5f6122f6d4c26a 100644 (file)
@@ -57,6 +57,10 @@ func resourceStatusCakeTest() *schema.Resource {
                                Type:     schema.TypeInt,
                                Optional: true,
                        },
+                       "confirmations": &schema.Schema{
+                               Type:     schema.TypeInt,
+                               Optional: true,
+                       },
                },
        }
 }
@@ -65,13 +69,14 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error {
        client := meta.(*statuscake.Client)
 
        newTest := &statuscake.Test{
-               WebsiteName: d.Get("website_name").(string),
-               WebsiteURL:  d.Get("website_url").(string),
-               CheckRate:   d.Get("check_rate").(int),
-               TestType:    d.Get("test_type").(string),
-               Paused:      d.Get("paused").(bool),
-               Timeout:     d.Get("timeout").(int),
-               ContactID:   d.Get("contact_id").(int),
+               WebsiteName:  d.Get("website_name").(string),
+               WebsiteURL:   d.Get("website_url").(string),
+               CheckRate:    d.Get("check_rate").(int),
+               TestType:     d.Get("test_type").(string),
+               Paused:       d.Get("paused").(bool),
+               Timeout:      d.Get("timeout").(int),
+               ContactID:    d.Get("contact_id").(int),
+               Confirmation: d.Get("confirmations").(int),
        }
 
        log.Printf("[DEBUG] Creating new StatusCake Test: %s", d.Get("website_name").(string))
@@ -134,6 +139,7 @@ func ReadTest(d *schema.ResourceData, meta interface{}) error {
        d.Set("paused", testResp.Paused)
        d.Set("timeout", testResp.Timeout)
        d.Set("contact_id", testResp.ContactID)
+       d.Set("confirmations", testResp.Confirmation)
 
        return nil
 }
@@ -167,5 +173,8 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
        if v, ok := d.GetOk("contact_id"); ok {
                test.ContactID = v.(int)
        }
+       if v, ok := d.GetOk("confirmations"); ok {
+               test.Confirmation = v.(int)
+       }
        return test
 }
index de302542d4a06504b9b16a019bf5ca60d44b1392..ac3cc92be15c863883ff96bb16bfbc3ca43c75ce 100644 (file)
@@ -52,6 +52,7 @@ func TestAccStatusCake_withUpdate(t *testing.T) {
                                        resource.TestCheckResourceAttr("statuscake_test.google", "check_rate", "500"),
                                        resource.TestCheckResourceAttr("statuscake_test.google", "paused", "true"),
                                        resource.TestCheckResourceAttr("statuscake_test.google", "contact_id", "0"),
+                                       resource.TestCheckResourceAttr("statuscake_test.google", "confirmations", "0"),
                                ),
                        },
                },
@@ -116,6 +117,8 @@ func testAccTestCheckAttributes(rn string, test *statuscake.Test) resource.TestC
                                err = check(key, value, strconv.Itoa(test.Timeout))
                        case "contact_id":
                                err = check(key, value, strconv.Itoa(test.ContactID))
+                       case "confirmations":
+                               err = check(key, value, strconv.Itoa(test.Confirmation))
                        }
 
                        if err != nil {
@@ -145,6 +148,7 @@ resource "statuscake_test" "google" {
        test_type = "HTTP"
        check_rate = 300
        contact_id = 12345
+       confirmations = 1
 }
 `