Skip to content

Commit

Permalink
Adding further test coverage for PlanResourceChange() for map, set an…
Browse files Browse the repository at this point in the history
…d single nested attributes (#668)
  • Loading branch information
bendbennett committed Mar 7, 2023
1 parent d68d931 commit cc78ea4
Show file tree
Hide file tree
Showing 3 changed files with 1,801 additions and 320 deletions.
4 changes: 2 additions & 2 deletions internal/fwschemadata/data_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ func (d *Data) TransformDefaults(ctx context.Context, configRaw tftypes.Value) d
if err != nil {
if errors.Is(err, fwschema.ErrPathInsideAtomicAttribute) {
// ignore attributes/elements inside schema.Attributes, they have no schema of their own
logging.FrameworkTrace(ctx, "attribute is a non-schema attribute, not marking unknown")
logging.FrameworkTrace(ctx, "attribute is a non-schema attribute, not setting default")
return tfTypeValue, nil
}

if errors.Is(err, fwschema.ErrPathIsBlock) {
// ignore blocks, they do not have a computed field
logging.FrameworkTrace(ctx, "attribute is a block, not marking unknown")
logging.FrameworkTrace(ctx, "attribute is a block, not setting default")
return tfTypeValue, nil
}

Expand Down
5 changes: 3 additions & 2 deletions internal/fwserver/server_planresourcechange.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ func (s *Server) PlanResourceChange(ctx context.Context, req *PlanResourceChange
// Set Defaults.
//
// If the planned state is not null (i.e., not a destroy operation) we traverse the schema,
// identifying any attributes which are null, and if the attribute has a default value
// specified by the `Default` field on the attribute then the default value is assigned.
// identifying any attributes which are null within the configuration, and if the attribute
// has a default value specified by the `Default` field on the attribute then the default
// value is assigned.
if !resp.PlannedState.Raw.IsNull() {
data := fwschemadata.Data{
Description: fwschemadata.DataDescriptionState,
Expand Down

0 comments on commit cc78ea4

Please sign in to comment.