Skip to content

Commit

Permalink
Using direct mapping for primitives in expand and flatten functions (#31
Browse files Browse the repository at this point in the history
)
  • Loading branch information
bendbennett committed Aug 8, 2023
1 parent 752d3ce commit 252d896
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/templates/primitive_to_from.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ if tfType.IsNull() || tfType.IsUnknown() {
return nil, diags
}

apiObject := &{{.TypeReference}}{
{{.Name}}: tfType.{{.DefaultTo}}(),
}
var t {{.TypeReference}}

t = tfType.{{.DefaultTo}}()

return apiObject, diags
return &t, diags
}

func From{{.Name}}(ctx context.Context, apiObject {{.Type}}) ({{.TfType}}, diag.Diagnostics) {
Expand All @@ -19,5 +19,7 @@ if apiObject == nil {
return {{.TfType}}Null(), diags
}

return types.{{.DefaultFrom}}(apiObject.{{.Name}}), diags
t := types.{{.DefaultFrom}}(*apiObject)

return t, diags
}

0 comments on commit 252d896

Please sign in to comment.