Hello,
I am building a provider with a model struct using the jsontypes.Normalized. I have to convert the struct to, and from, types.Object. Hence I wrote the function that expose the types. However I am unable to use jsontypes.NormalizedTypes for the “form” attribute:
# github.com/davidfischer-ch/terraform-provider-aria/internal/provider
internal\provider\custom_form_model.go:123:18: jsontypes.NormalizedType (type) is not an expression
FAIL github.com/davidfischer-ch/terraform-provider-aria/internal/provider [build failed]
FAIL
+ popd
The relevant sections of code :
// CustomFormModel describes the resource data model.
type CustomFormModel struct {
Id types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
Type types.String `tfsdk:"type"`
Form jsontypes.Normalized `tfsdk:"form"`
FormFormat types.String `tfsdk:"form_format"`
Styles types.String `tfsdk:"styles"`
SourceId types.String `tfsdk:"source_id"`
SourceType types.String `tfsdk:"source_type"`
Tenant types.String `tfsdk:"tenant"`
Status types.String `tfsdk:"status"`
}
// Used to convert structure to a types.Object.
func CustomFormModelAttributeTypes() map[string]attr.Type {
return map[string]attr.Type{
"id": types.StringType,
"name": types.StringType,
"type": types.StringType,
"form": jsontypes.NormalizedType,
"form_format": types.StringType,
"styles": types.StringType,
"source_id": types.StringType,
"source_type": types.StringType,
"tenant": types.StringType,
"status": types.StringType,
}
}
I do not see what I have to do in order for this code to compile.
I previously declared form as types.StringType however Terraform complained that the response, when saving in state the object, was wrong (String vs Normalized) … I think its not the path.
Thank you for any guidance.
Best Regards,
David