Skip to content

Commit

Permalink
Terraform 12 pre 1.0 (#109)
Browse files Browse the repository at this point in the history
* cherry-pick 3bd0f49

* Go modules

* Removed test code

* Fix upstream field

* Fix terraform 12 syntax errors

Co-authored-by: Olivier <[email protected]>
  • Loading branch information
acroca and Kyos authored Aug 12, 2020
1 parent 49e4467 commit caaa6c6
Show file tree
Hide file tree
Showing 2,020 changed files with 525,501 additions and 47,302 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ terraform import kong_api.<api_identifier> <api_id>
resource "kong_plugin" "response_rate_limiting" {
name = "response-ratelimiting"
config = {
limits.sms.minute = 10
"limits.sms.minute" = 10
}
}
```
Expand Down Expand Up @@ -170,7 +170,7 @@ resource "kong_plugin" "rate_limit" {
api_id = "${kong_api.api.id}"
consumer_id = "${kong_consumer.plugin_consumer.id}"
config = {
limits.sms.minute = 77
"limits.sms.minute" = 77
}
}
```
Expand Down Expand Up @@ -281,30 +281,30 @@ resource "kong_upstream" "upstream" {
hash_fallback = "consumer"
hash_on_header = "HeaderName"
hash_fallback_header = "FallbackHeaderName"
healthchecks = {
active = {
healthchecks {
active {
http_path = "/status"
timeout = 10
concurrency = 20
healthy = {
healthy {
successes = 1
interval = 5
http_statuses = [200, 201]
}
unhealthy = {
unhealthy {
timeouts = 7
interval = 3
tcp_failures = 1
http_failures = 2
http_statuses = [500, 501]
}
}
passive = {
healthy = {
passive {
healthy {
successes = 1
http_statuses = [200, 201, 202]
}
unhealthy = {
unhealthy {
timeouts = 3
tcp_failures = 5
http_failures = 6
Expand Down Expand Up @@ -345,7 +345,7 @@ resource "kong_upstream" "upstream" {
To look up an existing api you can do so by using a filter:
```hcl
data "kong_api" "api_data_source" {
filter = {
filter {
id = "de539d26-97d2-4d5b-aaf9-628e51087d9c"
name = "TestDataSourceApi"
upstream_url = "http://localhost:4140"
Expand Down Expand Up @@ -374,7 +374,7 @@ returned:
To look up an existing certificate:
```hcl
data "kong_certificate" "certificate_data_source" {
filter = {
filter {
id = "471c625a-4eba-4b78-985f-86cf54a2dc12"
}
}
Expand All @@ -389,7 +389,7 @@ You can only find existing certificates by their id in Kong. The following outp
To look up an existing consumer:
```hcl
data "kong_consumer" "consumer_data_source" {
filter = {
filter {
id = "8086a91b-cb5a-4e60-90b0-ca6650e82464"
username = "User777"
custom_id = "123456"
Expand All @@ -407,7 +407,7 @@ returned:
To look up an existing plugin:
```hcl
data "kong_plugin" "plugin_data_source" {
filter = {
filter {
id = "f0e656af-ad53-4622-ac73-ffd46ae05289"
name = "response-ratelimiting"
api_id = "51694bcd-3c72-43b3-b414-a09bbf4e3c30"
Expand All @@ -427,7 +427,7 @@ Each of the filter parameters are optional and they are combined for an AND sear
To lookup an existing upstream:
```hcl
data "kong_upstream" "upstream_data_source" {
filter = {
filter {
id = "893a49a8-090f-421e-afce-ba70b02ce958"
name = "TestUpstream"
}
Expand Down
20 changes: 20 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module github.com/kevholditch/terraform-provider-kong

go 1.12

require (
github.com/cenk/backoff v0.0.0-20171020064038-309aa717adbf // indirect
github.com/elazarl/goproxy v0.0.0-20190421051319-9d40249d3c2f // indirect
github.com/elazarl/goproxy/ext v0.0.0-20190421051319-9d40249d3c2f // indirect
github.com/fsouza/go-dockerclient v0.0.0-20160427172547-1d4f4ae73768 // indirect
github.com/go-sql-driver/mysql v1.4.1 // indirect
github.com/hashicorp/terraform v0.12.1
github.com/kevholditch/gokong v1.11.0
github.com/moul/http2curl v1.0.0 // indirect
github.com/parnurzeal/gorequest v0.2.16 // indirect
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 // indirect
github.com/pkg/errors v0.9.1 // indirect
golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
gopkg.in/ory-am/dockertest.v3 v3.0.9 // indirect
moul.io/http2curl v1.0.0 // indirect
)
464 changes: 464 additions & 0 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kong/data_source_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ resource "kong_api" "my_test_api" {
}
data "kong_api" "api_data_source" {
filter = {
filter {
id = "${kong_api.my_test_api.id}"
name = "TestDataSourceApi"
upstream_url = "http://localhost:4140"
Expand Down
2 changes: 1 addition & 1 deletion kong/data_source_certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource "kong_certificate" "test_certificate" {
}
data "kong_certificate" "certificate_data_source" {
filter = {
filter {
id = "${kong_certificate.test_certificate.id}"
}
}
Expand Down
2 changes: 1 addition & 1 deletion kong/data_source_consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource "kong_consumer" "test_consumer" {
}
data "kong_consumer" "consumer_data_source" {
filter = {
filter {
id = "${kong_consumer.test_consumer.id}"
username = "User777"
custom_id = "123456"
Expand Down
4 changes: 2 additions & 2 deletions kong/data_source_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ resource "kong_plugin" "rate_limit" {
api_id = "${kong_api.my_api.id}"
consumer_id = "${kong_consumer.my_consumer.id}"
config = {
limits.sms.minute = 11
"limits.sms.minute" = 11
}
}
data "kong_plugin" "plugin_data_source" {
filter = {
filter {
id = "${kong_plugin.rate_limit.id}"
name = "response-ratelimiting"
api_id = "${kong_api.my_api.id}"
Expand Down
16 changes: 8 additions & 8 deletions kong/data_source_upstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,30 @@ resource "kong_upstream" "upstream" {
hash_fallback = "consumer"
hash_on_header = "HeaderName"
hash_fallback_header = "FallbackHeaderName"
healthchecks = {
active = {
healthchecks {
active {
http_path = "/status"
timeout = 10
concurrency = 20
healthy = {
healthy {
successes = 1
interval = 5
http_statuses = [200, 201]
}
unhealthy = {
unhealthy {
timeouts = 7
interval = 3
tcp_failures = 1
http_failures = 2
http_statuses = [500, 501]
}
}
passive = {
healthy = {
passive {
healthy {
successes = 1
http_statuses = [200, 201, 202]
}
unhealthy = {
unhealthy {
timeouts = 3
tcp_failures = 5
http_failures = 6
Expand All @@ -92,7 +92,7 @@ resource "kong_upstream" "upstream" {
}
data "kong_upstream" "upstream_data_source" {
filter = {
filter {
id = "${kong_upstream.upstream.id}"
name = "TestUpstream"
}
Expand Down
46 changes: 10 additions & 36 deletions kong/resource_kong_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,6 @@ func TestAccKongPluginForAllConsumersAndApis(t *testing.T) {
})
}

func TestAccKongPluginForAllConsumersAndApisFOOOOOOOOOOOOOOOOOOOO(t *testing.T) {

resource.Test(t, resource.TestCase{
Providers: testAccProviders,
CheckDestroy: testAccCheckKongPluginDestroy,
Steps: []resource.TestStep{
{
Config: testCreatePluginForAllApisAndConsumersConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckKongPluginExists("kong_plugin.response_rate_limiting"),
resource.TestCheckResourceAttr("kong_plugin.response_rate_limiting", "name", "response-ratelimiting"),
resource.TestCheckResourceAttr("kong_plugin.response_rate_limiting", "config.limits.sms.minute", "10"),
),
},
{
Config: testCreatePluginForAllApisAndConsumersConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckKongPluginExists("kong_plugin.response_rate_limiting"),
resource.TestCheckResourceAttr("kong_plugin.response_rate_limiting", "name", "response-ratelimiting"),
resource.TestCheckResourceAttr("kong_plugin.response_rate_limiting", "config.limits.sms.minute", "10"),
),
},
},
})
}

func TestAccKongPluginForASpecificApi(t *testing.T) {

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -370,15 +344,15 @@ const testCreatePluginForAllApisAndConsumersConfig = `
resource "kong_plugin" "response_rate_limiting" {
name = "response-ratelimiting"
config = {
limits.sms.minute = 10
"limits.sms.minute" = 10
}
}
`
const testUpdatePluginForAllApisAndConsumersConfig = `
resource "kong_plugin" "response_rate_limiting" {
name = "response-ratelimiting"
config = {
limits.sms.minute = 40
"limits.sms.minute" = 40
}
}
`
Expand Down Expand Up @@ -444,7 +418,7 @@ resource "kong_plugin" "rate_limit" {
name = "response-ratelimiting"
consumer_id = "${kong_consumer.plugin_consumer.id}"
config = {
limits.sms.minute = 20
"limits.sms.minute" = 20
}
}
`
Expand All @@ -460,7 +434,7 @@ resource "kong_plugin" "rate_limit" {
name = "response-ratelimiting"
service_id = "${kong_service.service.id}"
config = {
limits.sms.minute = 20
"limits.sms.minute" = 20
}
}
`
Expand All @@ -486,7 +460,7 @@ resource "kong_plugin" "rate_limit" {
name = "response-ratelimiting"
route_id = "${kong_route.route.id}"
config = {
limits.sms.minute = 20
"limits.sms.minute" = 20
}
}
`
Expand All @@ -501,7 +475,7 @@ resource "kong_plugin" "rate_limit" {
name = "response-ratelimiting"
consumer_id = "${kong_consumer.plugin_consumer.id}"
config = {
limits.sms.minute = 11
"limits.sms.minute" = 11
}
}
`
Expand All @@ -517,7 +491,7 @@ resource "kong_plugin" "rate_limit" {
name = "response-ratelimiting"
service_id = "${kong_service.service.id}"
config = {
limits.sms.minute = 11
"limits.sms.minute" = 11
}
}
`
Expand All @@ -543,7 +517,7 @@ resource "kong_plugin" "rate_limit" {
name = "response-ratelimiting"
route_id = "${kong_route.route.id}"
config = {
limits.sms.minute = 11
"limits.sms.minute" = 11
}
}
`
Expand Down Expand Up @@ -575,7 +549,7 @@ resource "kong_plugin" "rate_limit" {
api_id = "${kong_api.api.id}"
consumer_id = "${kong_consumer.plugin_consumer.id}"
config = {
limits.sms.minute = 77
"limits.sms.minute" = 77
}
}
`
Expand Down Expand Up @@ -607,7 +581,7 @@ resource "kong_plugin" "rate_limit" {
api_id = "${kong_api.api.id}"
consumer_id = "${kong_consumer.plugin_consumer.id}"
config = {
limits.sms.minute = 23
"limits.sms.minute" = 23
}
}
`
Expand Down
4 changes: 2 additions & 2 deletions kong/resource_kong_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func resourceKongTargetCreate(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("failed to create kong target: %v error: %v", targetRequest, err)
}

d.SetId(*target.Upstream + "/" + *target.Id)
d.SetId(*target.UpstreamId + "/" + *target.Id)

return resourceKongTargetRead(d, meta)
}
Expand Down Expand Up @@ -75,7 +75,7 @@ func resourceKongTargetRead(d *schema.ResourceData, meta interface{}) error {
if *element.Id == ids[1] {
d.Set("target", element.Target)
d.Set("weight", element.Weight)
d.Set("upstream_id", element.Upstream)
d.Set("upstream_id", element.UpstreamId)
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions kong/resource_kong_upstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -992,30 +992,30 @@ resource "kong_upstream" "upstream" {
hash_fallback = "consumer"
hash_on_header = "HeaderName"
hash_fallback_header = "FallbackHeaderName"
healthchecks = {
active = {
healthchecks {
active {
http_path = "/status"
timeout = 10
concurrency = 20
healthy = {
healthy {
successes = 1
interval = 5
http_statuses = [200, 201]
}
unhealthy = {
unhealthy {
timeouts = 7
interval = 3
tcp_failures = 1
http_failures = 2
http_statuses = [500, 501]
}
}
passive = {
healthy = {
passive {
healthy {
successes = 1
http_statuses = [200, 201, 202]
}
unhealthy = {
unhealthy {
timeouts = 3
tcp_failures = 5
http_failures = 6
Expand Down
Loading

0 comments on commit caaa6c6

Please sign in to comment.