cuelang/cue

Exporting binary & text protos via protoreflect

thomas-wk opened this issue · 1 comments

Is your feature request related to a problem? Please describe.
Emitting protobin/prototxt from cue data that matches an imported proto schema and additional constraints is useful for integrating with builds, tests and running systems.

Describe the solution you'd like
Add an export option that consumes a proto filedescriptorset and uses protoreflect to dynamically create a message for data that matches an existing schema annotated with @protobuf. Add options to emit either binary or txt format proto.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Using data in @protobuf to generate raw protowire format. There is not enough information in the attribute today (eg should a field be encoded in fixed64 or varint?) and it is a much bigger effort / room for error than letting protoreflect do the wire encoding.

Using data in @protobuf to emit prototxt. The prototxt format is under specified and implementation defined (and there are multiple implementations for every target language). I have much more confidence in the official go proto library to emit prototxt that is widely compatible than rolling yet another prototxt producer from first principles.

Emitting json and relying on the reciever to use protojson to decode. This occasionally requires downstream changes and therefore is not satisfying. (Similar to having downstream consume cue directly).

Additional context
I have a tool built on top of cue golang APIs that does this for me. It's helping me deal with not having all those blaze gcl to proto rules I used to have in a previous life. I'd be happy to send a pr integrating with cue command line if welcome.

This issue has been migrated to cue-lang/cue#1047.

For more details about CUE's migration to a new home, please see cue-lang/cue#1078.