Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/deployment - remove computed from volume_mount #1246

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 70 additions & 8 deletions kubernetes/resource_kubernetes_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ func TestAccKubernetesDeployment_with_volume_mount(t *testing.T) {

deploymentName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
secretName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))

resourceName := "kubernetes_deployment.test"
imageName := nginxImageVersion

resource.Test(t, resource.TestCase{
Expand All @@ -558,13 +558,21 @@ func TestAccKubernetesDeployment_with_volume_mount(t *testing.T) {
{
Config: testAccKubernetesDeploymentConfigWithVolumeMounts(secretName, deploymentName, imageName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckKubernetesDeploymentExists("kubernetes_deployment.test", &conf),
resource.TestCheckResourceAttr("kubernetes_deployment.test", "spec.0.template.0.spec.0.container.0.image", imageName),
resource.TestCheckResourceAttr("kubernetes_deployment.test", "spec.0.template.0.spec.0.container.0.volume_mount.#", "1"),
resource.TestCheckResourceAttr("kubernetes_deployment.test", "spec.0.template.0.spec.0.container.0.volume_mount.0.mount_path", "/tmp/my_path"),
resource.TestCheckResourceAttr("kubernetes_deployment.test", "spec.0.template.0.spec.0.container.0.volume_mount.0.name", "db"),
resource.TestCheckResourceAttr("kubernetes_deployment.test", "spec.0.template.0.spec.0.container.0.volume_mount.0.read_only", "false"),
resource.TestCheckResourceAttr("kubernetes_deployment.test", "spec.0.template.0.spec.0.container.0.volume_mount.0.sub_path", ""),
testAccCheckKubernetesDeploymentExists(resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.image", imageName),
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.#", "1"),
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.mount_path", "/tmp/my_path"),
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.name", "db"),
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.read_only", "false"),
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.sub_path", ""),
),
},
{
Config: testAccKubernetesDeploymentConfigWithVolumeMountsNone(secretName, deploymentName, imageName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckKubernetesDeploymentExists(resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.image", imageName),
resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.#", "0"),
),
},
},
Expand Down Expand Up @@ -2078,6 +2086,60 @@ resource "kubernetes_deployment" "test" {
`, secretName, deploymentName, imageName)
}

func testAccKubernetesDeploymentConfigWithVolumeMountsNone(secretName, deploymentName, imageName string) string {
return fmt.Sprintf(`resource "kubernetes_secret" "test" {
metadata {
name = "%s"
}

data = {
one = "first"
}
}

resource "kubernetes_deployment" "test" {
metadata {
name = "%s"

labels = {
Test = "TfAcceptanceTest"
}
}

spec {
selector {
match_labels = {
Test = "TfAcceptanceTest"
}
}

template {
metadata {
labels = {
Test = "TfAcceptanceTest"
}
}

spec {
container {
image = "%s"
name = "containername"
}

volume {
name = "db"

secret {
secret_name = "${kubernetes_secret.test.metadata.0.name}"
}
}
}
}
}
}
`, secretName, deploymentName, imageName)
}

func testAccKubernetesDeploymentConfigWithResourceRequirements(deploymentName, imageName string) string {
return fmt.Sprintf(`resource "kubernetes_deployment" "test" {
metadata {
Expand Down
1 change: 0 additions & 1 deletion kubernetes/schema_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,6 @@ func containerFields(isUpdatable bool) map[string]*schema.Schema {
Type: schema.TypeList,
Optional: true,
ForceNew: !isUpdatable,
Computed: true,
Description: "Pod volumes to mount into the container's filesystem. Cannot be updated.",
Elem: &schema.Resource{
Schema: volumeMountFields(),
Expand Down