Skip to content

Commit a3823ba

Browse files
authored
Merge pull request #33 from kevholditch/kevholditch-empty-array-fields
fixing the empty array bug in kong
2 parents 2ea6914 + a481ebb commit a3823ba

File tree

5 files changed

+191
-28
lines changed

5 files changed

+191
-28
lines changed

kong/resource_kong_api_test.go

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,63 @@ func TestAccKongApiImport(t *testing.T) {
9696
})
9797
}
9898

99+
func TestAccKongApiImportNoHosts(t *testing.T) {
100+
101+
resource.Test(t, resource.TestCase{
102+
Providers: testAccProviders,
103+
CheckDestroy: testAccCheckKongApiDestroy,
104+
Steps: []resource.TestStep{
105+
resource.TestStep{
106+
Config: testImportApiNoHostsConfig,
107+
},
108+
109+
resource.TestStep{
110+
ResourceName: "kong_api.api",
111+
ImportState: true,
112+
ImportStateVerify: true,
113+
},
114+
},
115+
})
116+
}
117+
118+
func TestAccKongApiImportNoUris(t *testing.T) {
119+
120+
resource.Test(t, resource.TestCase{
121+
Providers: testAccProviders,
122+
CheckDestroy: testAccCheckKongApiDestroy,
123+
Steps: []resource.TestStep{
124+
resource.TestStep{
125+
Config: testImportApiNoUrisConfig,
126+
},
127+
128+
resource.TestStep{
129+
ResourceName: "kong_api.api",
130+
ImportState: true,
131+
ImportStateVerify: true,
132+
},
133+
},
134+
})
135+
}
136+
137+
func TestAccKongApiImportNoMethods(t *testing.T) {
138+
139+
resource.Test(t, resource.TestCase{
140+
Providers: testAccProviders,
141+
CheckDestroy: testAccCheckKongApiDestroy,
142+
Steps: []resource.TestStep{
143+
resource.TestStep{
144+
Config: testImportApiNoMethodsConfig,
145+
},
146+
147+
resource.TestStep{
148+
ResourceName: "kong_api.api",
149+
ImportState: true,
150+
ImportStateVerify: true,
151+
},
152+
},
153+
})
154+
}
155+
99156
func testAccCheckKongApiDestroy(state *terraform.State) error {
100157

101158
client := testAccProvider.Meta().(*gokong.KongAdminClient)
@@ -195,7 +252,61 @@ resource "kong_api" "api" {
195252
https_only = false
196253
http_if_terminated = false
197254
}
255+
256+
`
257+
const testImportApiNoHostsConfig = `
258+
resource "kong_api" "api" {
259+
name = "TestApi"
260+
hosts = []
261+
uris = [ "/example" ]
262+
methods = [ "GET", "POST" ]
263+
upstream_url = "http://localhost:4140"
264+
retries = 3
265+
strip_uri = false
266+
preserve_host = false
267+
upstream_connect_timeout = 60000
268+
upstream_send_timeout = 30000
269+
upstream_read_timeout = 10000
270+
https_only = false
271+
http_if_terminated = false
272+
}
273+
`
274+
const testImportApiNoMethodsConfig = `
275+
resource "kong_api" "api" {
276+
name = "TestApi"
277+
hosts = [ "example.com"]
278+
uris = [ "/example" ]
279+
methods = []
280+
upstream_url = "http://localhost:4140"
281+
retries = 3
282+
strip_uri = false
283+
preserve_host = false
284+
upstream_connect_timeout = 60000
285+
upstream_send_timeout = 30000
286+
upstream_read_timeout = 10000
287+
https_only = false
288+
http_if_terminated = false
289+
}
290+
`
291+
292+
const testImportApiNoUrisConfig = `
293+
resource "kong_api" "api" {
294+
name = "TestApi"
295+
hosts = [ "example.com"]
296+
uris = []
297+
methods = [ "GET" ]
298+
upstream_url = "http://localhost:4140"
299+
retries = 3
300+
strip_uri = false
301+
preserve_host = false
302+
upstream_connect_timeout = 60000
303+
upstream_send_timeout = 30000
304+
upstream_read_timeout = 10000
305+
https_only = false
306+
http_if_terminated = false
307+
}
198308
`
309+
199310
const testMinimumValuesApiConfig = `
200311
resource "kong_api" "minimal_api" {
201312
name = "MyMinimalApi"

vendor/github.com/kevholditch/gokong/README.md

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/kevholditch/gokong/apis.go

Lines changed: 60 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/kevholditch/gokong/routes.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/vendor.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,10 @@
535535
"revisionTime": "2016-08-03T19:07:31Z"
536536
},
537537
{
538-
"checksumSHA1": "ZVv247RQ+kBLRlmy+nLt2zFTxFs=",
538+
"checksumSHA1": "b3mQ8dVkpRngbnRQ0Wh7hpYLW0Y=",
539539
"path": "github.com/kevholditch/gokong",
540-
"revision": "ef943ada1515033fe7e1d211468eaf33be91a057",
541-
"revisionTime": "2018-07-10T14:04:32Z"
540+
"revision": "c1adf45559cf3f834a9ad995f21d6fc7c635f560",
541+
"revisionTime": "2018-07-30T20:22:00Z"
542542
},
543543
{
544544
"path": "github.com/kevholditch/gokong...",
@@ -547,8 +547,8 @@
547547
{
548548
"checksumSHA1": "w9MW3oDsZxi3k5QotS+3iWMa/eg=",
549549
"path": "github.com/kevholditch/gokong/containers",
550-
"revision": "157771deb83af0dc2f189ec247aaab067e4860c0",
551-
"revisionTime": "2018-07-07T06:11:15Z"
550+
"revision": "c1adf45559cf3f834a9ad995f21d6fc7c635f560",
551+
"revisionTime": "2018-07-30T20:22:00Z"
552552
},
553553
{
554554
"checksumSHA1": "IfZcD4U1dtllJKlPNeD2aU4Jn98=",
@@ -714,5 +714,5 @@
714714
"versionExact": "v1.6.1"
715715
}
716716
],
717-
"rootPath": "github.com/kamsz/terraform-provider-kong"
717+
"rootPath": "github.com/kevholditch/terraform-provider-kong"
718718
}

0 commit comments

Comments
 (0)