]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/commitdiff
`status` and `uptime` params is calculated
authorAndrew N Golovkov <andrew@callstats.io>
Tue, 16 Jan 2018 14:11:43 +0000 (16:11 +0200)
committerAndrew N Golovkov <andrew@callstats.io>
Wed, 17 Jan 2018 12:59:24 +0000 (14:59 +0200)
statuscake/resource_statuscaketest.go
statuscake/resource_statuscaketest_test.go

index 27cf9bf18cf1eb422d026e5c1ef7f27c51df96c6..50e16f9ffb145418e201c496cfab8db73bd99f81 100644 (file)
@@ -88,12 +88,12 @@ func resourceStatusCakeTest() *schema.Resource {
 
                        "status": {
                                Type:     schema.TypeString,
-                               Optional: true,
+                               Computed: true,
                        },
 
                        "uptime": {
                                Type:     schema.TypeFloat,
-                               Optional: true,
+                               Computed: true,
                        },
 
                        "node_locations": {
@@ -240,6 +240,8 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error {
        }
 
        d.Set("test_id", fmt.Sprintf("%d", response.TestID))
+       d.Set("status", response.Status)
+       d.Set("uptime", fmt.Sprintf("%.3f", response.Uptime))
        d.SetId(fmt.Sprintf("%d", response.TestID))
 
        return ReadTest(d, meta)
@@ -365,12 +367,6 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
        if v, ok := d.GetOk("user_agent"); ok {
                test.UserAgent = v.(string)
        }
-       if v, ok := d.GetOk("status"); ok {
-               test.Status = v.(string)
-       }
-       if v, ok := d.GetOk("uptime"); ok {
-               test.Uptime = v.(float64)
-       }
        if v, ok := d.GetOk("node_locations"); ok {
                test.NodeLocations = v.([]string)
        }
index b39d23cd0c58011816fbcecbd57f00a085f86a64..99acd0409281413e889e8270ca74730ab585456a 100644 (file)
@@ -171,10 +171,6 @@ func testAccTestCheckAttributes(rn string, test *statuscake.Test) resource.TestC
                                err = check(key, value, test.CustomHeader)
                        case "user_agent":
                                err = check(key, value, test.UserAgent)
-                       case "status":
-                               err = check(key, value, test.Status)
-                       case "uptime":
-                               err = check(key, value, strconv.FormatFloat(test.Uptime, 'f', -1, 64))
                        case "node_locations":
                                for _, tv := range test.NodeLocations {
                                        err = check(key, value, tv)
@@ -260,8 +256,6 @@ resource "statuscake_test" "google" {
        trigger_rate = 20
        custom_header = "{ \"Content-Type\": \"application/x-www-form-urlencoded\" }"
        user_agent = "string9988"
-       status = "string22117"
-       uptime = 3498.27
        node_locations = [ "string16045", "string19741", "string12122" ]
        ping_url = "string8410"
        basic_user = "string27052"