Skip to content

Commit

Permalink
Removing handling of nested primitives with associated external type …
Browse files Browse the repository at this point in the history
…from model object template (#31)
  • Loading branch information
bendbennett committed Aug 10, 2023
1 parent ba58c02 commit 73f2f1a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 68 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 0 additions & 32 deletions internal/templates/model_object_to_from.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,10 @@ if diags.HasError() {
return nil, diags
}

{{range $field := .Fields }}
{{- if $field.HasAssocExtType}}
to{{$field.Name}}, d := To{{$field.Name}}(ctx, tfModel.{{$field.Name}})

diags.Append(d...)

if diags.HasError() {
return nil, diags
}
{{- end}}
{{- end}}

apiObject := &{{.TypeReference}}{
{{- range $field := .Fields }}
{{- if $field.HasAssocExtType}}
{{$field.Name}}: to{{$field.Name}},
{{- else}}
{{$field.Name}}: tfModel.{{$field.Name}}.{{$field.DefaultTo}}(),
{{- end}}
{{- end}}
}

return apiObject, diags
Expand All @@ -47,24 +31,8 @@ return tfModel.ObjectNull(ctx), diags
}

{{range $field := .Fields }}
{{- if $field.HasAssocExtType}}
from{{$field.Name}}, d := From{{$field.Name}}(ctx, apiObject.{{$field.Name}})

diags.Append(d...)

if diags.HasError() {
return tfModel.ObjectNull(ctx), diags
}
{{- end}}
{{- end}}

{{range $field := .Fields }}
{{- if $field.HasAssocExtType}}
tfModel.{{$field.Name}} = from{{$field.Name}}
{{- else}}
tfModel.{{$field.Name}} = types.{{$field.DefaultFrom}}(apiObject.{{$field.Name}})
{{- end}}
{{- end}}

return tfModel.ObjectValueFrom(ctx, tfModel)
}

0 comments on commit 73f2f1a

Please sign in to comment.