Skip to content

Commit

Permalink
fix: prevent client resource needing update upon ADG Home instance re…
Browse files Browse the repository at this point in the history
…start (#25)
  • Loading branch information
gmichels authored Mar 27, 2023
1 parent 761843b commit 576040f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions adguard/client_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,14 @@ func (r *clientResource) Read(ctx context.Context, req resource.ReadRequest, res
if resp.Diagnostics.HasError() {
return
}
state.Upstreams, diags = types.ListValueFrom(ctx, types.StringType, client.Upstreams)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
// API response returns an actual empty list instead of null for upstreams, therefore
// only make the conversion if there are any upstreams
if len(client.Upstreams) > 0 {
state.Upstreams, diags = types.ListValueFrom(ctx, types.StringType, client.Upstreams)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
}
state.Tags, diags = types.ListValueFrom(ctx, types.StringType, client.Tags)
resp.Diagnostics.Append(diags...)
Expand Down

0 comments on commit 576040f

Please sign in to comment.