kbst / terraform-provider-kustomization

Terraform provider for Kustomize
https://www.kubestack.com
Apache License 2.0
270 stars 53 forks source link

fix `unexpected end of JSON input` during planning #221

Closed nazarewk closed 1 year ago

nazarewk commented 1 year ago

github.com/kbst/terraform-provider-kustomize/kustomize.kustomizationResourceDiff: github.com/kbst/terraform-provider-kustomize/kustomize.(*kManifest).load: json error: unexpected end of JSON input

not sure if it's the right way to go, but my workday is now over and i still want to share the findings

fixes #219

nazarewk commented 1 year ago

I've tried refactoring to see if there would be any code left after IF-ing everything depending on new value, but there wasn't anything left except loading old manifest, so it's mostly just improved error message and returning early without errors.

can I get a review @pst ?

nazarewk commented 1 year ago

I've noticed the same error happens during update after I delete last-applied config from a resource

wpbeckwith commented 1 year ago

What's the status on this issue? I can see it's being worked, more so trying to get an idea if we need to actually do something or wait for an imminent fix.

pst commented 1 year ago

I finally found the time to look into this, and I unfortunately have to tell you that I have decided to not merge this.

I don't see any real world situation where this is an issue, your prerender "hack" to work around the for_each limitation with known after apply values is not a valid use in my opinion. If you depend on values that are known after apply, avoid the for_each by having one kustomization_resource per K8s resource. Or fall back to the apply --target as suggested by Terraform.

If there are valid uses where the provider crashes because of such an issue