Skip to content

Commit

Permalink
Extracting element framework values
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Nov 4, 2022
1 parent a85929c commit c40eb65
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions internal/fwserver/attr_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,20 @@ func coerceListValue(schemaPath path.Path, value attr.Value) (types.List, diag.D
panic(fmt.Sprintf("cannot type assert elemType as FrameworjType: %T", elemType))
}

l.ElemType = etft.ToFrameworkType()
var elems []attr.Value

return l, nil
for _, v := range l.Elements() {
e, ok := v.(attr.FrameworkValue)
if !ok {
panic(fmt.Sprintf("cannot type assert e as FrameworkValue: %T", e))
}

elems = append(elems, e.ToFrameworkValue())
}

list := types.ListValueMust(etft.ToFrameworkType(), elems)

return list, nil
}

func coerceMapValue(schemaPath path.Path, value attr.Value) (types.Map, diag.Diagnostics) {
Expand Down
4 changes: 2 additions & 2 deletions internal/fwserver/block_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ type SingleNestedBlockCustomValue struct {
types.Object
}

func (t SingleNestedBlockCustomValue) Type(_ context.Context) attr.Type {
func (t SingleNestedBlockCustomValue) Type(ctx context.Context) attr.Type {
return SingleNestedBlockCustomType{
types.ObjectType{AttrTypes: t.AttrTypes},
types.ObjectType{AttrTypes: t.AttributeTypes(ctx)},
}
}

Expand Down

0 comments on commit c40eb65

Please sign in to comment.