talos
talos copied to clipboard
generator for protobuf representation of COSI resources
Feature Request
Convert native Go struct which represents a resource (e.g. LinkStatusSpec) to a .proto file under api/resources/... and methods MarshalToProto, UnmarshalFromProto.
Description
https://github.com/src-d/proteus
https://github.com/kubernetes/code-generator/tree/master/cmd/go-to-protobuf
🆒
- [x] Manually implement proto messages for common structures and converters from/to original types
- [x] github.com/talos-systems/crypto/x509.PEMEncodedCertificateAndKey
- [x] github.com/talos-systems/crypto/x509.PEMEncodedKey
- [x] netaddr.IP (maybe it have default represenation?)
- [x] netaddr.IPPort
- [x] netaddr.IPPrefix
- [x] Investigate other common types
- [x] Unstructured type which can be constructed from\to JSON
- [x] Rewrite structure fields with "protobuf" tags - 'protobuf:<field_number>'
- [x] Investigate if we can use https://github.com/quasilyte/go-ruleguard
- [x] Investigate if we can use gofix existing source
- [x] Given pkg it should update every *Spec struct which is included in Resources.
- [x] Implement encoder/decoder "generation" - generate the source code or implement it in runtime
- [x] Start with simple struct
- [x] Add usage of common structures
- [x] Maybe try with reflection based implementation first?
- [x] Generate proto files for *Spec structures
- [x] Decide between talos resource API and cosi resource API (or maybe something in between)
- [x] Remove everywhere (talosctl for example) YAML hacks
Split it into several self-contained PR's.
See also:
- https://developers.google.com/protocol-buffers/docs/encoding
- https://pkg.go.dev/google.golang.org/[email protected]/encoding/protowire
- Maybe look for Kubernetes marshaller K8s resources? (https://github.com/kubernetes/apimachinery/tree/master/pkg/runtime/serializer/protobuf)
- https://developers.google.com/protocol-buffers/docs/reference/csharp/namespace/google/protobuf/well-known-types
- https://developers.google.com/protocol-buffers/docs/reference/google.protobuf