Skip to content

Commit

Permalink
add another field starting with _Original for each computed field to …
Browse files Browse the repository at this point in the history
…allow effective values to be implemented
  • Loading branch information
rauchy committed Sep 30, 2024
1 parent 1cfc531 commit 4379a58
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .codegen/model.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ import (
type {{.PascalName}} struct {
{{- range .Fields}}
{{.Comment " // " 80}}
{{.PascalName}} {{if .IsOptionalObject}}*{{end}}{{template "type" .Entity}} `{{template "field-tag" . }}`{{end}}
{{template "field" .}}{{if .Entity.IsComputed }}{{printf "\n"}}_Original{{template "field" .}}{{end}}{{end}}
}

{{end}}
{{end}}

{{- define "field" -}}
{{.PascalName}} {{if .IsOptionalObject}}*{{end}}{{template "type" .Entity}} `{{template "field-tag" . }}`
{{- end -}}

{{- define "field-tag" -}}
{{if .IsJson}}tfsdk:"{{if and (ne .Entity.Terraform nil) (ne .Entity.Terraform.Alias "") }}{{.Entity.Terraform.Alias}}{{else}}{{.Name}}{{end}}" tf:"{{if not .Required}}optional{{end}}"{{else}}tfsdk:"-"{{end -}}
{{- end -}}
Expand Down

0 comments on commit 4379a58

Please sign in to comment.