gravitational / protoc-gen-terraform

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

Device credential conversion to terraform is not working #31

Open flyinghermit opened 1 year ago

flyinghermit commented 1 year ago

Device credential data is not getting converted to terraform. Results in null state

message DeviceCredential {
  string id = 1 [(gogoproto.jsontag) = "id"];
  bytes public_key_der = 2 [(gogoproto.jsontag) = "public_key_der"];
}
type DeviceCredential struct {
    Id                   string   `protobuf:"bytes,1,opt,name=id,proto3" json:"id"`
    PublicKeyDer         []byte   `protobuf:"bytes,2,opt,name=public_key_der,json=publicKeyDer,proto3" json:"public_key_der"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}
flyinghermit commented 1 year ago

Is it possibly because of issue with []byte <> string type conversion? Here's generated schema for credential.

"credential": {
    Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{
        "id": {
            Description: "",
            Optional:    true,
            Type:        github_com_hashicorp_terraform_plugin_framework_types.StringType,
        },
        "public_key_der": {
            Description: "",
            Optional:    true,
            Type:        github_com_hashicorp_terraform_plugin_framework_types.StringType,
        },
    }),
    Description: "",
    Optional:    true,
},

Notice PublicKeyDer as StringType, though that's defined as bytes in protos.