Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Resource Export #36847

Merged
merged 15 commits into from
Apr 22, 2024
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
Loading