From 848af6d9cea6ddf2a3c0c7285c9b78df98f4f516 Mon Sep 17 00:00:00 2001 From: Hannes Hayashi Date: Mon, 22 Dec 2025 10:04:01 +0100 Subject: [PATCH 1/5] feat: introduce deduplication for custom type and value generation --- go.mod | 13 +++++-- go.sum | 39 ++++++++++++++++--- internal/datasource/list_nested_attribute.go | 10 ++++- internal/datasource/list_nested_block.go | 14 +++++-- internal/datasource/map_nested_attribute.go | 10 ++++- internal/datasource/set_nested_attribute.go | 10 ++++- internal/datasource/set_nested_block.go | 14 +++++-- .../datasource/single_nested_attribute.go | 10 ++++- internal/datasource/single_nested_block.go | 12 ++++-- internal/provider/list_nested_attribute.go | 10 ++++- internal/provider/list_nested_block.go | 14 +++++-- internal/provider/map_nested_attribute.go | 10 ++++- internal/provider/set_nested_attribute.go | 10 ++++- internal/provider/set_nested_block.go | 14 +++++-- internal/provider/single_nested_attribute.go | 10 ++++- internal/provider/single_nested_block.go | 12 ++++-- internal/resource/bool_attribute.go | 8 +++- internal/resource/float64_attribute.go | 8 +++- internal/resource/int64_attribute.go | 8 +++- internal/resource/list_attribute.go | 8 +++- internal/resource/list_nested_attribute.go | 10 ++++- internal/resource/list_nested_block.go | 12 ++++-- internal/resource/map_attribute.go | 8 +++- internal/resource/map_nested_attribute.go | 10 ++++- internal/resource/number_attribute.go | 8 +++- internal/resource/object_attribute.go | 8 +++- internal/resource/set_attribute.go | 8 +++- internal/resource/set_nested_attribute.go | 10 ++++- internal/resource/set_nested_block.go | 14 +++++-- internal/resource/single_nested_attribute.go | 10 ++++- internal/resource/single_nested_block.go | 12 ++++-- internal/resource/string_attribute.go | 8 +++- internal/schema/schema.go | 7 ++-- internal/schema/types.go | 2 +- 34 files changed, 299 insertions(+), 72 deletions(-) diff --git a/go.mod b/go.mod index df044500..66252202 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,14 @@ module github.com/hashicorp/terraform-plugin-codegen-framework -go 1.22.7 +go 1.24.0 require ( github.com/google/go-cmp v0.7.0 github.com/hashicorp/cli v1.1.7 github.com/hashicorp/terraform-plugin-codegen-spec v0.2.0 + github.com/hashicorp/terraform-plugin-framework v1.17.0 + github.com/hashicorp/terraform-plugin-framework-validators v0.19.0 + github.com/hashicorp/terraform-plugin-go v0.29.0 github.com/mattn/go-colorable v0.1.14 ) @@ -18,19 +21,23 @@ require ( github.com/fatih/color v1.16.0 // indirect github.com/google/uuid v1.4.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/terraform-plugin-log v0.10.0 // indirect github.com/huandu/xstrings v1.4.0 // indirect github.com/imdario/mergo v0.3.16 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/posener/complete v1.2.3 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.1 // indirect - github.com/stretchr/testify v1.7.2 // indirect + github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect golang.org/x/crypto v0.32.0 // indirect - golang.org/x/sys v0.29.0 // indirect + golang.org/x/sys v0.35.0 // indirect ) diff --git a/go.sum b/go.sum index f9bd0511..3064dff1 100644 --- a/go.sum +++ b/go.sum @@ -10,8 +10,10 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= @@ -26,11 +28,21 @@ github.com/hashicorp/cli v1.1.7/go.mod h1:e6Mfpga9OCT1vqzFuoGZiiF/KaG9CbUfO5s3gh github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/terraform-plugin-codegen-spec v0.2.0 h1:91dQG1A/DxP6vRz9GiytDTrZTXDbhHPvmpYnAyWA/Vw= github.com/hashicorp/terraform-plugin-codegen-spec v0.2.0/go.mod h1:fywrEKpordQypmAjz/HIfm2LuNVmyJ6KDe8XT9GdJxQ= +github.com/hashicorp/terraform-plugin-framework v1.17.0 h1:JdX50CFrYcYFY31gkmitAEAzLKoBgsK+iaJjDC8OexY= +github.com/hashicorp/terraform-plugin-framework v1.17.0/go.mod h1:4OUXKdHNosX+ys6rLgVlgklfxN3WHR5VHSOABeS/BM0= +github.com/hashicorp/terraform-plugin-framework-validators v0.19.0 h1:Zz3iGgzxe/1XBkooZCewS0nJAaCFPFPHdNJd8FgE4Ow= +github.com/hashicorp/terraform-plugin-framework-validators v0.19.0/go.mod h1:GBKTNGbGVJohU03dZ7U8wHqc2zYnMUawgCN+gC0itLc= +github.com/hashicorp/terraform-plugin-go v0.29.0 h1:1nXKl/nSpaYIUBU1IG/EsDOX0vv+9JxAltQyDMpq5mU= +github.com/hashicorp/terraform-plugin-go v0.29.0/go.mod h1:vYZbIyvxyy0FWSmDHChCqKvI40cFTDGSb3D8D70i9GM= +github.com/hashicorp/terraform-plugin-log v0.10.0 h1:eu2kW6/QBVdN4P3Ju2WiB2W3ObjkAsyfBsL3Wh1fj3g= +github.com/hashicorp/terraform-plugin-log v0.10.0/go.mod h1:/9RR5Cv2aAbrqcTSdNmY1NRHP4E3ekrXRGjqORpXyB0= github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= @@ -41,18 +53,25 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= +github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= @@ -68,8 +87,13 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= +github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= +github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= +github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= @@ -91,14 +115,19 @@ golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= -golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= +golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= diff --git a/internal/datasource/list_nested_attribute.go b/internal/datasource/list_nested_attribute.go index d56cbc88..dc5f7e23 100644 --- a/internal/datasource/list_nested_attribute.go +++ b/internal/datasource/list_nested_attribute.go @@ -170,7 +170,13 @@ func (g GeneratorListNestedAttribute) GetAttributes() schema.GeneratorAttributes return g.NestedObject.Attributes } -func (g GeneratorListNestedAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorListNestedAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -223,7 +229,7 @@ func (g GeneratorListNestedAttribute) CustomTypeAndValue(name string) ([]byte, e // CustomTypeAndValue interface. for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/datasource/list_nested_block.go b/internal/datasource/list_nested_block.go index 18f614c9..9d84e660 100644 --- a/internal/datasource/list_nested_block.go +++ b/internal/datasource/list_nested_block.go @@ -181,7 +181,13 @@ func (g GeneratorListNestedBlock) GetBlocks() schema.GeneratorBlocks { return g.NestedObject.Blocks } -func (g GeneratorListNestedBlock) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorListNestedBlock) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -285,7 +291,7 @@ func (g GeneratorListNestedBlock) CustomTypeAndValue(name string) ([]byte, error // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err @@ -297,13 +303,15 @@ func (g GeneratorListNestedBlock) CustomTypeAndValue(name string) ([]byte, error for _, k := range blockKeys { if c, ok := g.NestedObject.Blocks[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err } buf.Write(b) + + continue } } diff --git a/internal/datasource/map_nested_attribute.go b/internal/datasource/map_nested_attribute.go index 6c3e6c2c..a1014562 100644 --- a/internal/datasource/map_nested_attribute.go +++ b/internal/datasource/map_nested_attribute.go @@ -170,7 +170,13 @@ func (g GeneratorMapNestedAttribute) GetAttributes() schema.GeneratorAttributes return g.NestedObject.Attributes } -func (g GeneratorMapNestedAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorMapNestedAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -223,7 +229,7 @@ func (g GeneratorMapNestedAttribute) CustomTypeAndValue(name string) ([]byte, er // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/datasource/set_nested_attribute.go b/internal/datasource/set_nested_attribute.go index 41a477c1..68d78739 100644 --- a/internal/datasource/set_nested_attribute.go +++ b/internal/datasource/set_nested_attribute.go @@ -170,7 +170,13 @@ func (g GeneratorSetNestedAttribute) GetAttributes() schema.GeneratorAttributes return g.NestedObject.Attributes } -func (g GeneratorSetNestedAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorSetNestedAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -223,7 +229,7 @@ func (g GeneratorSetNestedAttribute) CustomTypeAndValue(name string) ([]byte, er // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/datasource/set_nested_block.go b/internal/datasource/set_nested_block.go index 4a2c6d93..4e4f56fc 100644 --- a/internal/datasource/set_nested_block.go +++ b/internal/datasource/set_nested_block.go @@ -181,7 +181,13 @@ func (g GeneratorSetNestedBlock) GetBlocks() schema.GeneratorBlocks { return g.NestedObject.Blocks } -func (g GeneratorSetNestedBlock) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorSetNestedBlock) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -285,7 +291,7 @@ func (g GeneratorSetNestedBlock) CustomTypeAndValue(name string) ([]byte, error) // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err @@ -297,13 +303,15 @@ func (g GeneratorSetNestedBlock) CustomTypeAndValue(name string) ([]byte, error) for _, k := range blockKeys { if c, ok := g.NestedObject.Blocks[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err } buf.Write(b) + + continue } } diff --git a/internal/datasource/single_nested_attribute.go b/internal/datasource/single_nested_attribute.go index cfaa8e5f..ff6dff3b 100644 --- a/internal/datasource/single_nested_attribute.go +++ b/internal/datasource/single_nested_attribute.go @@ -163,7 +163,13 @@ func (g GeneratorSingleNestedAttribute) GetAttributes() schema.GeneratorAttribut return g.Attributes } -func (g GeneratorSingleNestedAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorSingleNestedAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.Attributes.AttrValues() @@ -216,7 +222,7 @@ func (g GeneratorSingleNestedAttribute) CustomTypeAndValue(name string) ([]byte, // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/datasource/single_nested_block.go b/internal/datasource/single_nested_block.go index 6107caab..38b8068f 100644 --- a/internal/datasource/single_nested_block.go +++ b/internal/datasource/single_nested_block.go @@ -194,7 +194,13 @@ func (g GeneratorSingleNestedBlock) GetBlocks() schema.GeneratorBlocks { return g.Blocks } -func (g GeneratorSingleNestedBlock) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorSingleNestedBlock) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.Attributes.AttrValues() @@ -298,7 +304,7 @@ func (g GeneratorSingleNestedBlock) CustomTypeAndValue(name string) ([]byte, err // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err @@ -310,7 +316,7 @@ func (g GeneratorSingleNestedBlock) CustomTypeAndValue(name string) ([]byte, err for _, k := range blockKeys { if c, ok := g.Blocks[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/provider/list_nested_attribute.go b/internal/provider/list_nested_attribute.go index f8fd788c..547c7532 100644 --- a/internal/provider/list_nested_attribute.go +++ b/internal/provider/list_nested_attribute.go @@ -170,7 +170,13 @@ func (g GeneratorListNestedAttribute) GetAttributes() schema.GeneratorAttributes return g.NestedObject.Attributes } -func (g GeneratorListNestedAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorListNestedAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -223,7 +229,7 @@ func (g GeneratorListNestedAttribute) CustomTypeAndValue(name string) ([]byte, e // CustomTypeAndValue interface. for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/provider/list_nested_block.go b/internal/provider/list_nested_block.go index 4eb2515e..13c703a1 100644 --- a/internal/provider/list_nested_block.go +++ b/internal/provider/list_nested_block.go @@ -181,7 +181,13 @@ func (g GeneratorListNestedBlock) GetBlocks() schema.GeneratorBlocks { return g.NestedObject.Blocks } -func (g GeneratorListNestedBlock) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorListNestedBlock) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -285,7 +291,7 @@ func (g GeneratorListNestedBlock) CustomTypeAndValue(name string) ([]byte, error // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err @@ -297,13 +303,15 @@ func (g GeneratorListNestedBlock) CustomTypeAndValue(name string) ([]byte, error for _, k := range blockKeys { if c, ok := g.NestedObject.Blocks[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err } buf.Write(b) + + continue } } diff --git a/internal/provider/map_nested_attribute.go b/internal/provider/map_nested_attribute.go index a2671708..1fe12ddd 100644 --- a/internal/provider/map_nested_attribute.go +++ b/internal/provider/map_nested_attribute.go @@ -170,7 +170,13 @@ func (g GeneratorMapNestedAttribute) GetAttributes() schema.GeneratorAttributes return g.NestedObject.Attributes } -func (g GeneratorMapNestedAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorMapNestedAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -223,7 +229,7 @@ func (g GeneratorMapNestedAttribute) CustomTypeAndValue(name string) ([]byte, er // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/provider/set_nested_attribute.go b/internal/provider/set_nested_attribute.go index 1d169c79..488c861a 100644 --- a/internal/provider/set_nested_attribute.go +++ b/internal/provider/set_nested_attribute.go @@ -170,7 +170,13 @@ func (g GeneratorSetNestedAttribute) GetAttributes() schema.GeneratorAttributes return g.NestedObject.Attributes } -func (g GeneratorSetNestedAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorSetNestedAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -223,7 +229,7 @@ func (g GeneratorSetNestedAttribute) CustomTypeAndValue(name string) ([]byte, er // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/provider/set_nested_block.go b/internal/provider/set_nested_block.go index eb0ad1a8..38dc665f 100644 --- a/internal/provider/set_nested_block.go +++ b/internal/provider/set_nested_block.go @@ -181,7 +181,13 @@ func (g GeneratorSetNestedBlock) GetBlocks() schema.GeneratorBlocks { return g.NestedObject.Blocks } -func (g GeneratorSetNestedBlock) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorSetNestedBlock) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -285,7 +291,7 @@ func (g GeneratorSetNestedBlock) CustomTypeAndValue(name string) ([]byte, error) // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err @@ -297,13 +303,15 @@ func (g GeneratorSetNestedBlock) CustomTypeAndValue(name string) ([]byte, error) for _, k := range blockKeys { if c, ok := g.NestedObject.Blocks[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err } buf.Write(b) + + continue } } diff --git a/internal/provider/single_nested_attribute.go b/internal/provider/single_nested_attribute.go index 831b0cd3..4c6daf8c 100644 --- a/internal/provider/single_nested_attribute.go +++ b/internal/provider/single_nested_attribute.go @@ -163,7 +163,13 @@ func (g GeneratorSingleNestedAttribute) GetAttributes() schema.GeneratorAttribut return g.Attributes } -func (g GeneratorSingleNestedAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorSingleNestedAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.Attributes.AttrValues() @@ -216,7 +222,7 @@ func (g GeneratorSingleNestedAttribute) CustomTypeAndValue(name string) ([]byte, // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/provider/single_nested_block.go b/internal/provider/single_nested_block.go index d493fa20..26cb92a3 100644 --- a/internal/provider/single_nested_block.go +++ b/internal/provider/single_nested_block.go @@ -194,7 +194,13 @@ func (g GeneratorSingleNestedBlock) GetBlocks() schema.GeneratorBlocks { return g.Blocks } -func (g GeneratorSingleNestedBlock) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorSingleNestedBlock) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.Attributes.AttrValues() @@ -298,7 +304,7 @@ func (g GeneratorSingleNestedBlock) CustomTypeAndValue(name string) ([]byte, err // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err @@ -310,7 +316,7 @@ func (g GeneratorSingleNestedBlock) CustomTypeAndValue(name string) ([]byte, err for _, k := range blockKeys { if c, ok := g.Blocks[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/resource/bool_attribute.go b/internal/resource/bool_attribute.go index 28481431..761a051c 100644 --- a/internal/resource/bool_attribute.go +++ b/internal/resource/bool_attribute.go @@ -159,7 +159,13 @@ func (g GeneratorBoolAttribute) ModelField(name generatorschema.FrameworkIdentif return field, nil } -func (g GeneratorBoolAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorBoolAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + if g.AssociatedExternalType == nil { return nil, nil } diff --git a/internal/resource/float64_attribute.go b/internal/resource/float64_attribute.go index d5673c69..be1e1423 100644 --- a/internal/resource/float64_attribute.go +++ b/internal/resource/float64_attribute.go @@ -159,7 +159,13 @@ func (g GeneratorFloat64Attribute) ModelField(name generatorschema.FrameworkIden return field, nil } -func (g GeneratorFloat64Attribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorFloat64Attribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + if g.AssociatedExternalType == nil { return nil, nil } diff --git a/internal/resource/int64_attribute.go b/internal/resource/int64_attribute.go index dc9fa4d4..ffceb7e8 100644 --- a/internal/resource/int64_attribute.go +++ b/internal/resource/int64_attribute.go @@ -159,7 +159,13 @@ func (g GeneratorInt64Attribute) ModelField(name generatorschema.FrameworkIdenti return field, nil } -func (g GeneratorInt64Attribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorInt64Attribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + if g.AssociatedExternalType == nil { return nil, nil } diff --git a/internal/resource/list_attribute.go b/internal/resource/list_attribute.go index 557e3432..f5fdbefa 100644 --- a/internal/resource/list_attribute.go +++ b/internal/resource/list_attribute.go @@ -187,7 +187,13 @@ func (g GeneratorListAttribute) ModelField(name generatorschema.FrameworkIdentif return field, nil } -func (g GeneratorListAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorListAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + if g.AssociatedExternalType == nil { return nil, nil } diff --git a/internal/resource/list_nested_attribute.go b/internal/resource/list_nested_attribute.go index baa3570b..f3caec8a 100644 --- a/internal/resource/list_nested_attribute.go +++ b/internal/resource/list_nested_attribute.go @@ -194,7 +194,13 @@ func (g GeneratorListNestedAttribute) GetAttributes() schema.GeneratorAttributes return g.NestedObject.Attributes } -func (g GeneratorListNestedAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorListNestedAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -247,7 +253,7 @@ func (g GeneratorListNestedAttribute) CustomTypeAndValue(name string) ([]byte, e // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/resource/list_nested_block.go b/internal/resource/list_nested_block.go index 1ed6ceed..5e729a51 100644 --- a/internal/resource/list_nested_block.go +++ b/internal/resource/list_nested_block.go @@ -194,7 +194,13 @@ func (g GeneratorListNestedBlock) GetBlocks() schema.GeneratorBlocks { return g.NestedObject.Blocks } -func (g GeneratorListNestedBlock) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorListNestedBlock) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -298,7 +304,7 @@ func (g GeneratorListNestedBlock) CustomTypeAndValue(name string) ([]byte, error // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err @@ -310,7 +316,7 @@ func (g GeneratorListNestedBlock) CustomTypeAndValue(name string) ([]byte, error for _, k := range blockKeys { if c, ok := g.NestedObject.Blocks[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/resource/map_attribute.go b/internal/resource/map_attribute.go index 297ef9bb..8601cf70 100644 --- a/internal/resource/map_attribute.go +++ b/internal/resource/map_attribute.go @@ -187,7 +187,13 @@ func (g GeneratorMapAttribute) ModelField(name generatorschema.FrameworkIdentifi return field, nil } -func (g GeneratorMapAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorMapAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + if g.AssociatedExternalType == nil { return nil, nil } diff --git a/internal/resource/map_nested_attribute.go b/internal/resource/map_nested_attribute.go index d4fa1fdc..3f9f3214 100644 --- a/internal/resource/map_nested_attribute.go +++ b/internal/resource/map_nested_attribute.go @@ -194,7 +194,13 @@ func (g GeneratorMapNestedAttribute) GetAttributes() schema.GeneratorAttributes return g.NestedObject.Attributes } -func (g GeneratorMapNestedAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorMapNestedAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -247,7 +253,7 @@ func (g GeneratorMapNestedAttribute) CustomTypeAndValue(name string) ([]byte, er // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/resource/number_attribute.go b/internal/resource/number_attribute.go index 4982b961..77a1f2fe 100644 --- a/internal/resource/number_attribute.go +++ b/internal/resource/number_attribute.go @@ -159,7 +159,13 @@ func (g GeneratorNumberAttribute) ModelField(name generatorschema.FrameworkIdent return field, nil } -func (g GeneratorNumberAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorNumberAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + if g.AssociatedExternalType == nil { return nil, nil } diff --git a/internal/resource/object_attribute.go b/internal/resource/object_attribute.go index d7c8b0fd..1d2db097 100644 --- a/internal/resource/object_attribute.go +++ b/internal/resource/object_attribute.go @@ -194,7 +194,13 @@ func (g GeneratorObjectAttribute) ModelField(name generatorschema.FrameworkIdent return field, nil } -func (g GeneratorObjectAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorObjectAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + if g.AssociatedExternalType == nil { return nil, nil } diff --git a/internal/resource/set_attribute.go b/internal/resource/set_attribute.go index 0515d8bf..1cb60102 100644 --- a/internal/resource/set_attribute.go +++ b/internal/resource/set_attribute.go @@ -187,7 +187,13 @@ func (g GeneratorSetAttribute) ModelField(name generatorschema.FrameworkIdentifi return field, nil } -func (g GeneratorSetAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorSetAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + if g.AssociatedExternalType == nil { return nil, nil } diff --git a/internal/resource/set_nested_attribute.go b/internal/resource/set_nested_attribute.go index 4258003c..a7e9db06 100644 --- a/internal/resource/set_nested_attribute.go +++ b/internal/resource/set_nested_attribute.go @@ -194,7 +194,13 @@ func (g GeneratorSetNestedAttribute) GetAttributes() schema.GeneratorAttributes return g.NestedObject.Attributes } -func (g GeneratorSetNestedAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorSetNestedAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -247,7 +253,7 @@ func (g GeneratorSetNestedAttribute) CustomTypeAndValue(name string) ([]byte, er // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/resource/set_nested_block.go b/internal/resource/set_nested_block.go index 64b4250d..0addb471 100644 --- a/internal/resource/set_nested_block.go +++ b/internal/resource/set_nested_block.go @@ -194,7 +194,13 @@ func (g GeneratorSetNestedBlock) GetBlocks() schema.GeneratorBlocks { return g.NestedObject.Blocks } -func (g GeneratorSetNestedBlock) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorSetNestedBlock) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.NestedObject.Attributes.AttrValues() @@ -298,7 +304,7 @@ func (g GeneratorSetNestedBlock) CustomTypeAndValue(name string) ([]byte, error) // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.NestedObject.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err @@ -310,13 +316,15 @@ func (g GeneratorSetNestedBlock) CustomTypeAndValue(name string) ([]byte, error) for _, k := range blockKeys { if c, ok := g.NestedObject.Blocks[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err } buf.Write(b) + + continue } } diff --git a/internal/resource/single_nested_attribute.go b/internal/resource/single_nested_attribute.go index 60b3f6bd..e1419f9d 100644 --- a/internal/resource/single_nested_attribute.go +++ b/internal/resource/single_nested_attribute.go @@ -185,7 +185,13 @@ func (g GeneratorSingleNestedAttribute) GetAttributes() schema.GeneratorAttribut return g.Attributes } -func (g GeneratorSingleNestedAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorSingleNestedAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.Attributes.AttrValues() @@ -238,7 +244,7 @@ func (g GeneratorSingleNestedAttribute) CustomTypeAndValue(name string) ([]byte, // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/resource/single_nested_block.go b/internal/resource/single_nested_block.go index 972390e6..408f8a85 100644 --- a/internal/resource/single_nested_block.go +++ b/internal/resource/single_nested_block.go @@ -205,7 +205,13 @@ func (g GeneratorSingleNestedBlock) GetBlocks() schema.GeneratorBlocks { return g.Blocks } -func (g GeneratorSingleNestedBlock) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorSingleNestedBlock) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + var buf bytes.Buffer attributeAttrValues, err := g.Attributes.AttrValues() @@ -309,7 +315,7 @@ func (g GeneratorSingleNestedBlock) CustomTypeAndValue(name string) ([]byte, err // CustomTypeAndValue interface (i.e, nested attributes). for _, k := range attributeKeys { if c, ok := g.Attributes[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err @@ -321,7 +327,7 @@ func (g GeneratorSingleNestedBlock) CustomTypeAndValue(name string) ([]byte, err for _, k := range blockKeys { if c, ok := g.Blocks[k].(schema.CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err diff --git a/internal/resource/string_attribute.go b/internal/resource/string_attribute.go index 5bea3434..46ce4560 100644 --- a/internal/resource/string_attribute.go +++ b/internal/resource/string_attribute.go @@ -159,7 +159,13 @@ func (g GeneratorStringAttribute) ModelField(name generatorschema.FrameworkIdent return field, nil } -func (g GeneratorStringAttribute) CustomTypeAndValue(name string) ([]byte, error) { +func (g GeneratorStringAttribute) CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) { + if _, ok := generated[name]; ok { + return nil, nil + } + + generated[name] = struct{}{} + if g.AssociatedExternalType == nil { return nil, nil } diff --git a/internal/schema/schema.go b/internal/schema/schema.go index f9b287da..bd0065f9 100644 --- a/internal/schema/schema.go +++ b/internal/schema/schema.go @@ -247,6 +247,8 @@ func (g GeneratorSchema) Models(name string) ([]model.Model, error) { func (g GeneratorSchema) CustomTypeValueBytes() ([]byte, error) { var buf bytes.Buffer + generated := make(map[string]struct{}) + attributeKeys := g.Attributes.SortedKeys() for _, k := range attributeKeys { @@ -255,7 +257,7 @@ func (g GeneratorSchema) CustomTypeValueBytes() ([]byte, error) { } if c, ok := g.Attributes[k].(CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err @@ -273,7 +275,7 @@ func (g GeneratorSchema) CustomTypeValueBytes() ([]byte, error) { } if c, ok := g.Blocks[k].(CustomTypeAndValue); ok { - b, err := c.CustomTypeAndValue(k) + b, err := c.CustomTypeAndValue(k, generated) if err != nil { return nil, err @@ -282,7 +284,6 @@ func (g GeneratorSchema) CustomTypeValueBytes() ([]byte, error) { buf.Write(b) } } - if buf.Len() > 0 { buf.WriteString("\n") } diff --git a/internal/schema/types.go b/internal/schema/types.go index 3521d347..2074119c 100644 --- a/internal/schema/types.go +++ b/internal/schema/types.go @@ -23,7 +23,7 @@ type Blocks interface { } type CustomTypeAndValue interface { - CustomTypeAndValue(name string) ([]byte, error) + CustomTypeAndValue(name string, generated map[string]struct{}) ([]byte, error) } type Elements interface { From ff182ac18e2ec66ff4e3b76e940eeab06c0290dc Mon Sep 17 00:00:00 2001 From: Hannes Hayashi Date: Mon, 22 Dec 2025 10:10:11 +0100 Subject: [PATCH 2/5] chore: Remove unused Terraform plugin framework dependencies, add `testify` for testing --- go.mod | 11 +++-------- go.sum | 27 --------------------------- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/go.mod b/go.mod index 66252202..b8f6c9c0 100644 --- a/go.mod +++ b/go.mod @@ -6,9 +6,6 @@ require ( github.com/google/go-cmp v0.7.0 github.com/hashicorp/cli v1.1.7 github.com/hashicorp/terraform-plugin-codegen-spec v0.2.0 - github.com/hashicorp/terraform-plugin-framework v1.17.0 - github.com/hashicorp/terraform-plugin-framework-validators v0.19.0 - github.com/hashicorp/terraform-plugin-go v0.29.0 github.com/mattn/go-colorable v0.1.14 ) @@ -18,23 +15,21 @@ require ( github.com/Masterminds/sprig/v3 v3.2.3 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fatih/color v1.16.0 // indirect github.com/google/uuid v1.4.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/terraform-plugin-log v0.10.0 // indirect github.com/huandu/xstrings v1.4.0 // indirect github.com/imdario/mergo v0.3.16 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect - github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/posener/complete v1.2.3 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.1 // indirect - github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect - github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + github.com/stretchr/testify v1.10.0 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect diff --git a/go.sum b/go.sum index 3064dff1..b73e60a4 100644 --- a/go.sum +++ b/go.sum @@ -13,7 +13,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= @@ -28,21 +27,11 @@ github.com/hashicorp/cli v1.1.7/go.mod h1:e6Mfpga9OCT1vqzFuoGZiiF/KaG9CbUfO5s3gh github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= -github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/terraform-plugin-codegen-spec v0.2.0 h1:91dQG1A/DxP6vRz9GiytDTrZTXDbhHPvmpYnAyWA/Vw= github.com/hashicorp/terraform-plugin-codegen-spec v0.2.0/go.mod h1:fywrEKpordQypmAjz/HIfm2LuNVmyJ6KDe8XT9GdJxQ= -github.com/hashicorp/terraform-plugin-framework v1.17.0 h1:JdX50CFrYcYFY31gkmitAEAzLKoBgsK+iaJjDC8OexY= -github.com/hashicorp/terraform-plugin-framework v1.17.0/go.mod h1:4OUXKdHNosX+ys6rLgVlgklfxN3WHR5VHSOABeS/BM0= -github.com/hashicorp/terraform-plugin-framework-validators v0.19.0 h1:Zz3iGgzxe/1XBkooZCewS0nJAaCFPFPHdNJd8FgE4Ow= -github.com/hashicorp/terraform-plugin-framework-validators v0.19.0/go.mod h1:GBKTNGbGVJohU03dZ7U8wHqc2zYnMUawgCN+gC0itLc= -github.com/hashicorp/terraform-plugin-go v0.29.0 h1:1nXKl/nSpaYIUBU1IG/EsDOX0vv+9JxAltQyDMpq5mU= -github.com/hashicorp/terraform-plugin-go v0.29.0/go.mod h1:vYZbIyvxyy0FWSmDHChCqKvI40cFTDGSb3D8D70i9GM= -github.com/hashicorp/terraform-plugin-log v0.10.0 h1:eu2kW6/QBVdN4P3Ju2WiB2W3ObjkAsyfBsL3Wh1fj3g= -github.com/hashicorp/terraform-plugin-log v0.10.0/go.mod h1:/9RR5Cv2aAbrqcTSdNmY1NRHP4E3ekrXRGjqORpXyB0= github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= @@ -53,19 +42,13 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= -github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -87,13 +70,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= -github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= -github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= -github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= @@ -115,13 +93,8 @@ golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From be79b9d03103bb93e14e098d8dba45d6a050f9dd Mon Sep 17 00:00:00 2001 From: Hannes Hayashi Date: Mon, 22 Dec 2025 12:51:05 +0100 Subject: [PATCH 3/5] refactor: introduce custom types for nested objects and simplify their value assignment --- internal/schema/attributes.go | 4 ++-- internal/schema/attrtypes.go | 3 ++- internal/schema/schema.go | 9 ++++---- ...nested_object_value_to_object_value.gotmpl | 23 ++++--------------- 4 files changed, 13 insertions(+), 26 deletions(-) diff --git a/internal/schema/attributes.go b/internal/schema/attributes.go index 101d0ab5..1c3bcdc3 100644 --- a/internal/schema/attributes.go +++ b/internal/schema/attributes.go @@ -83,7 +83,7 @@ func (g GeneratorAttributes) AttrTypes() (map[string]string, error) { case GeneratorSetNestedAttribute: attrTypes[k] = fmt.Sprintf("basetypes.SetType{\nElemType: %sValue{}.Type(ctx),\n}", name.ToPascalCase()) case GeneratorSingleNestedAttribute: - attrTypes[k] = fmt.Sprintf("basetypes.ObjectType{\nAttrTypes: %sValue{}.AttributeTypes(ctx),\n}", name.ToPascalCase()) + attrTypes[k] = fmt.Sprintf("%sType{\nbasetypes.ObjectType{\nAttrTypes: %sValue{}.AttributeTypes(ctx),\n},\n}", name.ToPascalCase(), name.ToPascalCase()) } } @@ -111,7 +111,7 @@ func (g GeneratorAttributes) AttrValues() (map[string]string, error) { case GeneratorSetNestedAttribute: attrValues[k] = "basetypes.SetValue" case GeneratorSingleNestedAttribute: - attrValues[k] = "basetypes.ObjectValue" + attrValues[k] = fmt.Sprintf("%sValue", FrameworkIdentifier(k).ToPascalCase()) } } diff --git a/internal/schema/attrtypes.go b/internal/schema/attrtypes.go index 178d1962..1c533e23 100644 --- a/internal/schema/attrtypes.go +++ b/internal/schema/attrtypes.go @@ -64,7 +64,8 @@ func GetAttrTypes(attrTypes specschema.ObjectAttributeTypes) string { if v.Object.CustomType != nil { aTypes.WriteString(fmt.Sprintf("%s{\nAttrTypes: map[string]attr.Type{\n%s\n},\n}", v.Object.CustomType.Type, GetAttrTypes(v.Object.AttributeTypes))) } else { - aTypes.WriteString(fmt.Sprintf("types.ObjectType{\nAttrTypes: map[string]attr.Type{\n%s\n},\n}", GetAttrTypes(v.Object.AttributeTypes))) + typeName := FrameworkIdentifier(v.Name).ToPascalCase() + aTypes.WriteString(fmt.Sprintf("%sType{\nbasetypes.ObjectType{\nAttrTypes: %sValue{}.AttributeTypes(ctx),\n},\n}", typeName, typeName)) } case v.Set != nil: if v.Set.CustomType != nil { diff --git a/internal/schema/schema.go b/internal/schema/schema.go index bd0065f9..a5d85faa 100644 --- a/internal/schema/schema.go +++ b/internal/schema/schema.go @@ -444,11 +444,12 @@ func AttrTypesString(attrTypes specschema.ObjectAttributeTypes) (string, error) case v.Number != nil: attrTypesStr = append(attrTypesStr, fmt.Sprintf("%q: types.NumberType", v.Name)) case v.Object != nil: - objAttrTypesStr, err := AttrTypesString(v.Object.AttributeTypes) - if err != nil { - return "", err + if v.Object.CustomType != nil { + attrTypesStr = append(attrTypesStr, fmt.Sprintf("%q: %s", v.Name, v.Object.CustomType.Type)) + } else { + typeName := FrameworkIdentifier(v.Name).ToPascalCase() + attrTypesStr = append(attrTypesStr, fmt.Sprintf("%q: %sType{\nbasetypes.ObjectType{\nAttrTypes: %sValue{}.AttributeTypes(ctx),\n},\n}", v.Name, typeName, typeName)) } - attrTypesStr = append(attrTypesStr, fmt.Sprintf("%q: types.ObjectType{\nAttrTypes: map[string]attr.Type{\n%s,\n}\n}", v.Name, objAttrTypesStr)) case v.Set != nil: elemType, err := ElementTypeString(v.Set.ElementType) if err != nil { diff --git a/internal/schema/templates/nested_object_value_to_object_value.gotmpl b/internal/schema/templates/nested_object_value_to_object_value.gotmpl index ddf98ccd..3a5429f4 100644 --- a/internal/schema/templates/nested_object_value_to_object_value.gotmpl +++ b/internal/schema/templates/nested_object_value_to_object_value.gotmpl @@ -40,25 +40,10 @@ AttrTypes: {{$key.ToPascalCase}}Value{}.AttributeTypes(ctx), } {{else if eq $value "SingleNested"}} -var {{$key.ToCamelCase}} basetypes.ObjectValue +var {{$key.ToCamelCase}} attr.Value -if v.{{$key.ToPascalCase}}.IsNull() { -{{$key.ToCamelCase}} = types.ObjectNull( -{{$key.ToPascalCase}}Value{}.AttributeTypes(ctx), -) -} - -if v.{{$key.ToPascalCase}}.IsUnknown() { -{{$key.ToCamelCase}} = types.ObjectUnknown( -{{$key.ToPascalCase}}Value{}.AttributeTypes(ctx), -) -} - -if !v.{{$key.ToPascalCase}}.IsNull() && !v.{{$key.ToPascalCase}}.IsUnknown() { -{{$key.ToCamelCase}} = types.ObjectValueMust( -{{$key.ToPascalCase}}Value{}.AttributeTypes(ctx), -v.{{$key.ToPascalCase}}.Attributes(), -) +{ + {{$key.ToCamelCase}} = v.{{$key.ToPascalCase}} } {{end}} {{- end}} @@ -152,4 +137,4 @@ map[string]attr.Value{ }) return objVal, diags -} \ No newline at end of file +} From c383db4ccfd9216202996dea0d0f268127b22a80 Mon Sep 17 00:00:00 2001 From: Hannes Hayashi Date: Tue, 23 Dec 2025 07:37:13 +0100 Subject: [PATCH 4/5] chore: revert changes to go.mod and go.sum --- go.mod | 8 +++----- go.sum | 14 ++++++-------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index b8f6c9c0..df044500 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/hashicorp/terraform-plugin-codegen-framework -go 1.24.0 +go 1.22.7 require ( github.com/google/go-cmp v0.7.0 @@ -15,7 +15,6 @@ require ( github.com/Masterminds/sprig/v3 v3.2.3 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fatih/color v1.16.0 // indirect github.com/google/uuid v1.4.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -25,14 +24,13 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/posener/complete v1.2.3 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.1 // indirect - github.com/stretchr/testify v1.10.0 // indirect + github.com/stretchr/testify v1.7.2 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect golang.org/x/crypto v0.32.0 // indirect - golang.org/x/sys v0.35.0 // indirect + golang.org/x/sys v0.29.0 // indirect ) diff --git a/go.sum b/go.sum index b73e60a4..f9bd0511 100644 --- a/go.sum +++ b/go.sum @@ -10,9 +10,8 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= @@ -52,9 +51,8 @@ github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HK github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= @@ -70,8 +68,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= @@ -99,8 +97,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= From 070358bff9883ca08aff2d234a6e0c72f18e894b Mon Sep 17 00:00:00 2001 From: Hannes Hayashi Date: Tue, 23 Dec 2025 07:51:37 +0100 Subject: [PATCH 5/5] fix: update templates and tests to match simplified generation logic --- internal/schema/custom_nested_object_test.go | 117 ++---------------- ...nested_object_value_to_object_value.gotmpl | 37 +----- 2 files changed, 17 insertions(+), 137 deletions(-) diff --git a/internal/schema/custom_nested_object_test.go b/internal/schema/custom_nested_object_test.go index ad4e77a4..d3906a79 100644 --- a/internal/schema/custom_nested_object_test.go +++ b/internal/schema/custom_nested_object_test.go @@ -1032,37 +1032,15 @@ return objVal, diags attrTypes: map[string]string{ "list_nested_attribute": "basetypes.ListType{}", }, + expected: []byte(` func (v ExampleValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { var diags diag.Diagnostics -listNestedAttribute := types.ListValueMust( -ListNestedAttributeType{ -basetypes.ObjectType{ -AttrTypes: ListNestedAttributeValue{}.AttributeTypes(ctx), -}, -}, -v.ListNestedAttribute.Elements(), -) +var listNestedAttribute attr.Value -if v.ListNestedAttribute.IsNull() { -listNestedAttribute = types.ListNull( -ListNestedAttributeType{ -basetypes.ObjectType{ -AttrTypes: ListNestedAttributeValue{}.AttributeTypes(ctx), -}, -}, -) -} - -if v.ListNestedAttribute.IsUnknown() { -listNestedAttribute = types.ListUnknown( -ListNestedAttributeType{ -basetypes.ObjectType{ -AttrTypes: ListNestedAttributeValue{}.AttributeTypes(ctx), -}, -}, -) +{ + listNestedAttribute = v.ListNestedAttribute } @@ -1099,33 +1077,10 @@ return objVal, diags func (v ExampleValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { var diags diag.Diagnostics -mapNestedAttribute := types.MapValueMust( -MapNestedAttributeType{ -basetypes.ObjectType{ -AttrTypes: MapNestedAttributeValue{}.AttributeTypes(ctx), -}, -}, -v.MapNestedAttribute.Elements(), -) - -if v.MapNestedAttribute.IsNull() { -mapNestedAttribute = types.MapNull( -MapNestedAttributeType{ -basetypes.ObjectType{ -AttrTypes: MapNestedAttributeValue{}.AttributeTypes(ctx), -}, -}, -) -} +var mapNestedAttribute attr.Value -if v.MapNestedAttribute.IsUnknown() { -mapNestedAttribute = types.MapUnknown( -MapNestedAttributeType{ -basetypes.ObjectType{ -AttrTypes: MapNestedAttributeValue{}.AttributeTypes(ctx), -}, -}, -) +{ + mapNestedAttribute = v.MapNestedAttribute } @@ -1162,33 +1117,10 @@ return objVal, diags func (v ExampleValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { var diags diag.Diagnostics -setNestedAttribute := types.SetValueMust( -SetNestedAttributeType{ -basetypes.ObjectType{ -AttrTypes: SetNestedAttributeValue{}.AttributeTypes(ctx), -}, -}, -v.SetNestedAttribute.Elements(), -) - -if v.SetNestedAttribute.IsNull() { -setNestedAttribute = types.SetNull( -SetNestedAttributeType{ -basetypes.ObjectType{ -AttrTypes: SetNestedAttributeValue{}.AttributeTypes(ctx), -}, -}, -) -} +var setNestedAttribute attr.Value -if v.SetNestedAttribute.IsUnknown() { -setNestedAttribute = types.SetUnknown( -SetNestedAttributeType{ -basetypes.ObjectType{ -AttrTypes: SetNestedAttributeValue{}.AttributeTypes(ctx), -}, -}, -) +{ + setNestedAttribute = v.SetNestedAttribute } @@ -1258,33 +1190,10 @@ return objVal, diags func (v ExampleValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { var diags diag.Diagnostics -exampleType := types.ListValueMust( -TypeType{ -basetypes.ObjectType{ -AttrTypes: TypeValue{}.AttributeTypes(ctx), -}, -}, -v.ExampleType.Elements(), -) - -if v.ExampleType.IsNull() { -exampleType = types.ListNull( -TypeType{ -basetypes.ObjectType{ -AttrTypes: TypeValue{}.AttributeTypes(ctx), -}, -}, -) -} +var exampleType attr.Value -if v.ExampleType.IsUnknown() { -exampleType = types.ListUnknown( -TypeType{ -basetypes.ObjectType{ -AttrTypes: TypeValue{}.AttributeTypes(ctx), -}, -}, -) +{ + exampleType = v.ExampleType } diff --git a/internal/schema/templates/nested_object_value_to_object_value.gotmpl b/internal/schema/templates/nested_object_value_to_object_value.gotmpl index 3a5429f4..34116827 100644 --- a/internal/schema/templates/nested_object_value_to_object_value.gotmpl +++ b/internal/schema/templates/nested_object_value_to_object_value.gotmpl @@ -3,40 +3,11 @@ func (v {{.Name}}Value) ToObjectValue(ctx context.Context) (basetypes.ObjectValu var diags diag.Diagnostics {{- range $key, $value := .AttributeTypes }} {{- if eq $value "ListNested" "MapNested" "SetNested"}} -{{- $typesType := "List"}} -{{- if eq $value "MapNested"}} -{{- $typesType = "Map"}} -{{- else if eq $value "SetNested"}} -{{- $typesType = "Set"}} -{{- end}} -{{$key.ToPrefixCamelCase $.Name}} := types.{{$typesType}}ValueMust( -{{$key.ToPascalCase}}Type{ -basetypes.ObjectType{ -AttrTypes: {{$key.ToPascalCase}}Value{}.AttributeTypes(ctx), -}, -}, -v.{{$key.ToPrefixPascalCase $.Name}}.Elements(), -) - -if v.{{$key.ToPrefixPascalCase $.Name}}.IsNull() { -{{$key.ToPrefixCamelCase $.Name}} = types.{{$typesType}}Null( -{{$key.ToPascalCase}}Type{ -basetypes.ObjectType{ -AttrTypes: {{$key.ToPascalCase}}Value{}.AttributeTypes(ctx), -}, -}, -) -} +var {{$key.ToPrefixCamelCase $.Name}} attr.Value -if v.{{$key.ToPrefixPascalCase $.Name}}.IsUnknown() { -{{$key.ToPrefixCamelCase $.Name}} = types.{{$typesType}}Unknown( -{{$key.ToPascalCase}}Type{ -basetypes.ObjectType{ -AttrTypes: {{$key.ToPascalCase}}Value{}.AttributeTypes(ctx), -}, -}, -) +{ + {{$key.ToPrefixCamelCase $.Name}} = v.{{$key.ToPrefixPascalCase $.Name}} } {{else if eq $value "SingleNested"}} @@ -137,4 +108,4 @@ map[string]attr.Value{ }) return objVal, diags -} +} \ No newline at end of file