diff --git a/apstra/design/tag.go b/apstra/design/tag.go index b9b34772..9de8471b 100644 --- a/apstra/design/tag.go +++ b/apstra/design/tag.go @@ -115,9 +115,9 @@ func (o Tag) AttrTypes() map[string]attr.Type { } } -func (o *Tag) LoadApiData(_ context.Context, in *apstra.DesignTagData, _ *diag.Diagnostics) { +func (o *Tag) LoadApiData(ctx context.Context, in *apstra.DesignTagData, diags *diag.Diagnostics) { o.Name = types.StringValue(in.Label) - o.Description = types.StringValue(in.Description) + o.Description = utils.StringValueOrNull(ctx, in.Description, diags) } func (o *Tag) Request(_ context.Context, _ *diag.Diagnostics) *apstra.DesignTagRequest { diff --git a/apstra/resource_tag.go b/apstra/resource_tag.go index 4039f450..3b9ae56a 100644 --- a/apstra/resource_tag.go +++ b/apstra/resource_tag.go @@ -73,20 +73,17 @@ func (o *resourceTag) Read(ctx context.Context, req resource.ReadRequest, resp * resp.State.RemoveResource(ctx) return } - resp.Diagnostics.AddError("error reading Tag", err.Error()) + resp.Diagnostics.AddError("failed reading Tag", err.Error()) return } - // create new state object - var newState design.Tag - newState.Id = types.StringValue(string(t.Id)) - newState.LoadApiData(ctx, t.Data, &resp.Diagnostics) + state.LoadApiData(ctx, t.Data, &resp.Diagnostics) if resp.Diagnostics.HasError() { return } // set state - resp.Diagnostics.Append(resp.State.Set(ctx, &newState)...) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) } // Update resource