gravitational / protoc-gen-terraform

Generates Terraform provider schemas and unmarshallers from protobuf definitions
Apache License 2.0
17 stars 5 forks source link

Add support for embedded fields #29

Closed marcoandredinis closed 1 year ago

marcoandredinis commented 1 year ago

When there's an embed proto field (extension (gogoproto.embed) = true) we need to embed the message's fields into the current message.

So this:

message DeviceV1 {
  ResourceHeader Header = 1 [(gogoproto.embed) = true];
  string other = 2;
}
message ResourceHeader {
  string Kind = 1;
}

Should become the following tfschema:

kind: string
other: string

However, we were creating the following schema:

header:
  kind: string
other: string

This PR changes this to support embedding those fields. I did a manual test for the DeviceTrust resource which we are about to add support for in Teleport's Terraform provider.

TODO

flyinghermit commented 1 year ago

@nklaassen Tagging you as reviewer since you are also reviewing https://github.com/gravitational/teleport-plugins/pull/801

flyinghermit commented 1 year ago

Friendly ping for code owner review please @r0mant

flyinghermit commented 1 year ago

Thanks everyone for review.