Skip to content
This repository has been archived by the owner on Jun 30, 2018. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 0.10.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilde committed Oct 11, 2017
2 parents 86ff517 + 354c439 commit 7cec33c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 17 deletions.
21 changes: 4 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
.DS_Store
examples/terraform.tfvars
terraform.tfplan
terraform.tfstate
.terraform
bin/
modules-dev/
./*.tfstate
/pkg/
*.log
*.bak
*~
.*.swp
terraform.tfvars
.idea
*.iml
*.test
*.iml
*.tfstate
*.tfstate.backup
terraform-provider-runscope
terraform-provider-runscope
pkg
.terraform
6 changes: 6 additions & 0 deletions examples/test.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ provider "runscope" {
access_token = "${var.access_token}"
}

resource "runscope_environment" "main" {
bucket_id = "${runscope_bucket.main.id}"
name = "shared-environment"
regions = ["us1", "eu1"]
}

# Create a bucket
resource "runscope_bucket" "main" {
name = "terraform-ftw"
Expand Down
18 changes: 18 additions & 0 deletions runscope/resource_runscope_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ func resourceRunscopeEnvironment() *schema.Resource {
},
Optional: true,
},
"regions": &schema.Schema{
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
}
}
Expand All @@ -85,6 +90,7 @@ func resourceEnvironmentCreate(d *schema.ResourceData, meta interface{}) error {

var createdEnvironment *runscope.Environment
bucketId := d.Get("bucket_id").(string)

if testId, ok := d.GetOk("test_id"); ok {
createdEnvironment, err = client.CreateTestEnvironment(environment,
&runscope.Test{ID: testId.(string), Bucket: &runscope.Bucket{Key: bucketId}})
Expand Down Expand Up @@ -240,6 +246,18 @@ func createEnvironmentFromResourceData(d *schema.ResourceData) (*runscope.Enviro
environment.Integrations = integrations
}


if attr, ok := d.GetOk("regions"); ok {
regions := []string{}
items := attr.([]interface{})
for _, x := range items {
item := x.(string)
regions = append(regions, item)
}

environment.Regions = regions
}

return environment, nil
}

Expand Down
14 changes: 14 additions & 0 deletions runscope/resource_runscope_environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ func testAccCheckEnvironmentExists(n string) resource.TestCheckFunc {
return fmt.Errorf("Expected %d integrations, actual %d", 1, len(environment.Integrations))
}

if len(foundRecord.Regions) != 2 {
return fmt.Errorf("Expected %d regions, actual %d", 2, len(environment.Regions))
}

if (foundRecord.Regions[0] != "us1") {
return fmt.Errorf("Expected %s, actual %s", "us1", environment.Regions[0])
}

if (foundRecord.Regions[1] != "eu1") {
return fmt.Errorf("Expected %s, actual %s", "eu1", environment.Regions[1])
}

return nil
}
}
Expand All @@ -119,6 +131,8 @@ resource "runscope_environment" "environment" {
var1 = "true",
var2 = "value2"
}
regions = ["us1", "eu1"]
}
resource "runscope_test" "test" {
Expand Down
7 changes: 7 additions & 0 deletions website/docs/r/environment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ that you'd like to use across all tests within a bucket,
use a [Shared Environment](https://www.runscope.com/docs/api-testing/environments#shared).

### Creating a shared environment

> Note: to create a shared environment you do not include a `test_id`
```hcl
resource "runscope_environment" "environment" {
bucket_id = "${runscope_bucket.bucket.id}"
Expand All @@ -42,6 +45,9 @@ data "runscope_integration" "pagerduty" {
}
```
### Creating a test environment

> Note: to create an environment specific to a test include the associated `test_id`
```hcl
resource "runscope_environment" "environment" {
bucket_id = "${runscope_bucket.bucket.id}"
Expand Down Expand Up @@ -94,6 +100,7 @@ to to run to setup the environment
* `initial_variables` - (Optional) Map of keys and values being used for variables when the test begins.
* `integrations` - (Optional) A list of integrations to enable for test runs using this environment.
Integrations documented below.
* `regions` - (Optional) A list of [Runscope regions](https://www.runscope.com/docs/regions) to execute test runs in when using this environment.

Integrations (`integrations`) supports the following:

Expand Down

0 comments on commit 7cec33c

Please sign in to comment.