From fd2828a3af93640f9905be73b731e98e3744411d Mon Sep 17 00:00:00 2001 From: shireesh gadidesi Date: Thu, 12 Dec 2024 11:52:51 -0800 Subject: [PATCH] removed prefix --- api/protogen/protogen.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/api/protogen/protogen.go b/api/protogen/protogen.go index b1b71e0..f24491d 100644 --- a/api/protogen/protogen.go +++ b/api/protogen/protogen.go @@ -154,7 +154,7 @@ func GenerateGRPCAPISpec(dst io.Writer, src schema.Schema, tagger *apiSpecTagger for _, attrName := range attrNames { attrSchema := resource.Schema.Attributes[attrName] - repeated, t, msg, err := terraformAttributeTypeToProtoType(attrName, attrSchema.GetType(), resourceName) + repeated, t, msg, err := terraformAttributeTypeToProtoType(attrName, attrSchema.GetType()) if err != nil { return fmt.Errorf("failed to parse field %s in resource %s: %w", attrName, resourceMessageName, err) } @@ -249,7 +249,7 @@ func GenerateGRPCAPISpec(dst io.Writer, src schema.Schema, tagger *apiSpecTagger } // terraformAttributeTypeToProtoType converts a Terraform attribute type into the corresponding Protocol Buffer type, and optionally additional Protocol Buffer messages that represent nested types. -func terraformAttributeTypeToProtoType(attrName string, attrType attr.Type, prefix string) (repeated bool, protoType string, messages *message, err error) { +func terraformAttributeTypeToProtoType(attrName string, attrType attr.Type) (repeated bool, protoType string, messages *message, err error) { switch v := attrType.(type) { case basetypes.BoolType: return false, "bool", nil, nil @@ -260,7 +260,7 @@ func terraformAttributeTypeToProtoType(attrName string, attrType attr.Type, pref case basetypes.StringType: return false, "string", nil, nil case types.ListType: - toProtoType, s, m, err := terraformRepeatedAttributeTypeToProtoType(attrName, v.ElementType(), prefix) + toProtoType, s, m, err := terraformRepeatedAttributeTypeToProtoType(attrName, v.ElementType()) if err != nil { return false, "", nil, err } @@ -272,9 +272,9 @@ func terraformAttributeTypeToProtoType(attrName string, attrType attr.Type, pref return toProtoType, s, m, nil case types.SetType: - return terraformRepeatedAttributeTypeToProtoType(attrName, v.ElementType(), prefix) + return terraformRepeatedAttributeTypeToProtoType(attrName, v.ElementType()) case types.ObjectType: - return terraformObjectAttributeTypeToProtoType(attrName, v.AttrTypes, prefix) + return terraformObjectAttributeTypeToProtoType(attrName, v.AttrTypes) default: return false, "", nil, fmt.Errorf("unsupported Terraform type: %s", attrType.String()) @@ -282,7 +282,7 @@ func terraformAttributeTypeToProtoType(attrName string, attrType attr.Type, pref } // Converts a Terraform object attribute to a Protocol Buffer message type. -func terraformObjectAttributeTypeToProtoType(attrName string, attrTypes map[string]attr.Type, prefix string) (repeated bool, protoType string, messages *message, err error) { +func terraformObjectAttributeTypeToProtoType(attrName string, attrTypes map[string]attr.Type) (repeated bool, protoType string, messages *message, err error) { messageName := schema.ProtoMessageName(attrName) newMessage := &message{ Name: messageName, @@ -290,7 +290,7 @@ func terraformObjectAttributeTypeToProtoType(attrName string, attrTypes map[stri } for name, attrType := range attrTypes { - repeated, t, msg, err := terraformAttributeTypeToProtoType(name, attrType, schema.ProtoMessageName(prefix)+schema.ProtoMessageName(messageName)) + repeated, t, msg, err := terraformAttributeTypeToProtoType(name, attrType) if err != nil { return false, "", nil, fmt.Errorf("failed to parse field %s in object %s: %w", name, attrName, err) } @@ -314,8 +314,8 @@ func terraformObjectAttributeTypeToProtoType(attrName string, attrTypes map[stri return false, messageName, newMessage, nil } -func terraformRepeatedAttributeTypeToProtoType(attrName string, elementType attr.Type, prefix string) (repeated bool, protoType string, messages *message, err error) { - elemRepeated, elemProtoType, elemMessage, err := terraformAttributeTypeToProtoType(attrName, elementType, prefix) +func terraformRepeatedAttributeTypeToProtoType(attrName string, elementType attr.Type) (repeated bool, protoType string, messages *message, err error) { + elemRepeated, elemProtoType, elemMessage, err := terraformAttributeTypeToProtoType(attrName, elementType) switch { case err != nil: