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

Commit

Permalink
Upgrade to support new provider model
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilde committed Sep 27, 2017
1 parent 5896613 commit 86ff517
Show file tree
Hide file tree
Showing 1,594 changed files with 210,035 additions and 649,510 deletions.
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
example/terraform.tfvars
.DS_Store
examples/terraform.tfvars
terraform.tfplan
terraform.tfstate
.terraform
bin/
modules-dev/
./*.tfstate
/pkg/
*.log
*.bak
*~
.*.swp
.idea
*.iml
*.test
*.iml
*.tfstate
*.tfstate.backup
terraform-provider-runscope
47 changes: 47 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
TEST?=$$(go list ./... |grep -v 'vendor')
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)

default: build

build: fmtcheck
go install

test: fmtcheck
go test -i $(TEST) || exit 1
echo $(TEST) | \
xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4

testacc: fmtcheck
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m

vet:
@echo "go vet ."
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
exit 1; \
fi

fmt:
gofmt -w $(GOFMT_FILES)

fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"

vendor-status:
@govendor status

test-compile:
@if [ "$(TEST)" = "./..." ]; then \
echo "ERROR: Set TEST to a specific package. For example,"; \
echo " make test-compile TEST=./aws"; \
exit 1; \
fi
go test -c $(TEST) $(TESTARGS)

.PHONY: build test testacc vet fmt fmtcheck errcheck vendor-status test-compile

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2016 PayByPhone Technologies, Inc.
Copyright:: Copyright (c) 2017 Edward Wilde

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
197 changes: 40 additions & 157 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,181 +1,64 @@
Terraform Runscope Provider
===========================
# Terraform Runscope Provider

This repository contains a plugin form of the Runscope provider that was proposed
and submitted in [Terraform PR #14221][1].
- Website: https://www.terraform.io
- [![Gitter chat](https://badges.gitter.im/hashicorp-terraform/Lobby.png)](https://gitter.im/hashicorp-terraform/Lobby)
- Mailing list: [Google Groups](http://groups.google.com/group/terraform-tool)

The Runscope provider is used to create and manage Runscope tests using
the official [Runscope API][2]

## Installing

See the [Plugin Basics][4] page of the Terraform docs to see how to plunk this
into your config. Check the [releases page][5] of this repo to get releases for
Linux, OS X, and Windows.

## Usage

The following section details the use of the provider and its resources.

These docs are derived from the middleman templates that were created for the
PR itself, and can be found in their original form [here][5].

### Example Usage

The below example is an end-to-end demonstration of the setup of a basic
runscope test:


### Creating a test with a step
```hcl
resource "runscope_step" "main_page" {
bucket_id = "${runscope_bucket.bucket.id}"
test_id = "${runscope_test.test.id}"
step_type = "request"
url = "http://example.com"
method = "GET"
variables = [
{
name = "httpStatus"
source = "response_status"
},
{
name = "httpContentEncoding"
source = "response_header"
property = "Content-Encoding"
},
]
assertions = [
{
source = "response_status"
comparison = "equal_number"
value = "200"
},
{
source = "response_json"
comparison = "equal"
value = "c5baeb4a-2379-478a-9cda-1b671de77cf9",
property = "data.id"
},
],
headers = [
{
header = "Accept-Encoding",
value = "application/json"
},
{
header = "Accept-Encoding",
value = "application/xml"
},
{
header = "Authorization",
value = "Bearer bb74fe7b-b9f2-48bd-9445-bdc60e1edc6a",
}
]
}
resource "runscope_test" "test" {
bucket_id = "${runscope_bucket.bucket.id}"
name = "runscope test"
description = "This is a test test..."
}
resource "runscope_bucket" "bucket" {
name = "terraform-provider-test"
team_uuid = "dfb75aac-eeb3-4451-8675-3a37ab421e4f"
}
```
<img src="https://cdn.rawgit.com/hashicorp/terraform-website/master/content/source/assets/images/logo-hashicorp.svg" width="600px">

## Argument Reference
The Runscope provider is used to create and manage Runscope tests using
the official [Runscope API](https://www.runscope.com/docs/api)

The following arguments are supported:
## Requirements

* `bucket_id` - (Required) The id of the bucket to associate this step with.
* `test_id` - (Required) The id of the test to associate this step with.
* `step_type` - (Required) The type of step.
* [request](#request-steps)
* pause
* condition
* ghost
* subtest
- [Terraform](https://www.terraform.io/downloads.html) 0.10.x
- [Go](https://golang.org/doc/install) 1.9 (to build the provider plugin)

### Request steps
When creating a `request` type of step the additional arguments also apply:
## Building The Provider

* `method` - (Required) The HTTP method for this request step.
* `variables` - (Optional) A list of variables to extract out of the HTTP response from this request. Variables documented below.
* `assertions` - (Optional) A list of assertions to apply to the HTTP response from this request. Assertions documented below.
* `headers` - (Optional) A list of headers to apply to the request. Headers documented below.
* `body` - (Optional) A string to use as the body of the request.
Clone repository to: `$GOPATH/src/github.com/terraform-providers/terraform-provider-runscope`

Variables (`variables`) supports the following:
```sh
$ mkdir -p $GOPATH/src/github.com/terraform-providers; cd $GOPATH/src/github.com/terraform-providers
$ git clone git@github.com:terraform-providers/terraform-provider-runscope
```

* `name` - (Required) Name of the variable to define.
* `property` - (Required) The name of the source property. i.e. header name or json path
* `source` - (Required) The variable source, for list of allowed values see: https://www.runscope.com/docs/api/steps#assertions
Enter the provider directory and build the provider

Assertions (`assertions`) supports the following:
```sh
$ cd $GOPATH/src/github.com/terraform-providers/terraform-provider-runscope
$ make build
```

* `source` - (Required) The assertion source, for list of allowed values see: https://www.runscope.com/docs/api/steps#assertions
* `property` - (Optional) The name of the source property. i.e. header name or json path
* `comparison` - (Required) The assertion comparison to make i.e. `equals`, for list of allowed values see: https://www.runscope.com/docs/api/steps#assertions
* `value` - (Optional) The value the `comparison` will use
## Using the provider

**Example Assertions**
See [examples](examples/)

Status Code == 200
See [runscope providers documentation](https://www.terraform.io/docs/providers/runscope/index.html)

```json
"assertions": [
{
"source": "response_status",
"comparison": "equal_number",
"value": 200
}
]
```
## Developing the Provider

JSON element 'address' contains the text "avenue"
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.9+ is *required*). You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`.

To compile the provider, run `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.

```json
"assertions": [
{
"source": "response_json",
"property": "address",
"comparison": "contains",
"value": "avenue"
}
]
```sh
$ make build
...
$ $GOPATH/bin/terraform-provider-runscope
...
```

Response Time is faster than 1 second.
In order to test the provider, you can simply run `make test`.


```json
"assertions": [
{
"source": "response_time",
"comparison": "is_less_than",
"value": 1000
}
]
```sh
$ make test
```

The `headers` list supports the following:

* `header` - (Required) The name of the header
* `value` - (Required) The name header value

## Attributes Reference
In order to run the full suite of Acceptance tests, run `make testacc`.

The following attributes are exported:
*Note:* Acceptance tests create real resources, and often cost money to run.

* `id` - The ID of the step.


[1]: https://github.com/hashicorp/terraform/pull/14221
[2]: https://www.runscope.com/docs/api
[3]: https://www.terraform.io/docs/plugins/basics.html
[4]: https://github.com/ewilde/terraform-provider-runscope/releases
[5]: website/source/docs/providers/runscope
```sh
$ env RUNSCOPE_TEAM_ID={your-team-id} RUNSCOPE_ACCESS_TOKEN={your-access-token} make testacc
```
File renamed without changes.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
"github.com/ewilde/terraform-provider-runscope/runscope"
"github.com/hashicorp/terraform/plugin"
"github.com/ewilde/terraform-provider-runscope/plugin/providers/runscope"
)

func main() {
Expand Down
19 changes: 0 additions & 19 deletions main_test.go

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed pkg/windows_amd64/terraform-provider-runscope.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed plugin/providers/.DS_Store
Binary file not shown.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func testAccDataSourceRunscopeIntegration(dataSource string) resource.TestCheckF
return fmt.Errorf("Expected to get an integration ID from runscope data resource")
}

if a["type"] != "pagerduty" {
if a["type"] != "slack" {
return fmt.Errorf("Expected to get an integration type pagerduty from runscope data resource")
}

Expand All @@ -47,6 +47,6 @@ func testAccDataSourceRunscopeIntegration(dataSource string) resource.TestCheckF
const testAccDataSourceRunscopeIntegrationConfig = `
data "runscope_integration" "by_type" {
team_uuid = "%s"
type = "pagerduty"
type = "slack"
}
`
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ resource "runscope_environment" "environment" {
integrations = [
{
id = "${data.runscope_integration.pagerduty.id}"
integration_type = "pagerduty"
id = "${data.runscope_integration.slack.id}"
integration_type = "slack"
}
]
Expand All @@ -132,8 +132,8 @@ resource "runscope_bucket" "bucket" {
team_uuid = "%s"
}
data "runscope_integration" "pagerduty" {
data "runscope_integration" "slack" {
team_uuid = "%s"
type = "pagerduty"
type = "slack"
}
`
File renamed without changes.
Loading

0 comments on commit 86ff517

Please sign in to comment.