rancher / terraform-provider-rancher2

Terraform Rancher2 provider
https://www.terraform.io/docs/providers/rancher2/
Mozilla Public License 2.0
253 stars 216 forks source link

add PSACT custom resource #1302

Closed jiaqiluo closed 4 months ago

jiaqiluo commented 5 months ago

Issue:

https://github.com/rancher/terraform-provider-rancher2/issues/1189

Problem

Rancher v2.7.2 supports a new CRD for Pod Security Admission (PSA) Configuration Templates that can only be created outside of TF manually.

Solution

Add a new resource and data source named rancher2_pod_security_admission_configuration_template for rancher2_pod_security_admission_configuration_template so users can manage custom admission configuration templates via Terraform for RKE and RKE2/K3s clusters.

Testing

Engineering Testing

Manual Testing

Automated Testing

unit test

The standard sets of tests are added for the new Resource & DataSource.

acceptance test

The acceptance tests are added but "disabled" by making the function names lowercase. This is because the current framework does not support running acceptance tests in Rancher v2.7.9 and v2.8.1.

Here is how the acceptance test works:

Steps 3 and 4 are repeated to upgrade and test on Rancher v2.4.13, v2.5.9, and v2.6.2.

To add the tests for the PSACT resource, I tried to add Rancher v2.7.9 and v2.8.1 to the version list. However, it did not work due to the following reasons:

To make the acceptance test work, we need to:

That work is large enough to be a separate task. (Update: the issue was made https://github.com/rancher/terraform-provider-rancher2/issues/1308)

The good news is that the manual and automated tests that QA performs can cover more than the acceptance I planned to add.

QA Testing Considerations

Regressions Considerations

The new resource and data source themselves should not affect anything existing.

QA should validate there is no regression for deleting a rancher2_cluster_v2 resource because one change is made in this PR.