-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding types for use with attribute fields and making the template fo…
…r use with primitive attributes generic (#31)
- Loading branch information
1 parent
35002a5
commit 752d3ce
Showing
4 changed files
with
79 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
func To{{.Name}}(ctx context.Context, tfType {{.TfType}}) ({{.Type}}, diag.Diagnostics) { | ||
var diags diag.Diagnostics | ||
|
||
if tfType.IsNull() || tfType.IsUnknown() { | ||
return nil, diags | ||
} | ||
|
||
apiObject := &{{.TypeReference}}{ | ||
{{.Name}}: tfType.{{.DefaultTo}}(), | ||
} | ||
|
||
return apiObject, diags | ||
} | ||
|
||
func From{{.Name}}(ctx context.Context, apiObject {{.Type}}) ({{.TfType}}, diag.Diagnostics) { | ||
var diags diag.Diagnostics | ||
|
||
if apiObject == nil { | ||
return {{.TfType}}Null(), diags | ||
} | ||
|
||
return types.{{.DefaultFrom}}(apiObject.{{.Name}}), diags | ||
} |