Hello,
I am getting error while targetting new SDK 1.0
below is my error
│ Path: members
│ Target Type: hashicups.membersModelQ
│ Suggested Type: basetypes.ListValue
Below is my go.mod
github.com/hashicorp/terraform-plugin-framework v1.0.0
github.com/hashicorp/terraform-plugin-go v0.14.2
github.com/hashicorp/terraform-plugin-sdk/v2 v2.23.0
below is my code for resource[Create]
type orderResourceModel struct {
ID types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
Members []membersModelQ `tfsdk:"members"`
}
type membersModelQ struct {
Name types.String `tfsdk:"name"`
Surname types.String `tfsdk:"surname"`
}
func (r *orderResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "Fetches the list of family members.",
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Description: "Placeholder identifier attribute.",
Required: true,
},
"name": schema.StringAttribute{
Description: "Placeholder identifier attribute.",
Computed: true,
},
"members": schema.ListNestedAttribute{
Description: "Placeholder identifier attribute.",
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Description: "Placeholder identifier attribute.",
Computed: true,
},
"surname": schema.StringAttribute{
Description: "Placeholder identifier attribute.",
Computed: true,
},
},
},
},
},
}
}
func (r *orderResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
var plan orderResourceModel
diags := req.Plan.Get(ctx, &plan)
resp.Diagnostics.Append(diags...)
tflog.Debug(ctx, "[here] error in plan ")
if resp.Diagnostics.HasError() {
return
}
id := uuid.New()
plan.Name = types.StringValue(id.String())
// plan.Members = []membersModelQ{
// {
// Name: types.StringValue("some"),
// Surname: types.StringValue("some"),
// },
// }
tflog.Debug(ctx, "[here] "+PrettyJson(plan))
diags = resp.State.Set(ctx, plan)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
}
below is my config
resource "family_adopt" "edu" {
id = "someid"
}
output "family_adopt" {
value = family_adopt.edu
}
Basically I am trying add list of object/s to member which is computed field and will be populated after apply.
Hope someone can help here
Thanks in advance.