diff --git a/docs/resources/persistent_volume_claim_v1.md b/docs/resources/persistent_volume_claim_v1.md index e6da788968..83f3b389fe 100644 --- a/docs/resources/persistent_volume_claim_v1.md +++ b/docs/resources/persistent_volume_claim_v1.md @@ -71,15 +71,7 @@ Optional: ### Nested Schema for `spec.data_source` Optional: - -- `persistent_volume_claim` (Block List, Max: 1) Details of the source PersistentVolumeClaim. (see [below for nested schema](#nestedblock--spec--data_source--persistent_volume_claim)) - - -### Nested Schema for `spec.data_source.persistent_volume_claim` - -Required: - -- `claim_name` (String) The name of the source PersistentVolumeClaim. +- `name` (String) The name of the source PersistentVolumeClaim. ### Nested Schema for `spec.selector` @@ -158,9 +150,7 @@ resource "kubernetes_persistent_volume_claim_v1" "example_clone" { } } data_source { - persistent_volume_claim { - claim_name = "example-source-pvc" - } + name = "example-source-pvc" } } } diff --git a/kubernetes/resource_kubernetes_persistent_volume_claim_v1_test.go b/kubernetes/resource_kubernetes_persistent_volume_claim_v1_test.go index c4d40fe020..070dc136ae 100644 --- a/kubernetes/resource_kubernetes_persistent_volume_claim_v1_test.go +++ b/kubernetes/resource_kubernetes_persistent_volume_claim_v1_test.go @@ -589,7 +589,7 @@ func TestAccKubernetesPersistentVolumeClaimV1_dataSource(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckKubernetesPersistentVolumeClaimV1Exists(resourceName, &conf), resource.TestCheckResourceAttr(resourceName, "metadata.0.name", clonedPVC), - resource.TestCheckResourceAttr(resourceName, "spec.0.data_source.0.persistent_volume_claim.0.claim_name", originalPVC), + resource.TestCheckResourceAttr(resourceName, "spec.0.data_source.0.name", originalPVC), ), }, }, @@ -1055,9 +1055,7 @@ func testAccKubernetesPersistentVolumeClaimV1Config_dataSourceClone(sourceName, } data_source { - persistent_volume_claim { - claim_name = "%s" - } + name = "%s" } } diff --git a/kubernetes/schema_persistent_volume_claim.go b/kubernetes/schema_persistent_volume_claim.go index a536974201..147d09fd51 100644 --- a/kubernetes/schema_persistent_volume_claim.go +++ b/kubernetes/schema_persistent_volume_claim.go @@ -73,20 +73,10 @@ func persistentVolumeClaimSpecFields() map[string]*schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "persistent_volume_claim": { - Type: schema.TypeList, - Description: "Details of the source PersistentVolumeClaim.", + "name": { + Type: schema.TypeString, + Description: "The name of the source PersistentVolumeClaim.", Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "claim_name": { - Type: schema.TypeString, - Description: "The name of the source PersistentVolumeClaim.", - Required: true, - }, - }, - }, }, }, }, diff --git a/kubernetes/structure_persistent_volume_claim.go b/kubernetes/structure_persistent_volume_claim.go index 41637a6dd8..c36a68da9a 100644 --- a/kubernetes/structure_persistent_volume_claim.go +++ b/kubernetes/structure_persistent_volume_claim.go @@ -29,16 +29,12 @@ func flattenPersistentVolumeClaimSpec(in corev1.PersistentVolumeClaimSpec) []int if in.VolumeMode != nil { att["volume_mode"] = in.VolumeMode } - if in.DataSource != nil { - dataSource := make(map[string]interface{}) - if in.DataSource.Kind == "PersistentVolumeClaim" && in.DataSource.Name != "" { - dataSource["persistent_volume_claim"] = []interface{}{ - map[string]interface{}{ - "claim_name": in.DataSource.Name, - }, - } + if in.DataSource != nil && in.DataSource.Name != "" { + att["data_source"] = []interface{}{ + map[string]interface{}{ + "name": in.DataSource.Name, + }, } - att["data_source"] = []interface{}{dataSource} } return []interface{}{att} } @@ -104,13 +100,11 @@ func expandPersistentVolumeClaimSpec(l []interface{}) (*corev1.PersistentVolumeC } if v, ok := in["data_source"].([]interface{}); ok && len(v) > 0 && v[0] != nil { dataSource := v[0].(map[string]interface{}) - if pvcSource, ok := dataSource["persistent_volume_claim"].([]interface{}); ok && len(pvcSource) > 0 && pvcSource[0] != nil { - pvcData := pvcSource[0].(map[string]interface{}) - if claimName, ok := pvcData["claim_name"].(string); ok && claimName != "" { - obj.DataSource = &corev1.TypedLocalObjectReference{ - Kind: "PersistentVolumeClaim", - Name: claimName, - } + if name, ok := dataSource["name"].(string); ok && name != "" { + obj.DataSource = &corev1.TypedLocalObjectReference{ + Kind: "PersistentVolumeClaim", + Name: name, + APIGroup: ptr.To(""), } } }