Comments (3)
I found that Terraform declares a proto message to serialize cty.Path
.
https://github.com/hashicorp/terraform/blob/v1.3.9/docs/plugin-protocol/tfplugin6.3.proto#L43-L56
Is this approach preferable?
from go-cty.
Hi @wata727,
Terraform also has some functions that produce JSON representation of paths, it seems: https://github.com/hashicorp/terraform/blob/729408333e3c0de2ae42207bb9147bf240cfad7b/internal/command/jsonplan/plan.go#L824
It feels a little weird to me to implement a "standard" JSON serialisation of a concept that doesn't really exist in JSON. Of course the same argument could be made for types, but those ended up having a JSON serialisation because it was necessary for it to be possible to encode to DynamicPseudoType
; it doesn't seem so important for this package to define a serialisation for paths because each application can decide its own serialisation depending on what it needs to capture. For example, it seems like what Terraform is doing in the code I linked above is "lossy", I think because this Terraform format is designed with the assumption that the consumer knows the resource type schema and so can infer automatically what each element of the path represents.
As you saw, Terraform also uses a protocol buffers version of this information in the plugin wire protocol, which I think was desirable because it avoided an extra level of encoding and decoding since this protocol is already using protocol buffers for other reasons.
Therefore my instinct is to not define some fixed serialisation of these paths and instead leave each application to choose a suitable serialisation based on its own constraints and requirements.
Would that work for you, or does your goal rely on this being built in to this library? Thanks!
from go-cty.
Thank you for your reply. At first, I thought this proposal was reasonable because I didn't understand why only cty.Type
and cty.Value
implement a JSON serialization, but your explanation made me understand.
As with Terraform, I'm going to implement our own serialization in our application. Thanks again!
from go-cty.
Related Issues (20)
- 1.11.0 causes errors with //go:generate packer-sdc mapstructure-to-hcl2 HOT 1
- hashicorp/packer-plugin-sdk incompatible with zclconf/go-cty v1.11.0 HOT 4
- TestFormatDate fails with upcoming Go 1.20 release HOT 5
- Add support for decoding into structs with a custom tag HOT 1
- Nested go struct to cty value fails HOT 1
- cty/json: configure (non-)HTML-escaping serialization HOT 3
- stdlib: SetProductFunc doesn't seem to handle refinements quite right HOT 2
- How to convert cty.Value of unknown type into `interface{}` HOT 2
- cty.StringVal always doubles $ in `${}` output HOT 2
- Parse string into cty type HOT 1
- cty.StringVal always doubles $ in ${} output Pt2 HOT 1
- adding jsonencode() block into a generated terraform file using golang cty HOT 2
- Encoding values with custom function (terraform provider) HOT 1
- Marshal() generate invalid JSON HOT 2
- panic with `AsString()` on result of json encoding of to_number conversion of null value HOT 4
- Some valid `Path` values cannot be applied to their source `Value` HOT 2
- Add a deepmerge function HOT 1
- `ObjectVal` or `MapVal `without `NormalizeString` HOT 6
- Some method to avoid the lexicographical order when parsing tokens HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-cty.