@@ -140,13 +140,23 @@ func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.Reso
140140 // Handles the string fixed64 format
141141 if strVal, ok := v. (string); ok {
142142 if intVal, err := tpgresource.StringToFixed64 (strVal); err == nil {
143+ {{- if and (ne $ .DefaultValue nil ) (not $ .Required ) (not $ .HasAncestorCustomSet ) }}
144+ if intVal == {{ $ .GoLiteral $ .DefaultValue }} {
145+ return nil
146+ }
147+ {{- end }}
143148 return intVal
144149 }
145150 }
146151
147152 // number values are represented as float64
148153 if floatVal, ok := v. (float64); ok {
149154 intVal := int(floatVal)
155+ {{- if and (ne $ .DefaultValue nil ) (not $ .Required ) (not $ .HasAncestorCustomSet ) }}
156+ if intVal == {{ $ .GoLiteral $ .DefaultValue }} {
157+ return nil
158+ }
159+ {{- end }}
150160 return intVal
151161 }
152162
@@ -156,6 +166,15 @@ func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.Reso
156166 }
157167 {{- end }}
158168
169+ {{- if and (ne $ .DefaultValue nil ) (not $ .Required ) (not $ .HasAncestorCustomSet ) }}
170+ if intVal, ok := v. (int); ok && intVal == {{ $ .GoLiteral $ .DefaultValue }} {
171+ return nil
172+ }
173+ if floatVal, ok := v. (float64); ok && floatVal == {{ $ .GoLiteral $ .DefaultValue }} {
174+ return nil
175+ }
176+ {{- end }}
177+
159178 return v // let terraform core handle it otherwise
160179 {{- else if and ($ .IsA " Array" ) ($ .ItemType.IsA " ResourceRef" )}}
161180 if v == nil {
@@ -196,6 +215,21 @@ func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.Reso
196215 }
197216 return v
198217 {{- else }}
218+ {{- if and (ne $ .DefaultValue nil ) (not $ .Required ) (not $ .HasAncestorCustomSet ) }}
219+ {{- if or ($ .IsA " String" ) (or ($ .IsA " Enum" ) ($ .IsA " ResourceRef" )) }}
220+ if strVal, ok := v. (string); ok && strVal == {{ $ .GoLiteral $ .DefaultValue }} {
221+ return nil
222+ }
223+ {{- else if $ .IsA " Boolean" }}
224+ if boolVal, ok := v. (bool); ok && boolVal == {{ $ .GoLiteral $ .DefaultValue }} {
225+ return nil
226+ }
227+ {{- else if $ .IsA " Double" }}
228+ if floatVal, ok := v. (float64); ok && floatVal == {{ $ .GoLiteral $ .DefaultValue }} {
229+ return nil
230+ }
231+ {{- end }}
232+ {{- end }}
199233 return v
200234{{- end }}
201235}
0 commit comments