terraform-provider-kubernetes icon indicating copy to clipboard operation
terraform-provider-kubernetes copied to clipboard

add field for PersistentVolumeClaim resource

Open JaylonmcShan03 opened this issue 11 months ago • 4 comments

Description

Addresses #2608

This pull request introduces the data_source field for the PersistentVolumeClaim resource.

Changes

  1. Added data_source field to the PersistentVolumeClaim schema.
  2. Implemented validation in the Create function to ensure the specified data_source PVC exists.
  3. Included the new field in flatten and expand method.

Acceptance tests

  • [x] Have you added an acceptance test for the functionality being added?
  • [x] Have you run the acceptance tests on this branch?

Output from acceptance testing:

2024-12-09T10:14:13.480-0600 [DEBUG] sdk.helper_resource: Called TestCase CheckDestroy: test_step_number=2 test_terraform_path=/opt/homebrew/bin/terraform test_name=TestAccKubernetesPersistentVolumeClaimV1_dataSource test_working_directory=/var/folders/bp/l16ph9cj7958ml9t254_zcv00000gn/T/plugintest3860028569
2024-12-09T10:14:13.482-0600 [DEBUG] sdk.helper_resource: Finished TestCase: test_name=TestAccKubernetesPersistentVolumeClaimV1_dataSource
--- PASS: TestAccKubernetesPersistentVolumeClaimV1_dataSource (3.21s)
PASS
ok      github.com/hashicorp/terraform-provider-kubernetes/kubernetes   3.824s
jaylon.mcshan@jaylon terraform-provider-kubernetes % 


2024-12-09T10:15:00.499-0600 [DEBUG] sdk.helper_resource: Started sdkv2 provider instance server: tf_provider_addr=registry.terraform.io/hashicorp/kubernetes test_name=TestAccKubernetesPersistentVolumeClaimV1_invalidDataSource test_terraform_path=/opt/homebrew/bin/terraform test_working_directory=/var/folders/bp/l16ph9cj7958ml9t254_zcv00000gn/T/plugintest1113338307 test_step_number=1
2024-12-09T10:15:00.558-0600 [DEBUG] sdk.helper_resource: Stopping providers: test_working_directory=/var/folders/bp/l16ph9cj7958ml9t254_zcv00000gn/T/plugintest1113338307 test_step_number=1 test_name=TestAccKubernetesPersistentVolumeClaimV1_invalidDataSource test_terraform_path=/opt/homebrew/bin/terraform
2024-12-09T10:15:00.560-0600 [DEBUG] sdk.helper_resource: Finished TestCase: test_name=TestAccKubernetesPersistentVolumeClaimV1_invalidDataSource
--- PASS: TestAccKubernetesPersistentVolumeClaimV1_invalidDataSource (0.51s)
PASS
ok      github.com/hashicorp/terraform-provider-kubernetes/kubernetes   1.248s
jaylon.mcshan@jaylon terraform-provider-kubernetes %
$ make testacc TESTARGS='-run=TestAccXXX'

...

Release Note

Release note for CHANGELOG:

...

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

JaylonmcShan03 avatar Dec 09 '24 16:12 JaylonmcShan03

@BBBmau The kind and apiGroup field is actually very important in the stable API. It is possible to specify the dataSource as either a VolumeSnapshot or a PVC. You need the kind field to differentiate in that case you have both with the same name.

https://kubernetes.io/docs/concepts/storage/persistent-volumes/#create-persistent-volume-claim-from-volume-snapshot https://kubernetes.io/docs/concepts/storage/persistent-volumes/#create-persistent-volume-claim-from-an-existing-pvc

evilhamsterman avatar Jan 09 '25 19:01 evilhamsterman

@BBBmau The kind and apiGroup field is actually very important in the stable API. It is possible to specify the dataSource as either a VolumeSnapshot or a PVC. You need the kind field to differentiate in that case you have both with the same name.

kubernetes.io/docs/concepts/storage/persistent-volumes#create-persistent-volume-claim-from-volume-snapshot kubernetes.io/docs/concepts/storage/persistent-volumes#create-persistent-volume-claim-from-an-existing-pvc

This makes sense, not sure how I glanced over that. Thanks for bringing it up.

cc: @JaylonmcShan03

BBBmau avatar Jan 09 '25 19:01 BBBmau

Just tapping in @JaylonmcShan03 are you able to update the PR to add support for the kind and apiGroup fields? They are important to the dataSource support which has been stable for awhile so it's long due for the terraform plugin. Plus I'm personally waiting on it for a project 😄

evilhamsterman avatar Jan 27 '25 18:01 evilhamsterman

Sorry to nag, but I've been waiting for this update to unblock some functionality at work. Any update on when this will get updated and merged?

evilhamsterman avatar Mar 13 '25 17:03 evilhamsterman

Another nag, anyone still looking at this? It is a major accepted part of Kubernetes PVCs now.

evilhamsterman avatar Jul 30 '25 16:07 evilhamsterman