Skip to content

Commit

Permalink
rnd-ify sa name for TestAccKubernetesPod_config_with_automount_servic…
Browse files Browse the repository at this point in the history
…e_account_token
  • Loading branch information
jhoblitt committed Jan 10, 2019
1 parent 8475a81 commit 1e1fcdc
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions kubernetes/resource_kubernetes_pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,14 +595,15 @@ func TestAccKubernetesPod_config_with_automount_service_account_token(t *testing

podName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
imageName := "nginx:1.7.9"
saName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesPodDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesPodConfigWithAutomountServiceAccountToken(podName, imageName),
Config: testAccKubernetesPodConfigWithAutomountServiceAccountToken(saName, podName, imageName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckKubernetesPodExists("kubernetes_pod.test", &confPod),
testAccCheckKubernetesServiceAccountExists("kubernetes_service_account.test", &confSA),
Expand Down Expand Up @@ -1324,11 +1325,11 @@ resource "kubernetes_pod" "test" {
`, podName, imageName, val)
}

func testAccKubernetesPodConfigWithAutomountServiceAccountToken(podName, imageName string) string {
func testAccKubernetesPodConfigWithAutomountServiceAccountToken(saName string, podName string, imageName string) string {
return fmt.Sprintf(`
resource "kubernetes_service_account" "test" {
metadata {
name = "foo"
name = "%s"
}
}
Expand All @@ -1342,16 +1343,14 @@ resource "kubernetes_pod" "test" {
}
spec {
service_account_name = "foo"
service_account_name = "kubernetes_service_account.test.metadata.0.name"
automount_service_account_token = true
container {
image = "%s"
name = "containername"
}
}
depends_on = [ "kubernetes_service_account.test" ]
}
`, podName, imageName)
`, saName, podName, imageName)
}

0 comments on commit 1e1fcdc

Please sign in to comment.