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

fix cluster role binding namespace handling

Open JaylonmcShan03 opened this issue 1 year ago • 2 comments

Description

Fixes #710 This PR addresses and fixes the handling of namespaces in the kubernetes_cluster_role_binding_v1 resource

I am looking for feedback on my fix! Initially, I implemented logic in structures_rbac.go to handle namespace values directly. However, during acceptance testing, I encountered plan difference errors, where the namespace field was toggling between "default" and null. These differences caused Terraform to repeatedly attempt updates, believing the resource was not in the desired state.

To address this issue, I modified the schema to include diff suppression for the namespace field: Diff suppression ensures that when the namespace field is either "default" (defaulted by Kubernetes) or null (irrelevant for Group and User), Terraform does not detect a difference.

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:

$ make testacc TESTARGS='-run=TestAccXXX'

...
irectory=/var/folders/bp/l16ph9cj7958ml9t254_zcv00000gn/T/plugintest2388791179 test_step_number=1
2024-11-25T08:43:36.326-0600 [DEBUG] sdk.helper_resource: Finished TestCase: test_name=TestAccKubernetesClusterRoleBindingV1_namespaceHandling
--- PASS: TestAccKubernetesClusterRoleBindingV1_namespaceHandling (1.77s)
PASS
ok      github.com/hashicorp/terraform-provider-kubernetes/kubernetes

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 Nov 25 '24 17:11 JaylonmcShan03