Skip to content

manifest: add support for explicit elements in computedFields #2436

Open
@BBBmau

Description

@BBBmau

Description

We only support computedFields attributes, if a user attempts to be explicit with computedFields they will get a vanished output:

│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to kubernetes_manifest.deployment_resource_diff, provider
│ "provider[\"registry.terraform.io/hashicorp/kubernetes\"]" produced an unexpected new value:
│ .object.spec.template.spec.containers[0].resources.limits: element "cpu" has vanished.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

What's the value in being able to support this? Of course the work around is to just set the attribute as computedFields where the element exists, though it also would be good to give users that option of being explicit also.

A related issue where a user brings this up, advice was to just set attributes to computedFields

#1530

Potential Terraform Configuration

Any tfconfig will do where you attempt to set an element in computedFields

resource "kubernetes_manifest" "deployment_resource_diff" {
computed_fields = ["spec.template.spec.containers[0].resources.limits[\"cpu\"]"]
    manifest = {
        apiVersion = "apps/v1"
        kind       = "Deployment"

        metadata = {
            name = "deployment-resource-diff"
            namespace = "default"
        }

        spec = {
    replicas = 3

    selector = {
      matchLabels = {
        test = "MyExampleApp"
      }
    }

    template = {
      metadata= {
        labels = {
          test = "MyExampleApp"
        }
      }
      

      spec = {
        containers = [{
          image = "nginx:1.21.6"
          name  = "example"

          resources = {
            limits = {
              cpu    = "0.5"
              memory = "512Mi"
            }
            requests = {
              cpu    = "250m"
              memory = "50Mi"
            }
          }
        }]
      }
    }
  }
        }
    }

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions