Hi Team,
I have below resource model, actually BackupDatacenter is also the type of DatacenterResourceModel, but BackupDatacenter don’t have property Location
, I don’t want to define another BackupDatacenterResourceModel
which excluded location
type DatacenterResourceModel struct {
Id types.Int64 `tfsdk:"id"`
Date types.Int64 `tfsdk:"date"`
Location types.String `tfsdk:"location"`
BackupDatacenter types.Object `tfsdk:"backup_ datacenter"`
}
However when I tried to use below code to convert the input d.BackupDatacenter to DatacenterResourceModel, it doesn’t work and give me error.
var backup DatacenterResourceModel
diags = append(diags, tfsdk.ValueAs(ctx, d.BackupDatacenter, &backup)...)
Error:
Looks return reflect.Into(ctx, val.Type(ctx), raw, target, reflect.Options{}, path.Empty())
there is reflect.Options{} to skip the non-exist property, but how can do it ? is there solution to help me fix this issue ?