terraform-provider-kubernetes
terraform-provider-kubernetes copied to clipboard
add field for PersistentVolumeClaim resource
Description
Addresses #2608
This pull request introduces the data_source field for the PersistentVolumeClaim resource.
Changes
- Added
data_sourcefield to the PersistentVolumeClaim schema. - Implemented validation in the
Createfunction to ensure the specifieddata_sourcePVC exists. - 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
@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
@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
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 😄
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?
Another nag, anyone still looking at this? It is a major accepted part of Kubernetes PVCs now.