hashicorp / terraform-provider-kubernetes

Terraform Kubernetes provider
https://www.terraform.io/docs/providers/kubernetes/
Mozilla Public License 2.0
1.6k stars 979 forks source link

Return current state when requesting deferral. #2570

Closed alexsomesan closed 3 months ago

alexsomesan commented 3 months ago

Description

Returns current state durring planning and reading resources that require deferral. This is to correlate with new expectations of Terraform core introduced in: https://github.com/hashicorp/terraform/pull/35526

Testing this change requires running with an up-to-date build of Terraform, that includes the above mentioned PR. A build from current main would be ideal.

Acceptance tests

Output from acceptance testing:

Without this change:

$ go test -v -run '^TestAccKubernetesDeferredActions' ./kubernetes/test-dfa
=== RUN   TestAccKubernetesDeferredActions_2_step
    deferred_actions_test.go:28: Step 1/3 error: Error running pre-apply plan: exit status 1

        Error: Attempt to get attribute from null value

          on workspace.tf line 13, in resource "kubernetes_manifest" "demo_workspace":
          13:     kind       = kubernetes_manifest.crd_workspaces.object.spec.names.kind
            ├────────────────
            │ kubernetes_manifest.crd_workspaces.object is null

        This value is null, so it does not have any attributes.
--- FAIL: TestAccKubernetesDeferredActions_2_step (4.35s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-kubernetes/kubernetes/test-dfa  5.424s
FAIL

With this change:

$ go test -v -run '^TestAccKubernetesDeferredActions' ./kubernetes/test-dfa
=== RUN   TestAccKubernetesDeferredActions_2_step
--- PASS: TestAccKubernetesDeferredActions_2_step (41.58s)
PASS
ok      github.com/hashicorp/terraform-provider-kubernetes/kubernetes/test-dfa  42.673s

Release Note

Release note for CHANGELOG:

deferred actions: return unknown value instead of nil when requesting deferral of a planned resource change.

References

Community Note