@@ -194,38 +194,41 @@ func TestAccKubernetesSecret_generatedName(t *testing.T) {
194194 })
195195}
196196
197- // Disabled - this test loads binary data from a file and passes it through configuration
198- // which is no longer supported in TF 0.12.
199- // Instead, the resource attribute should be adapted to transport base64 encoded
200- // data and decode it when constructing the API object for client-go.
201- //
202- // func TestAccKubernetesSecret_binaryData(t *testing.T) {
203- // var conf api.Secret
204- // prefix := "tf-acc-test-gen-"
205- //
206- // resource.Test(t, resource.TestCase{
207- // PreCheck: func() { testAccPreCheck(t) },
208- // IDRefreshName: "kubernetes_secret.test",
209- // ProviderFactories: testAccProviderFactories,
210- // CheckDestroy: testAccCheckKubernetesSecretDestroy,
211- // Steps: []resource.TestStep{
212- // {
213- // Config: testAccKubernetesSecretConfig_binaryData(prefix),
214- // Check: resource.ComposeAggregateTestCheckFunc(
215- // testAccCheckKubernetesSecretExists("kubernetes_secret.test", &conf),
216- // resource.TestCheckResourceAttr("kubernetes_secret.test", "data.%", "1"),
217- // ),
218- // },
219- // {
220- // Config: testAccKubernetesSecretConfig_binaryData2(prefix),
221- // Check: resource.ComposeAggregateTestCheckFunc(
222- // testAccCheckKubernetesSecretExists("kubernetes_secret.test", &conf),
223- // resource.TestCheckResourceAttr("kubernetes_secret.test", "data.%", "2"),
224- // ),
225- // },
226- // },
227- // })
228- // }
197+ func TestAccKubernetesSecret_binaryData (t * testing.T ) {
198+ var conf api.Secret
199+ prefix := "tf-acc-test-gen-"
200+
201+ resource .Test (t , resource.TestCase {
202+ PreCheck : func () { testAccPreCheck (t ) },
203+ IDRefreshName : "kubernetes_secret.test" ,
204+ ProviderFactories : testAccProviderFactories ,
205+ CheckDestroy : testAccCheckKubernetesSecretDestroy ,
206+ Steps : []resource.TestStep {
207+ {
208+ Config : testAccKubernetesSecretConfig_binaryData (prefix ),
209+ Check : resource .ComposeAggregateTestCheckFunc (
210+ testAccCheckKubernetesSecretExists ("kubernetes_secret.test" , & conf ),
211+ resource .TestCheckResourceAttr ("kubernetes_secret.test" , "binary_data.%" , "1" ),
212+ ),
213+ },
214+ {
215+ Config : testAccKubernetesSecretConfig_binaryData2 (prefix ),
216+ Check : resource .ComposeAggregateTestCheckFunc (
217+ testAccCheckKubernetesSecretExists ("kubernetes_secret.test" , & conf ),
218+ resource .TestCheckResourceAttr ("kubernetes_secret.test" , "binary_data.%" , "2" ),
219+ ),
220+ },
221+ {
222+ Config : testAccKubernetesSecretConfig_binaryDataCombined (prefix ),
223+ Check : resource .ComposeAggregateTestCheckFunc (
224+ testAccCheckKubernetesSecretExists ("kubernetes_secret.test" , & conf ),
225+ resource .TestCheckResourceAttr ("kubernetes_secret.test" , "data.%" , "2" ),
226+ resource .TestCheckResourceAttr ("kubernetes_secret.test" , "binary_data.%" , "2" ),
227+ ),
228+ },
229+ },
230+ })
231+ }
229232
230233func testAccCheckSecretData (m * api.Secret , expected map [string ]string ) resource.TestCheckFunc {
231234 return func (s * terraform.State ) error {
@@ -382,6 +385,8 @@ func testAccKubernetesSecretConfig_noData(name string) string {
382385 metadata {
383386 name = "%s"
384387 }
388+
389+ data = {}
385390}
386391` , name )
387392}
@@ -422,11 +427,8 @@ func testAccKubernetesSecretConfig_binaryData(prefix string) string {
422427 generate_name = "%s"
423428 }
424429
425- data = {
426- one = <<EOF
427- "${filebase64("./test-fixtures/binary.data")}"
428- EOF
429-
430+ binary_data = {
431+ one = filebase64("./test-fixtures/binary.data")
430432 }
431433}
432434` , prefix )
@@ -438,15 +440,28 @@ func testAccKubernetesSecretConfig_binaryData2(prefix string) string {
438440 generate_name = "%s"
439441 }
440442
441- data = {
442- one = <<EOF
443- "${filebase64("./test-fixtures/binary2.data")}"
444- EOF
443+ binary_data = {
444+ one = filebase64("./test-fixtures/binary.data")
445+ two = filebase64("./test-fixtures/binary2.data")
446+ }
447+ }
448+ ` , prefix )
449+ }
450+
451+ func testAccKubernetesSecretConfig_binaryDataCombined (prefix string ) string {
452+ return fmt .Sprintf (`resource "kubernetes_secret" "test" {
453+ metadata {
454+ generate_name = "%s"
455+ }
445456
446- two = <<EOF
447- "${filebase64("./test-fixtures/binary.data")}"
448- EOF
457+ data = {
458+ "HOST" = "127.0.0.1"
459+ "PORT" = "80"
460+ }
449461
462+ binary_data = {
463+ one = filebase64("./test-fixtures/binary.data")
464+ two = filebase64("./test-fixtures/binary2.data")
450465 }
451466}
452467` , prefix )
0 commit comments