aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--statuscake/resource_statuscaketest.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/statuscake/resource_statuscaketest.go b/statuscake/resource_statuscaketest.go
index 50e16f9..187f711 100644
--- a/statuscake/resource_statuscaketest.go
+++ b/statuscake/resource_statuscaketest.go
@@ -10,6 +10,16 @@ import (
10 "github.com/hashicorp/terraform/helper/schema" 10 "github.com/hashicorp/terraform/helper/schema"
11) 11)
12 12
13func castInterfaceToSliceStrings(in interface{}) []string {
14 input := in.([]interface{})
15 res := make([]string, len(input))
16
17 for i, element := range input {
18 res[i] = element.(string)
19 }
20 return res
21}
22
13func resourceStatusCakeTest() *schema.Resource { 23func resourceStatusCakeTest() *schema.Resource {
14 return &schema.Resource{ 24 return &schema.Resource{
15 Create: CreateTest, 25 Create: CreateTest,
@@ -212,7 +222,7 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error {
212 UserAgent: d.Get("user_agent").(string), 222 UserAgent: d.Get("user_agent").(string),
213 Status: d.Get("status").(string), 223 Status: d.Get("status").(string),
214 Uptime: d.Get("uptime").(float64), 224 Uptime: d.Get("uptime").(float64),
215 NodeLocations: d.Get("node_locations").([]string), 225 NodeLocations: castInterfaceToSliceStrings(d.Get("node_locations")),
216 PingURL: d.Get("ping_url").(string), 226 PingURL: d.Get("ping_url").(string),
217 BasicUser: d.Get("basic_user").(string), 227 BasicUser: d.Get("basic_user").(string),
218 BasicPass: d.Get("basic_pass").(string), 228 BasicPass: d.Get("basic_pass").(string),
@@ -301,7 +311,9 @@ func ReadTest(d *schema.ResourceData, meta interface{}) error {
301 d.Set("user_agent", testResp.UserAgent) 311 d.Set("user_agent", testResp.UserAgent)
302 d.Set("status", testResp.Status) 312 d.Set("status", testResp.Status)
303 d.Set("uptime", testResp.Uptime) 313 d.Set("uptime", testResp.Uptime)
304 d.Set("node_locations", testResp.NodeLocations) 314 if err := d.Set("node_locations", testResp.NodeLocations); err != nil {
315 return fmt.Errorf("[WARN] Error setting node locations: %s", err)
316 }
305 d.Set("ping_url", testResp.PingURL) 317 d.Set("ping_url", testResp.PingURL)
306 d.Set("basic_user", testResp.BasicUser) 318 d.Set("basic_user", testResp.BasicUser)
307 d.Set("basic_pass", testResp.BasicPass) 319 d.Set("basic_pass", testResp.BasicPass)
@@ -368,7 +380,7 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
368 test.UserAgent = v.(string) 380 test.UserAgent = v.(string)
369 } 381 }
370 if v, ok := d.GetOk("node_locations"); ok { 382 if v, ok := d.GetOk("node_locations"); ok {
371 test.NodeLocations = v.([]string) 383 test.NodeLocations = castInterfaceToSliceStrings(v)
372 } 384 }
373 if v, ok := d.GetOk("ping_url"); ok { 385 if v, ok := d.GetOk("ping_url"); ok {
374 test.PingURL = v.(string) 386 test.PingURL = v.(string)