Skip to content

Commit

Permalink
Merge pull request #36847 from hashicorp/f-export-resource
Browse files Browse the repository at this point in the history
New Resource Export
  • Loading branch information
nam054 authored Apr 22, 2024
2 parents dfce800 + 3222702 commit 2ded024
Show file tree
Hide file tree
Showing 12 changed files with 1,325 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/36847.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
aws_bcmdataexports_export
```
48 changes: 48 additions & 0 deletions internal/framework/flex/auto_flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,54 @@ func (flattener autoFlattener) map_(ctx context.Context, vFrom reflect.Value, tT
return diags
}

case reflect.Map:
switch tTo := tTo.(type) {
case basetypes.MapTypable:
//
// map[string]map[string]string -> types.Map(OfMap[types.String]).
//
if vFrom.IsNil() {
to, d := tTo.ValueFromMap(ctx, types.MapNull(types.MapType{ElemType: types.StringType}))
diags.Append(d...)
if diags.HasError() {
return diags
}

vTo.Set(reflect.ValueOf(to))
return diags
}

from := vFrom.Interface().(map[string]map[string]string)
elements := make(map[string]attr.Value, len(from))
for k, v := range from {
innerElements := make(map[string]attr.Value, len(v))
for ik, iv := range v {
innerElements[ik] = types.StringValue(iv)
}
innerMap, d := fwtypes.NewMapValueOf[types.String](ctx, innerElements)
diags.Append(d...)
if diags.HasError() {
return diags
}

elements[k] = innerMap
}
map_, d := fwtypes.NewMapValueOf[fwtypes.MapValueOf[types.String]](ctx, elements)
diags.Append(d...)
if diags.HasError() {
return diags
}

to, d := tTo.ValueFromMap(ctx, map_.MapValue)
diags.Append(d...)
if diags.HasError() {
return diags
}

vTo.Set(reflect.ValueOf(to))
return diags
}

case reflect.Ptr:
switch tMapElem.Elem().Kind() {
case reflect.Struct:
Expand Down
Loading

0 comments on commit 2ded024

Please sign in to comment.