-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: Make json structs exported #332
Comments
Hi @wata727! Thanks for sharing this use-case. I'm a little concerned with the idea of sending expression nodes via The problem of sending not-yet-evaluated expressions over the wire to be evaluated later was something I started exploring in With that said, I continue to believe that the best way to send HCL expressions over a wire protocol for evaluation elsewhere is in their source form rather than in their decoded form, because the source syntax is already a compatibility constraint and is already pretty compact. The challenge is what makes a good API for dealing with that on both the producer and consumer sides, which each have some challenges:
I'd rather continue down this investigation path than create new compatibility constraints on the implementation details of the |
@apparentlymart Thank you for your quick reply! I totally agree with your opinion that the source code is the preferred format for transmission. By the way, I think a similar problem can be considered in |
Hi @wata727, The HCL decoding API was designed to ensure that only attribute values can require dynamic data from an While sending the source code for a specific block over a wire protocol could work in principle, it seems like quite a complicated way to handle it and I expect it would have a lot more edge-cases to deal with. Terraform takes an approach like this with its provider plugins: the plugins are required to report to Terraform ahead of time what schema they are expecting, and then Terraform handles the decoding step using that schema. In Terraform's case the expression evaluation also happens in prior to calling the provider plugins, but expression evaluation is a separate step so in principle it could be done on the provider plugin side, using a mechanism like we're describing, without affecting how the overall structure is decoded. With that said, I think our existing |
Unlike hclsyntax, the json struct is unexported:
hcl/json/structure.go
Line 14 in 3aa4a2e
hcl/json/structure.go
Line 25 in 3aa4a2e
hcl/json/ast.go
Line 9 in 3aa4a2e
Can we make these exported? If possible, I'm going to make a PR.
Background
I'm planning to build a plugin to send and receive structs that satisfy
hcl.Expression
with go-plugin. However, to handle an interface, we need togob.Register
structs that satisfies it.hclsyntax is exported, so we can
gob.Regitser
from outside of the package, but json is not exported, so we cannot avoid the following errors:The text was updated successfully, but these errors were encountered: