From c2311e3e1526c90308b8e673b9d1e8b72569431f Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Thu, 26 Oct 2017 19:28:54 +0200 Subject: [PATCH] Add acceptance test --- kubernetes/resource_kubernetes_pod_test.go | 48 +++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/kubernetes/resource_kubernetes_pod_test.go b/kubernetes/resource_kubernetes_pod_test.go index 6daeafbfef..97c8f8f9b6 100644 --- a/kubernetes/resource_kubernetes_pod_test.go +++ b/kubernetes/resource_kubernetes_pod_test.go @@ -43,6 +43,15 @@ func TestAccKubernetesPod_basic(t *testing.T) { resource.TestCheckResourceAttrSet("kubernetes_pod.test", "metadata.0.uid"), resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env.0.value_from.0.secret_key_ref.0.name", secretName), resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env.1.value_from.0.config_map_key_ref.0.name", configMapName), + resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.#", "2"), + resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.0.config_map_ref.#", "1"), + resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.0.config_map_ref.0.name", fmt.Sprintf("%s-from", configMapName)), + resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.0.config_map_ref.0.optional", "true"), + resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.0.prefix", "FROM_CM_"), + resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.1.secret_ref.#", "1"), + resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.1.secret_ref.0.name", fmt.Sprintf("%s-from", secretName)), + resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.1.secret_ref.0.optional", "false"), + resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.1.prefix", "FROM_S_"), resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.image", imageName1), ), }, @@ -579,6 +588,17 @@ resource "kubernetes_secret" "test" { } } +resource "kubernetes_secret" "test_from" { + metadata { + name = "%s-from" + } + + data { + one = "first_from" + second = "second_from" + } +} + resource "kubernetes_config_map" "test" { metadata { name = "%s" @@ -589,6 +609,17 @@ resource "kubernetes_config_map" "test" { } } +resource "kubernetes_config_map" "test_from" { + metadata { + name = "%s-from" + } + + data { + one = "ONE_FROM" + two = "TWO_FROM" + } +} + resource "kubernetes_pod" "test" { metadata { labels { @@ -624,6 +655,21 @@ resource "kubernetes_pod" "test" { } }, ] + + env_from = [{ + config_map_ref { + name = "${kubernetes_config_map.test_from.metadata.0.name}" + optional = true + } + prefix = "FROM_CM_" + }, { + secret_ref { + name = "${kubernetes_secret.test_from.metadata.0.name}" + optional = false + } + prefix = "FROM_S_" + }] + } volume { name = "db" @@ -633,7 +679,7 @@ resource "kubernetes_pod" "test" { } } } - `, secretName, configMapName, podName, imageName) + `, secretName, secretName, configMapName, configMapName, podName, imageName) } func testAccKubernetesPodConfigWithSecurityContext(podName, imageName string) string {