@@ -32,13 +32,13 @@ type dnsZoneResource struct {
3232}
3333
3434type dnsZoneResourceModel struct {
35- ID types.String `tfsdk:"id"`
36- LastUpdated types.String `tfsdk:"last_updated"`
37- Name types.String `tfsdk:"name"`
38- TeamID types.String `tfsdk:"team_id"`
39- TeamSlug types.String `tfsdk:"team_slug"`
40- DnsServers types.List `tfsdk:"dns_servers"`
41- Domain * netlifyDomainModel `tfsdk:"domain"`
35+ ID types.String `tfsdk:"id"`
36+ LastUpdated types.String `tfsdk:"last_updated"`
37+ Name types.String `tfsdk:"name"`
38+ TeamID types.String `tfsdk:"team_id"`
39+ TeamSlug types.String `tfsdk:"team_slug"`
40+ DnsServers types.List `tfsdk:"dns_servers"`
41+ Domain types. Object `tfsdk:"domain"`
4242}
4343
4444func (r * dnsZoneResource ) Metadata (_ context.Context , req resource.MetadataRequest , resp * resource.MetadataResponse ) {
@@ -183,17 +183,18 @@ func (r *dnsZoneResource) Create(ctx context.Context, req resource.CreateRequest
183183 plan .DnsServers , diags = types .ListValueFrom (ctx , types .StringType , dnsServers )
184184 resp .Diagnostics .Append (diags ... )
185185 if dnsZone .Domain == nil {
186- plan .Domain = nil
186+ plan .Domain = types . ObjectNull ( netlifyDomainModel {}. AttributeTypes ())
187187 } else {
188- plan .Domain = & netlifyDomainModel {
188+ plan .Domain , diags = types . ObjectValueFrom ( ctx , netlifyDomainModel {}. AttributeTypes (), netlifyDomainModel {
189189 ID : types .StringValue (dnsZone .Domain .Id ),
190190 Name : types .StringValue (dnsZone .Domain .Name ),
191191 RegisteredAt : types .StringValue (dnsZone .Domain .RegisteredAt .Format (time .RFC3339 )),
192192 ExpiresAt : types .StringValue (dnsZone .Domain .ExpiresAt .Format (time .RFC3339 )),
193193 RenewalPrice : types .StringValue (dnsZone .Domain .RenewalPrice ),
194194 AutoRenew : types .BoolValue (dnsZone .Domain .AutoRenew ),
195195 AutoRenewAt : types .StringValue (dnsZone .Domain .AutoRenewAt .Format (time .RFC3339 )),
196- }
196+ })
197+ resp .Diagnostics .Append (diags ... )
197198 }
198199
199200 _ , _ , err = r .data .client .DNSZonesAPI .EnableDnsZoneIpv6 (ctx , plan .ID .ValueString ()).Execute ()
@@ -244,17 +245,18 @@ func (r *dnsZoneResource) Read(ctx context.Context, req resource.ReadRequest, re
244245 state .DnsServers , diags = types .ListValueFrom (ctx , types .StringType , dnsServers )
245246 resp .Diagnostics .Append (diags ... )
246247 if dnsZone .Domain == nil {
247- state .Domain = nil
248+ state .Domain = types . ObjectNull ( netlifyDomainModel {}. AttributeTypes ())
248249 } else {
249- state .Domain = & netlifyDomainModel {
250+ state .Domain , diags = types . ObjectValueFrom ( ctx , netlifyDomainModel {}. AttributeTypes (), netlifyDomainModel {
250251 ID : types .StringValue (dnsZone .Domain .Id ),
251252 Name : types .StringValue (dnsZone .Domain .Name ),
252253 RegisteredAt : types .StringValue (dnsZone .Domain .RegisteredAt .Format (time .RFC3339 )),
253254 ExpiresAt : types .StringValue (dnsZone .Domain .ExpiresAt .Format (time .RFC3339 )),
254255 RenewalPrice : types .StringValue (dnsZone .Domain .RenewalPrice ),
255256 AutoRenew : types .BoolValue (dnsZone .Domain .AutoRenew ),
256257 AutoRenewAt : types .StringValue (dnsZone .Domain .AutoRenewAt .Format (time .RFC3339 )),
257- }
258+ })
259+ resp .Diagnostics .Append (diags ... )
258260 }
259261
260262 resp .Diagnostics .Append (resp .State .Set (ctx , & state )... )
0 commit comments