encoding/cuedata: Add CUEdata package #1434
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduces a new (en|de)coder to covert any CUE file to and from a literal data format. Non concrete expressions in each struct are serialized into a syntax string and added as a field, labelled
$$cue
.This allows for CUE files to be stored and transmitted as structured data. Our use case at balena is to store CUE files in a document database and query against the concrete values, the resulting documents can then be decoded back to CUE and evaluated as CUE. I think others would share a similar use case, hence I am creating this PR. If this is not acceptable, we will create it as a standalone tool.
I have named the format
CUEdata
, but I am open to alternatives. I see in issue #130QSON
as in "Q (CUE) Strict Object Notation" andCUEL
as in "CUE Literal" were suggested.This address #1250, for our needs its a more complete solution than JSONSchema, since it allows the document to contain arbitrarily complex CUE expressions that could not be encoded as JSONSchema.
I am new to the Go language and this is an implementation by imitation, I have probably copied some techniques that the CUE code base would like to move away from. I am not aware of all the Go idioms. Please feel free to let me know any better solutions.
Resolves #1435