gavinbunney / terraform-provider-kubectl

Terraform provider to handle raw kubernetes manifest yaml files
https://registry.terraform.io/providers/gavinbunney/kubectl
Mozilla Public License 2.0
619 stars 105 forks source link

fix: prevent inconsistent planning #198

Open zenobios opened 2 years ago

zenobios commented 2 years ago

This PR fixes the issue reported in #162 by resetting yaml_body_parsed and yaml_incluster in case yaml_body has been changed.

barryib commented 2 years ago

@gavinbunney hope you're doing well. Any chance to review this PR please ?

nestor-lobo-work commented 1 year ago

@gavinbunney I see this change from @zenobios is still pending from some time ago

Would that be possible to be reviewed in the short term? I am suffering exact same issue and believe it could be solved with this change in place

Thanks in advance

AmitKatyal-Sophos commented 1 year ago

@gavinbunney blocked on this issue. Can we please review it ? Thanks!

AmitKatyal-Sophos commented 1 year ago

@zenobios the actual issue is in the terraform ? Why NewValueKnown for the "yaml_body" key is returning false ? It should have returned true right ?. If any change in the yaml body is not working, then very basic use-case of update of the manifest is not working. Am I missing something here ?

AmitKatyal-Sophos commented 1 year ago

@nestor-lobo-work creating the resource using the templatefile seems to be working fine.

resource "kubectl_manifest" "argocd_apps" { for_each = XXXXX yaml_body = templatefile("${path.module}/manifests/apps.yaml", { }) wait = "true" }

tamirsagi commented 1 year ago

I built it locally including that fix, however it still failed due to inconsistent plan.

Adphi commented 1 year ago

Thanks @zenobios for you work on this. It seems to work for me when template variables are updated from other resources. I've forwarded the pull request here https://github.com/alekc/terraform-provider-kubectl/pull/46

alekc commented 1 year ago

Released in "2.0.3-rc2". Please test if that version covered your usecases.

terraform {
  required_providers {
    kubectl = {
      source = "alekc/kubectl"
      version = "2.0.3-rc2"
    }
  }
}

Cheers