From 40da2bc21994a6d0371f2adfe82802a00693c43c Mon Sep 17 00:00:00 2001 From: Jason Kidd Date: Fri, 15 Nov 2024 15:48:04 -0800 Subject: [PATCH] Add sub_path_expr to volume mount options --- docs/data-sources/pod.md | 2 ++ docs/data-sources/pod_v1.md | 2 ++ docs/resources/cron_job.md | 4 +++- docs/resources/cron_job_v1.md | 2 ++ docs/resources/daemon_set_v1.md | 2 ++ docs/resources/daemonset.md | 2 ++ docs/resources/deployment.md | 2 ++ docs/resources/deployment_v1.md | 2 ++ docs/resources/job.md | 2 ++ docs/resources/job_v1.md | 2 ++ docs/resources/pod.md | 2 ++ docs/resources/pod_v1.md | 2 ++ docs/resources/replication_controller_v1.md | 2 ++ docs/resources/stateful_set.md | 2 ++ kubernetes/resource_kubernetes_deployment_v1_test.go | 1 + kubernetes/resource_kubernetes_pod_v1_test.go | 3 +++ .../resource_kubernetes_replication_controller_v1_test.go | 1 + kubernetes/schema_container.go | 5 +++++ kubernetes/structures_container.go | 6 ++++++ 19 files changed, 45 insertions(+), 1 deletion(-) diff --git a/docs/data-sources/pod.md b/docs/data-sources/pod.md index 96946e8752..5b1c5b4771 100644 --- a/docs/data-sources/pod.md +++ b/docs/data-sources/pod.md @@ -802,6 +802,7 @@ Read-Only: - `name` (String) - `read_only` (Boolean) - `sub_path` (String) +- `sub_path_expr` (String) @@ -1321,6 +1322,7 @@ Read-Only: - `name` (String) - `read_only` (Boolean) - `sub_path` (String) +- `sub_path_expr` (String) diff --git a/docs/data-sources/pod_v1.md b/docs/data-sources/pod_v1.md index 93199eb308..79ce406607 100644 --- a/docs/data-sources/pod_v1.md +++ b/docs/data-sources/pod_v1.md @@ -802,6 +802,7 @@ Read-Only: - `name` (String) - `read_only` (Boolean) - `sub_path` (String) +- `sub_path_expr` (String) @@ -1321,6 +1322,7 @@ Read-Only: - `name` (String) - `read_only` (Boolean) - `sub_path` (String) +- `sub_path_expr` (String) diff --git a/docs/resources/cron_job.md b/docs/resources/cron_job.md index c8042befb6..28c053d052 100644 --- a/docs/resources/cron_job.md +++ b/docs/resources/cron_job.md @@ -951,6 +951,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.job_template.spec.template.spec.container.volume_device` @@ -1512,6 +1513,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.job_template.spec.template.spec.init_container.volume_device` @@ -2389,4 +2391,4 @@ resource "kubernetes_cron_job" "demo" { ``` $ terraform import kubernetes_cron_job_v1/example default/example -``` \ No newline at end of file +``` diff --git a/docs/resources/cron_job_v1.md b/docs/resources/cron_job_v1.md index c5c7ea1d54..b435350633 100644 --- a/docs/resources/cron_job_v1.md +++ b/docs/resources/cron_job_v1.md @@ -946,6 +946,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.job_template.spec.template.spec.container.volume_device` @@ -1507,6 +1508,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.job_template.spec.template.spec.init_container.volume_device` diff --git a/docs/resources/daemon_set_v1.md b/docs/resources/daemon_set_v1.md index 59ba45b42d..86c8f7d9af 100644 --- a/docs/resources/daemon_set_v1.md +++ b/docs/resources/daemon_set_v1.md @@ -898,6 +898,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.container.volume_device` @@ -1458,6 +1459,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.init_container.volume_device` diff --git a/docs/resources/daemonset.md b/docs/resources/daemonset.md index 582da60be2..2a11c29128 100644 --- a/docs/resources/daemonset.md +++ b/docs/resources/daemonset.md @@ -898,6 +898,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.container.volume_device` @@ -1458,6 +1459,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.init_container.volume_device` diff --git a/docs/resources/deployment.md b/docs/resources/deployment.md index 1fa160f220..38062e9ab8 100644 --- a/docs/resources/deployment.md +++ b/docs/resources/deployment.md @@ -898,6 +898,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.container.volume_device` @@ -1458,6 +1459,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.init_container.volume_device` diff --git a/docs/resources/deployment_v1.md b/docs/resources/deployment_v1.md index 049de98022..4801406631 100644 --- a/docs/resources/deployment_v1.md +++ b/docs/resources/deployment_v1.md @@ -906,6 +906,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.container.volume_device` @@ -1466,6 +1467,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.init_container.volume_device` diff --git a/docs/resources/job.md b/docs/resources/job.md index 73dacd7813..bcaca5b3ba 100644 --- a/docs/resources/job.md +++ b/docs/resources/job.md @@ -906,6 +906,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.container.volume_device` @@ -1466,6 +1467,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.init_container.volume_device` diff --git a/docs/resources/job_v1.md b/docs/resources/job_v1.md index 32296bb876..5e222cb5f3 100644 --- a/docs/resources/job_v1.md +++ b/docs/resources/job_v1.md @@ -904,6 +904,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.container.volume_device` @@ -1464,6 +1465,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.init_container.volume_device` diff --git a/docs/resources/pod.md b/docs/resources/pod.md index 548a508040..9a806bd765 100644 --- a/docs/resources/pod.md +++ b/docs/resources/pod.md @@ -857,6 +857,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.container.volume_device` @@ -1418,6 +1419,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.init_container.volume_device` diff --git a/docs/resources/pod_v1.md b/docs/resources/pod_v1.md index 957dd320da..7c7ac8846a 100644 --- a/docs/resources/pod_v1.md +++ b/docs/resources/pod_v1.md @@ -855,6 +855,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.container.volume_device` @@ -1416,6 +1417,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.init_container.volume_device` diff --git a/docs/resources/replication_controller_v1.md b/docs/resources/replication_controller_v1.md index e83f7c6969..12af4452ae 100644 --- a/docs/resources/replication_controller_v1.md +++ b/docs/resources/replication_controller_v1.md @@ -893,6 +893,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.container.volume_device` @@ -1453,6 +1454,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.init_container.volume_device` diff --git a/docs/resources/stateful_set.md b/docs/resources/stateful_set.md index dde06232ef..fa41a3ff34 100644 --- a/docs/resources/stateful_set.md +++ b/docs/resources/stateful_set.md @@ -925,6 +925,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.container.volume_device` @@ -1485,6 +1486,7 @@ Optional: - `mount_propagation` (String) Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional. - `read_only` (Boolean) Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - `sub_path` (String) Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). +- `sub_path_expr` (String) Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). ### Nested Schema for `spec.template.spec.init_container.volume_device` diff --git a/kubernetes/resource_kubernetes_deployment_v1_test.go b/kubernetes/resource_kubernetes_deployment_v1_test.go index 85872dec7e..342285bf51 100644 --- a/kubernetes/resource_kubernetes_deployment_v1_test.go +++ b/kubernetes/resource_kubernetes_deployment_v1_test.go @@ -649,6 +649,7 @@ func TestAccKubernetesDeploymentV1_with_volume_mount(t *testing.T) { 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", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.sub_path_expr", ""), ), }, { diff --git a/kubernetes/resource_kubernetes_pod_v1_test.go b/kubernetes/resource_kubernetes_pod_v1_test.go index d1970deb96..22e30661ed 100644 --- a/kubernetes/resource_kubernetes_pod_v1_test.go +++ b/kubernetes/resource_kubernetes_pod_v1_test.go @@ -738,6 +738,7 @@ func TestAccKubernetesPodV1_with_volume_mount(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.name", "db"), resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.read_only", "false"), resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.sub_path", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.sub_path_expr", ""), resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.mount_propagation", "HostToContainer"), ), }, @@ -774,11 +775,13 @@ func TestAccKubernetesPodV1_with_cfg_map_volume_mount(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.name", "cfg"), resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.read_only", "false"), resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.sub_path", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.sub_path_expr", ""), resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.0.mount_propagation", "None"), resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.1.mount_path", "/tmp/my_raw_path"), resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.1.name", "cfg-binary"), resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.1.read_only", "false"), resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.1.sub_path", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.volume_mount.1.sub_path_expr", ""), resource.TestCheckResourceAttr(resourceName, "spec.0.volume.0.name", "cfg"), resource.TestCheckResourceAttr(resourceName, "spec.0.volume.0.config_map.0.name", cfgMap), resource.TestCheckResourceAttr(resourceName, "spec.0.volume.0.config_map.0.default_mode", "0777")), diff --git a/kubernetes/resource_kubernetes_replication_controller_v1_test.go b/kubernetes/resource_kubernetes_replication_controller_v1_test.go index f6cd0444cf..ffffebe998 100644 --- a/kubernetes/resource_kubernetes_replication_controller_v1_test.go +++ b/kubernetes/resource_kubernetes_replication_controller_v1_test.go @@ -421,6 +421,7 @@ func TestAccKubernetesReplicationControllerV1_with_volume_mount(t *testing.T) { 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", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.template.0.spec.0.container.0.volume_mount.0.sub_path_expr", ""), ), }, }, diff --git a/kubernetes/schema_container.go b/kubernetes/schema_container.go index 499ea0236a..73f81e6de8 100644 --- a/kubernetes/schema_container.go +++ b/kubernetes/schema_container.go @@ -243,6 +243,11 @@ func volumeMountFields() map[string]*schema.Schema { Optional: true, Description: `Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).`, }, + "sub_path_expr": { + Type: schema.TypeString, + Optional: true, + Description: `Dynamic path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).`, + }, "mount_propagation": { Type: schema.TypeString, Description: "Mount propagation mode. mount_propagation determines how mounts are propagated from the host to container and the other way around. Valid values are None (default), HostToContainer and Bidirectional.", diff --git a/kubernetes/structures_container.go b/kubernetes/structures_container.go index e116825050..e6077729e4 100644 --- a/kubernetes/structures_container.go +++ b/kubernetes/structures_container.go @@ -298,6 +298,9 @@ func flattenContainerVolumeMounts(in []v1.VolumeMount) []interface{} { if v.SubPath != "" { m["sub_path"] = v.SubPath } + if v.SubPathExpr != "" { + m["sub_path_expr"] = v.SubPathExpr + } m["mount_propagation"] = string(v1.MountPropagationNone) if v.MountPropagation != nil { @@ -820,6 +823,9 @@ func expandContainerVolumeMounts(in []interface{}) []v1.VolumeMount { if subPath, ok := p["sub_path"]; ok { vmp[i].SubPath = subPath.(string) } + if subPathExpr, ok := p["sub_path_expr"]; ok { + vmp[i].SubPathExpr = subPathExpr.(string) + } if mountPropagation, ok := p["mount_propagation"]; ok { mp := v1.MountPropagationMode(mountPropagation.(string)) vmp[i].MountPropagation = &mp