From 7076ccaaf25b9cf7d1f211f78022cdfc0aba0b7f Mon Sep 17 00:00:00 2001 From: Austin Valle Date: Tue, 17 Sep 2024 11:23:20 -0400 Subject: [PATCH] docs: Miscellaneous doc fixes in attribute + unit tests (#1027) * fix and uncomment custom type tests * fix comments on nested attributes * add new attribute types to package docs * fix map docs * fix linting errors * SEC-090: Automated trusted workflow pinning (2024-08-19) (#1028) * Result of tsccr-helper -log-level=info gha update -latest . * Resolve linter errors and warnings --------- Co-authored-by: hashicorp-tsccr[bot] Co-authored-by: Selena Goods * build(deps): Bump hashicorp/setup-terraform from 3.1.1 to 3.1.2 (#1029) Bumps [hashicorp/setup-terraform](https://github.com/hashicorp/setup-terraform) from 3.1.1 to 3.1.2. - [Release notes](https://github.com/hashicorp/setup-terraform/releases) - [Changelog](https://github.com/hashicorp/setup-terraform/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/setup-terraform/compare/651471c36a6092792c552e8b1bef71e592b462d8...b9cd54a3c349d3f38e8881555d616ced269862dd) --- updated-dependencies: - dependency-name: hashicorp/setup-terraform dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Result of tsccr-helper -log-level=info gha update -latest . (#1034) Co-authored-by: hashicorp-tsccr[bot] * all: Bump minimum Go module version to 1.22 (#1033) * all: Bump minimum Go module version to 1.22.7 * add changelog * back to 1.22.0 * [CI] Update lock workflow file * [CI] Update issue comment triage workflow file * [CI] terraform-devex-repos automation * [CI] terraform-devex-repos automation * [CI] terraform-devex-repos automation --------- Signed-off-by: dependabot[bot] Co-authored-by: hashicorp-tsccr[bot] <129506189+hashicorp-tsccr[bot]@users.noreply.github.com> Co-authored-by: hashicorp-tsccr[bot] Co-authored-by: Selena Goods Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Service Account - Terraform Provider DevEx <100357958+hc-github-team-tf-provider-devex@users.noreply.github.com> --- datasource/schema/attribute.go | 3 +++ datasource/schema/float64_attribute_test.go | 13 +++++++------ datasource/schema/int32_attribute_test.go | 13 +++++++------ datasource/schema/int64_attribute_test.go | 13 +++++++------ datasource/schema/list_attribute_test.go | 12 ++++++------ datasource/schema/list_nested_attribute_test.go | 12 ++++++------ datasource/schema/list_nested_block_test.go | 12 ++++++------ datasource/schema/map_attribute.go | 4 ++-- datasource/schema/map_attribute_test.go | 12 ++++++------ datasource/schema/map_nested_attribute.go | 6 +++--- datasource/schema/map_nested_attribute_test.go | 12 ++++++------ datasource/schema/nested_attribute_object_test.go | 13 +++++++------ datasource/schema/nested_block_object_test.go | 13 +++++++------ datasource/schema/object_attribute_test.go | 12 ++++++------ datasource/schema/set_attribute_test.go | 12 ++++++------ datasource/schema/set_nested_attribute.go | 2 +- datasource/schema/set_nested_attribute_test.go | 12 ++++++------ datasource/schema/set_nested_block_test.go | 12 ++++++------ datasource/schema/single_nested_attribute.go | 2 +- datasource/schema/single_nested_attribute_test.go | 13 +++++++------ datasource/schema/single_nested_block_test.go | 13 +++++++------ provider/metaschema/float64_attribute_test.go | 13 +++++++------ provider/metaschema/int64_attribute_test.go | 13 +++++++------ provider/metaschema/list_attribute_test.go | 12 ++++++------ provider/metaschema/list_nested_attribute_test.go | 13 +++++++------ provider/metaschema/map_attribute.go | 4 ++-- provider/metaschema/map_attribute_test.go | 12 ++++++------ provider/metaschema/map_nested_attribute.go | 6 +++--- provider/metaschema/map_nested_attribute_test.go | 13 +++++++------ provider/metaschema/nested_attribute_object_test.go | 13 +++++++------ provider/metaschema/object_attribute_test.go | 12 ++++++------ provider/metaschema/set_attribute_test.go | 12 ++++++------ provider/metaschema/set_nested_attribute.go | 2 +- provider/metaschema/set_nested_attribute_test.go | 13 +++++++------ provider/metaschema/single_nested_attribute.go | 2 +- provider/metaschema/single_nested_attribute_test.go | 13 +++++++------ provider/schema/attribute.go | 3 +++ provider/schema/float32_attribute_test.go | 13 +++++++------ provider/schema/float64_attribute_test.go | 13 +++++++------ provider/schema/int64_attribute_test.go | 13 +++++++------ provider/schema/list_attribute_test.go | 12 ++++++------ provider/schema/list_nested_attribute_test.go | 12 ++++++------ provider/schema/list_nested_block_test.go | 12 ++++++------ provider/schema/map_attribute.go | 4 ++-- provider/schema/map_attribute_test.go | 12 ++++++------ provider/schema/map_nested_attribute.go | 6 +++--- provider/schema/map_nested_attribute_test.go | 12 ++++++------ provider/schema/nested_attribute_object_test.go | 13 +++++++------ provider/schema/nested_block_object_test.go | 13 +++++++------ provider/schema/object_attribute_test.go | 12 ++++++------ provider/schema/set_attribute_test.go | 12 ++++++------ provider/schema/set_nested_attribute.go | 2 +- provider/schema/set_nested_attribute_test.go | 12 ++++++------ provider/schema/set_nested_block_test.go | 12 ++++++------ provider/schema/single_nested_attribute.go | 2 +- provider/schema/single_nested_attribute_test.go | 13 +++++++------ provider/schema/single_nested_block_test.go | 13 +++++++------ resource/schema/attribute.go | 3 +++ resource/schema/float32_attribute_test.go | 13 +++++++------ resource/schema/float64_attribute_test.go | 13 +++++++------ resource/schema/int64_attribute_test.go | 13 +++++++------ resource/schema/list_attribute_test.go | 12 ++++++------ resource/schema/list_nested_attribute_test.go | 13 +++++++------ resource/schema/list_nested_block_test.go | 13 +++++++------ resource/schema/map_attribute.go | 4 ++-- resource/schema/map_attribute_test.go | 12 ++++++------ resource/schema/map_nested_attribute.go | 6 +++--- resource/schema/map_nested_attribute_test.go | 13 +++++++------ resource/schema/nested_attribute_object_test.go | 13 +++++++------ resource/schema/nested_block_object_test.go | 13 +++++++------ resource/schema/object_attribute_test.go | 12 ++++++------ resource/schema/set_attribute_test.go | 13 +++++++------ resource/schema/set_nested_attribute.go | 2 +- resource/schema/set_nested_attribute_test.go | 13 +++++++------ resource/schema/set_nested_block_test.go | 13 +++++++------ resource/schema/single_nested_attribute.go | 2 +- resource/schema/single_nested_attribute_test.go | 13 +++++++------ resource/schema/single_nested_block_test.go | 13 +++++++------ 78 files changed, 425 insertions(+), 382 deletions(-) diff --git a/datasource/schema/attribute.go b/datasource/schema/attribute.go index 4a0feceec..67294bfc6 100644 --- a/datasource/schema/attribute.go +++ b/datasource/schema/attribute.go @@ -10,7 +10,10 @@ import ( // Attribute define a value field inside the Schema. Implementations in this // package include: // - BoolAttribute +// - DynamicAttribute +// - Float32Attribute // - Float64Attribute +// - Int32Attribute // - Int64Attribute // - ListAttribute // - MapAttribute diff --git a/datasource/schema/float64_attribute_test.go b/datasource/schema/float64_attribute_test.go index a70ca695b..f2e05ebf7 100644 --- a/datasource/schema/float64_attribute_test.go +++ b/datasource/schema/float64_attribute_test.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -264,12 +265,12 @@ func TestFloat64AttributeGetType(t *testing.T) { attribute: schema.Float64Attribute{}, expected: types.Float64Type, }, - // "custom-type": { - // attribute: schema.Float64Attribute{ - // CustomType: testtypes.Float64Type{}, - // }, - // expected: testtypes.Float64Type{}, - // }, + "custom-type": { + attribute: schema.Float64Attribute{ + CustomType: testtypes.Float64Type{}, + }, + expected: testtypes.Float64Type{}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/int32_attribute_test.go b/datasource/schema/int32_attribute_test.go index 889e3686d..3df85e9c7 100644 --- a/datasource/schema/int32_attribute_test.go +++ b/datasource/schema/int32_attribute_test.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" ) @@ -231,12 +232,12 @@ func TestInt32AttributeGetType(t *testing.T) { attribute: schema.Int32Attribute{}, expected: types.Int32Type, }, - // "custom-type": { - // attribute: schema.Int32Attribute{ - // CustomType: testtypes.Int32Type{}, - // }, - // expected: testtypes.Int32Type{}, - // }, + "custom-type": { + attribute: schema.Int32Attribute{ + CustomType: testtypes.Int32Type{}, + }, + expected: testtypes.Int32Type{}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/int64_attribute_test.go b/datasource/schema/int64_attribute_test.go index 7d560560a..c1ac3c7a4 100644 --- a/datasource/schema/int64_attribute_test.go +++ b/datasource/schema/int64_attribute_test.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -230,12 +231,12 @@ func TestInt64AttributeGetType(t *testing.T) { attribute: schema.Int64Attribute{}, expected: types.Int64Type, }, - // "custom-type": { - // attribute: schema.Int64Attribute{ - // CustomType: testtypes.Int64Type{}, - // }, - // expected: testtypes.Int64Type{}, - // }, + "custom-type": { + attribute: schema.Int64Attribute{ + CustomType: testtypes.Int64Type{}, + }, + expected: testtypes.Int64Type{}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/list_attribute_test.go b/datasource/schema/list_attribute_test.go index 5c33f4fbe..27294a130 100644 --- a/datasource/schema/list_attribute_test.go +++ b/datasource/schema/list_attribute_test.go @@ -239,12 +239,12 @@ func TestListAttributeGetType(t *testing.T) { attribute: schema.ListAttribute{ElementType: types.StringType}, expected: types.ListType{ElemType: types.StringType}, }, - // "custom-type": { - // attribute: schema.ListAttribute{ - // CustomType: testtypes.ListType{}, - // }, - // expected: testtypes.ListType{}, - // }, + "custom-type": { + attribute: schema.ListAttribute{ + CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, + expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/list_nested_attribute_test.go b/datasource/schema/list_nested_attribute_test.go index 5fb035b29..5d1e7db88 100644 --- a/datasource/schema/list_nested_attribute_test.go +++ b/datasource/schema/list_nested_attribute_test.go @@ -386,12 +386,12 @@ func TestListNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: schema.ListNestedAttribute{ - // CustomType: testtypes.ListType{}, - // }, - // expected: testtypes.ListType{}, - // }, + "custom-type": { + attribute: schema.ListNestedAttribute{ + CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, + expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/list_nested_block_test.go b/datasource/schema/list_nested_block_test.go index b1ac538b7..6dce467fa 100644 --- a/datasource/schema/list_nested_block_test.go +++ b/datasource/schema/list_nested_block_test.go @@ -467,12 +467,12 @@ func TestListNestedBlockType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.ListNestedBlock{ - // CustomType: testtypes.ListType{}, - // }, - // expected: testtypes.ListType{}, - // }, + "custom-type": { + block: schema.ListNestedBlock{ + CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, + expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/map_attribute.go b/datasource/schema/map_attribute.go index d9b701f73..516576a4e 100644 --- a/datasource/schema/map_attribute.go +++ b/datasource/schema/map_attribute.go @@ -23,7 +23,7 @@ var ( _ fwxschema.AttributeWithMapValidators = MapAttribute{} ) -// MapAttribute represents a schema attribute that is a list with a single +// MapAttribute represents a schema attribute that is a map with a single // element type. When retrieving the value for this attribute, use types.Map // as the value type unless the CustomType field is set. The ElementType field // must be set. @@ -32,7 +32,7 @@ var ( // require definition beyond type information. // // Terraform configurations configure this attribute using expressions that -// return a list or directly via curly brace syntax. +// return a map or directly via curly brace syntax. // // # map of strings // example_attribute = { diff --git a/datasource/schema/map_attribute_test.go b/datasource/schema/map_attribute_test.go index 6abffa4bb..d79425462 100644 --- a/datasource/schema/map_attribute_test.go +++ b/datasource/schema/map_attribute_test.go @@ -239,12 +239,12 @@ func TestMapAttributeGetType(t *testing.T) { attribute: schema.MapAttribute{ElementType: types.StringType}, expected: types.MapType{ElemType: types.StringType}, }, - // "custom-type": { - // attribute: schema.MapAttribute{ - // CustomType: testtypes.MapType{}, - // }, - // expected: testtypes.MapType{}, - // }, + "custom-type": { + attribute: schema.MapAttribute{ + CustomType: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, + expected: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/map_nested_attribute.go b/datasource/schema/map_nested_attribute.go index 2f3a60ec5..9729efdc3 100644 --- a/datasource/schema/map_nested_attribute.go +++ b/datasource/schema/map_nested_attribute.go @@ -25,7 +25,7 @@ var ( _ fwxschema.AttributeWithMapValidators = MapNestedAttribute{} ) -// MapNestedAttribute represents an attribute that is a set of objects where +// MapNestedAttribute represents an attribute that is a map of objects where // the object attributes can be fully defined, including further nested // attributes. When retrieving the value for this attribute, use types.Map // as the value type unless the CustomType field is set. The NestedObject field @@ -35,7 +35,7 @@ var ( // not require definition beyond type information. // // Terraform configurations configure this attribute using expressions that -// return a set of objects or directly via curly brace syntax. +// return a map of objects or directly via curly brace syntax. // // # map of objects // example_attribute = { @@ -195,7 +195,7 @@ func (a MapNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject { return a.NestedObject } -// GetNestingMode always returns NestingModeList. +// GetNestingMode always returns NestingModeMap. func (a MapNestedAttribute) GetNestingMode() fwschema.NestingMode { return fwschema.NestingModeMap } diff --git a/datasource/schema/map_nested_attribute_test.go b/datasource/schema/map_nested_attribute_test.go index 7e6dbc2a0..ea6dc480d 100644 --- a/datasource/schema/map_nested_attribute_test.go +++ b/datasource/schema/map_nested_attribute_test.go @@ -386,12 +386,12 @@ func TestMapNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: schema.MapNestedAttribute{ - // CustomType: testtypes.MapType{}, - // }, - // expected: testtypes.MapType{}, - // }, + "custom-type": { + attribute: schema.MapNestedAttribute{ + CustomType: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, + expected: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/nested_attribute_object_test.go b/datasource/schema/nested_attribute_object_test.go index 2708eddf2..db5bc1277 100644 --- a/datasource/schema/nested_attribute_object_test.go +++ b/datasource/schema/nested_attribute_object_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -255,12 +256,12 @@ func TestNestedAttributeObjectType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.NestedAttributeObject{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + object: schema.NestedAttributeObject{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/nested_block_object_test.go b/datasource/schema/nested_block_object_test.go index a5631f4cb..2e0aa4738 100644 --- a/datasource/schema/nested_block_object_test.go +++ b/datasource/schema/nested_block_object_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -341,12 +342,12 @@ func TestNestedBlockObjectType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.NestedBlockObject{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + object: schema.NestedBlockObject{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/object_attribute_test.go b/datasource/schema/object_attribute_test.go index e6139dc13..c517465ed 100644 --- a/datasource/schema/object_attribute_test.go +++ b/datasource/schema/object_attribute_test.go @@ -245,12 +245,12 @@ func TestObjectAttributeGetType(t *testing.T) { attribute: schema.ObjectAttribute{AttributeTypes: map[string]attr.Type{"testattr": types.StringType}}, expected: types.ObjectType{AttrTypes: map[string]attr.Type{"testattr": types.StringType}}, }, - // "custom-type": { - // attribute: schema.ObjectAttribute{ - // CustomType: testtypes.ObjectType{}, - // }, - // expected: testtypes.ObjectType{}, - // }, + "custom-type": { + attribute: schema.ObjectAttribute{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/set_attribute_test.go b/datasource/schema/set_attribute_test.go index 4d8f3c3f9..793095705 100644 --- a/datasource/schema/set_attribute_test.go +++ b/datasource/schema/set_attribute_test.go @@ -239,12 +239,12 @@ func TestSetAttributeGetType(t *testing.T) { attribute: schema.SetAttribute{ElementType: types.StringType}, expected: types.SetType{ElemType: types.StringType}, }, - // "custom-type": { - // attribute: schema.SetAttribute{ - // CustomType: testtypes.SetType{}, - // }, - // expected: testtypes.SetType{}, - // }, + "custom-type": { + attribute: schema.SetAttribute{ + CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, + expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/set_nested_attribute.go b/datasource/schema/set_nested_attribute.go index 860ab4c96..1b17b8743 100644 --- a/datasource/schema/set_nested_attribute.go +++ b/datasource/schema/set_nested_attribute.go @@ -190,7 +190,7 @@ func (a SetNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject { return a.NestedObject } -// GetNestingMode always returns NestingModeList. +// GetNestingMode always returns NestingModeSet. func (a SetNestedAttribute) GetNestingMode() fwschema.NestingMode { return fwschema.NestingModeSet } diff --git a/datasource/schema/set_nested_attribute_test.go b/datasource/schema/set_nested_attribute_test.go index 630a64863..7f7815f70 100644 --- a/datasource/schema/set_nested_attribute_test.go +++ b/datasource/schema/set_nested_attribute_test.go @@ -386,12 +386,12 @@ func TestSetNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: schema.SetNestedAttribute{ - // CustomType: testtypes.SetType{}, - // }, - // expected: testtypes.SetType{}, - // }, + "custom-type": { + attribute: schema.SetNestedAttribute{ + CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, + expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/set_nested_block_test.go b/datasource/schema/set_nested_block_test.go index 988aee797..40096f374 100644 --- a/datasource/schema/set_nested_block_test.go +++ b/datasource/schema/set_nested_block_test.go @@ -467,12 +467,12 @@ func TestSetNestedBlockType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.SetNestedBlock{ - // CustomType: testtypes.SetType{}, - // }, - // expected: testtypes.SetType{}, - // }, + "custom-type": { + block: schema.SetNestedBlock{ + CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, + expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/single_nested_attribute.go b/datasource/schema/single_nested_attribute.go index 21c9f3231..811e76de4 100644 --- a/datasource/schema/single_nested_attribute.go +++ b/datasource/schema/single_nested_attribute.go @@ -198,7 +198,7 @@ func (a SingleNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject } } -// GetNestingMode always returns NestingModeList. +// GetNestingMode always returns NestingModeSingle. func (a SingleNestedAttribute) GetNestingMode() fwschema.NestingMode { return fwschema.NestingModeSingle } diff --git a/datasource/schema/single_nested_attribute_test.go b/datasource/schema/single_nested_attribute_test.go index 817eaaf7c..25a5e565e 100644 --- a/datasource/schema/single_nested_attribute_test.go +++ b/datasource/schema/single_nested_attribute_test.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -354,12 +355,12 @@ func TestSingleNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: schema.SingleNestedAttribute{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + attribute: schema.SingleNestedAttribute{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/datasource/schema/single_nested_block_test.go b/datasource/schema/single_nested_block_test.go index e204b534c..041f98bfa 100644 --- a/datasource/schema/single_nested_block_test.go +++ b/datasource/schema/single_nested_block_test.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -461,12 +462,12 @@ func TestSingleNestedBlockType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.SingleNestedBlock{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + block: schema.SingleNestedBlock{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/provider/metaschema/float64_attribute_test.go b/provider/metaschema/float64_attribute_test.go index 763da9ac7..71cb2f688 100644 --- a/provider/metaschema/float64_attribute_test.go +++ b/provider/metaschema/float64_attribute_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/metaschema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -223,12 +224,12 @@ func TestFloat64AttributeGetType(t *testing.T) { attribute: metaschema.Float64Attribute{}, expected: types.Float64Type, }, - // "custom-type": { - // attribute: metaschema.Float64Attribute{ - // CustomType: testtypes.Float64Type{}, - // }, - // expected: testtypes.Float64Type{}, - // }, + "custom-type": { + attribute: metaschema.Float64Attribute{ + CustomType: testtypes.Float64Type{}, + }, + expected: testtypes.Float64Type{}, + }, } for name, testCase := range testCases { diff --git a/provider/metaschema/int64_attribute_test.go b/provider/metaschema/int64_attribute_test.go index 55a3c96f0..28efcebd7 100644 --- a/provider/metaschema/int64_attribute_test.go +++ b/provider/metaschema/int64_attribute_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/metaschema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -223,12 +224,12 @@ func TestInt64AttributeGetType(t *testing.T) { attribute: metaschema.Int64Attribute{}, expected: types.Int64Type, }, - // "custom-type": { - // attribute: metaschema.Int64Attribute{ - // CustomType: testtypes.Int64Type{}, - // }, - // expected: testtypes.Int64Type{}, - // }, + "custom-type": { + attribute: metaschema.Int64Attribute{ + CustomType: testtypes.Int64Type{}, + }, + expected: testtypes.Int64Type{}, + }, } for name, testCase := range testCases { diff --git a/provider/metaschema/list_attribute_test.go b/provider/metaschema/list_attribute_test.go index 0677b66e6..6c864e8d6 100644 --- a/provider/metaschema/list_attribute_test.go +++ b/provider/metaschema/list_attribute_test.go @@ -232,12 +232,12 @@ func TestListAttributeGetType(t *testing.T) { attribute: metaschema.ListAttribute{ElementType: types.StringType}, expected: types.ListType{ElemType: types.StringType}, }, - // "custom-type": { - // attribute: metaschema.ListAttribute{ - // CustomType: testtypes.ListType{}, - // }, - // expected: testtypes.ListType{}, - // }, + "custom-type": { + attribute: metaschema.ListAttribute{ + CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, + expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/metaschema/list_nested_attribute_test.go b/provider/metaschema/list_nested_attribute_test.go index 56ca2e1f8..dc6188822 100644 --- a/provider/metaschema/list_nested_attribute_test.go +++ b/provider/metaschema/list_nested_attribute_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/metaschema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -375,12 +376,12 @@ func TestListNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: metaschema.ListNestedAttribute{ - // CustomType: testtypes.ListType{}, - // }, - // expected: testtypes.ListType{}, - // }, + "custom-type": { + attribute: metaschema.ListNestedAttribute{ + CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, + expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/metaschema/map_attribute.go b/provider/metaschema/map_attribute.go index d75cec982..51ee02edb 100644 --- a/provider/metaschema/map_attribute.go +++ b/provider/metaschema/map_attribute.go @@ -19,7 +19,7 @@ var ( _ fwschema.AttributeWithValidateImplementation = MapAttribute{} ) -// MapAttribute represents a schema attribute that is a list with a single +// MapAttribute represents a schema attribute that is a map with a single // element type. When retrieving the value for this attribute, use types.Map // as the value type unless the CustomType field is set. The ElementType field // must be set. @@ -28,7 +28,7 @@ var ( // require definition beyond type information. // // Terraform configurations configure this attribute using expressions that -// return a list or directly via curly brace syntax. +// return a map or directly via curly brace syntax. // // # map of strings // example_attribute = { diff --git a/provider/metaschema/map_attribute_test.go b/provider/metaschema/map_attribute_test.go index 9f4f5f32f..0956d8cc4 100644 --- a/provider/metaschema/map_attribute_test.go +++ b/provider/metaschema/map_attribute_test.go @@ -232,12 +232,12 @@ func TestMapAttributeGetType(t *testing.T) { attribute: metaschema.MapAttribute{ElementType: types.StringType}, expected: types.MapType{ElemType: types.StringType}, }, - // "custom-type": { - // attribute: metaschema.MapAttribute{ - // CustomType: testtypes.MapType{}, - // }, - // expected: testtypes.MapType{}, - // }, + "custom-type": { + attribute: metaschema.MapAttribute{ + CustomType: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, + expected: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/metaschema/map_nested_attribute.go b/provider/metaschema/map_nested_attribute.go index a8809b7a6..47a3b4348 100644 --- a/provider/metaschema/map_nested_attribute.go +++ b/provider/metaschema/map_nested_attribute.go @@ -18,7 +18,7 @@ var ( _ NestedAttribute = MapNestedAttribute{} ) -// MapNestedAttribute represents an attribute that is a set of objects where +// MapNestedAttribute represents an attribute that is a map of objects where // the object attributes can be fully defined, including further nested // attributes. When retrieving the value for this attribute, use types.Map // as the value type unless the CustomType field is set. The NestedObject field @@ -28,7 +28,7 @@ var ( // not require definition beyond type information. // // Terraform configurations configure this attribute using expressions that -// return a set of objects or directly via curly brace syntax. +// return a map of objects or directly via curly brace syntax. // // # map of objects // example_attribute = { @@ -123,7 +123,7 @@ func (a MapNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject { return a.NestedObject } -// GetNestingMode always returns NestingModeList. +// GetNestingMode always returns NestingModeMap. func (a MapNestedAttribute) GetNestingMode() fwschema.NestingMode { return fwschema.NestingModeMap } diff --git a/provider/metaschema/map_nested_attribute_test.go b/provider/metaschema/map_nested_attribute_test.go index a014c6429..7c320b1bf 100644 --- a/provider/metaschema/map_nested_attribute_test.go +++ b/provider/metaschema/map_nested_attribute_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/metaschema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -375,12 +376,12 @@ func TestMapNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: metaschema.MapNestedAttribute{ - // CustomType: testtypes.MapType{}, - // }, - // expected: testtypes.MapType{}, - // }, + "custom-type": { + attribute: metaschema.MapNestedAttribute{ + CustomType: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, + expected: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/metaschema/nested_attribute_object_test.go b/provider/metaschema/nested_attribute_object_test.go index afb466785..c9ca5a210 100644 --- a/provider/metaschema/nested_attribute_object_test.go +++ b/provider/metaschema/nested_attribute_object_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/metaschema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -216,12 +217,12 @@ func TestNestedAttributeObjectType(t *testing.T) { }, }, }, - // "custom-type": { - // block: metaschema.NestedAttributeObject{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + object: metaschema.NestedAttributeObject{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/provider/metaschema/object_attribute_test.go b/provider/metaschema/object_attribute_test.go index 93acca227..e24db5dd1 100644 --- a/provider/metaschema/object_attribute_test.go +++ b/provider/metaschema/object_attribute_test.go @@ -238,12 +238,12 @@ func TestObjectAttributeGetType(t *testing.T) { attribute: metaschema.ObjectAttribute{AttributeTypes: map[string]attr.Type{"testattr": types.StringType}}, expected: types.ObjectType{AttrTypes: map[string]attr.Type{"testattr": types.StringType}}, }, - // "custom-type": { - // attribute: metaschema.ObjectAttribute{ - // CustomType: testtypes.ObjectType{}, - // }, - // expected: testtypes.ObjectType{}, - // }, + "custom-type": { + attribute: metaschema.ObjectAttribute{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/provider/metaschema/set_attribute_test.go b/provider/metaschema/set_attribute_test.go index 9e0bbb18e..8cb5a95d5 100644 --- a/provider/metaschema/set_attribute_test.go +++ b/provider/metaschema/set_attribute_test.go @@ -232,12 +232,12 @@ func TestSetAttributeGetType(t *testing.T) { attribute: metaschema.SetAttribute{ElementType: types.StringType}, expected: types.SetType{ElemType: types.StringType}, }, - // "custom-type": { - // attribute: metaschema.SetAttribute{ - // CustomType: testtypes.SetType{}, - // }, - // expected: testtypes.SetType{}, - // }, + "custom-type": { + attribute: metaschema.SetAttribute{ + CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, + expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/metaschema/set_nested_attribute.go b/provider/metaschema/set_nested_attribute.go index 8bbcf1259..233866a00 100644 --- a/provider/metaschema/set_nested_attribute.go +++ b/provider/metaschema/set_nested_attribute.go @@ -118,7 +118,7 @@ func (a SetNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject { return a.NestedObject } -// GetNestingMode always returns NestingModeList. +// GetNestingMode always returns NestingModeSet. func (a SetNestedAttribute) GetNestingMode() fwschema.NestingMode { return fwschema.NestingModeSet } diff --git a/provider/metaschema/set_nested_attribute_test.go b/provider/metaschema/set_nested_attribute_test.go index 8ac6ed87a..623fa3668 100644 --- a/provider/metaschema/set_nested_attribute_test.go +++ b/provider/metaschema/set_nested_attribute_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/metaschema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -375,12 +376,12 @@ func TestSetNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: metaschema.SetNestedAttribute{ - // CustomType: testtypes.SetType{}, - // }, - // expected: testtypes.SetType{}, - // }, + "custom-type": { + attribute: metaschema.SetNestedAttribute{ + CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, + expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/metaschema/single_nested_attribute.go b/provider/metaschema/single_nested_attribute.go index de4dc07a4..0ed1a22fd 100644 --- a/provider/metaschema/single_nested_attribute.go +++ b/provider/metaschema/single_nested_attribute.go @@ -132,7 +132,7 @@ func (a SingleNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject } } -// GetNestingMode always returns NestingModeList. +// GetNestingMode always returns NestingModeSingle. func (a SingleNestedAttribute) GetNestingMode() fwschema.NestingMode { return fwschema.NestingModeSingle } diff --git a/provider/metaschema/single_nested_attribute_test.go b/provider/metaschema/single_nested_attribute_test.go index a8ce22e63..f7c7cbda5 100644 --- a/provider/metaschema/single_nested_attribute_test.go +++ b/provider/metaschema/single_nested_attribute_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/metaschema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -347,12 +348,12 @@ func TestSingleNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: metaschema.SingleNestedAttribute{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + attribute: metaschema.SingleNestedAttribute{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/attribute.go b/provider/schema/attribute.go index 4a0feceec..67294bfc6 100644 --- a/provider/schema/attribute.go +++ b/provider/schema/attribute.go @@ -10,7 +10,10 @@ import ( // Attribute define a value field inside the Schema. Implementations in this // package include: // - BoolAttribute +// - DynamicAttribute +// - Float32Attribute // - Float64Attribute +// - Int32Attribute // - Int64Attribute // - ListAttribute // - MapAttribute diff --git a/provider/schema/float32_attribute_test.go b/provider/schema/float32_attribute_test.go index c792d326e..e779b4a0a 100644 --- a/provider/schema/float32_attribute_test.go +++ b/provider/schema/float32_attribute_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" @@ -264,12 +265,12 @@ func TestFloat32AttributeGetType(t *testing.T) { attribute: schema.Float32Attribute{}, expected: types.Float32Type, }, - // "custom-type": { - // attribute: schema.Float32Attribute{ - // CustomType: testtypes.Float32Type{}, - // }, - // expected: testtypes.Float32Type{}, - // }, + "custom-type": { + attribute: schema.Float32Attribute{ + CustomType: testtypes.Float32Type{}, + }, + expected: testtypes.Float32Type{}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/float64_attribute_test.go b/provider/schema/float64_attribute_test.go index 4478a88b6..96604d0e7 100644 --- a/provider/schema/float64_attribute_test.go +++ b/provider/schema/float64_attribute_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" @@ -264,12 +265,12 @@ func TestFloat64AttributeGetType(t *testing.T) { attribute: schema.Float64Attribute{}, expected: types.Float64Type, }, - // "custom-type": { - // attribute: schema.Float64Attribute{ - // CustomType: testtypes.Float64Type{}, - // }, - // expected: testtypes.Float64Type{}, - // }, + "custom-type": { + attribute: schema.Float64Attribute{ + CustomType: testtypes.Float64Type{}, + }, + expected: testtypes.Float64Type{}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/int64_attribute_test.go b/provider/schema/int64_attribute_test.go index 505df6657..f5e457663 100644 --- a/provider/schema/int64_attribute_test.go +++ b/provider/schema/int64_attribute_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" @@ -230,12 +231,12 @@ func TestInt64AttributeGetType(t *testing.T) { attribute: schema.Int64Attribute{}, expected: types.Int64Type, }, - // "custom-type": { - // attribute: schema.Int64Attribute{ - // CustomType: testtypes.Int64Type{}, - // }, - // expected: testtypes.Int64Type{}, - // }, + "custom-type": { + attribute: schema.Int64Attribute{ + CustomType: testtypes.Int64Type{}, + }, + expected: testtypes.Int64Type{}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/list_attribute_test.go b/provider/schema/list_attribute_test.go index cde4bc7c7..3baa9382b 100644 --- a/provider/schema/list_attribute_test.go +++ b/provider/schema/list_attribute_test.go @@ -239,12 +239,12 @@ func TestListAttributeGetType(t *testing.T) { attribute: schema.ListAttribute{ElementType: types.StringType}, expected: types.ListType{ElemType: types.StringType}, }, - // "custom-type": { - // attribute: schema.ListAttribute{ - // CustomType: testtypes.ListType{}, - // }, - // expected: testtypes.ListType{}, - // }, + "custom-type": { + attribute: schema.ListAttribute{ + CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, + expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/list_nested_attribute_test.go b/provider/schema/list_nested_attribute_test.go index 93d23a555..43d76a612 100644 --- a/provider/schema/list_nested_attribute_test.go +++ b/provider/schema/list_nested_attribute_test.go @@ -386,12 +386,12 @@ func TestListNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: schema.ListNestedAttribute{ - // CustomType: testtypes.ListType{}, - // }, - // expected: testtypes.ListType{}, - // }, + "custom-type": { + attribute: schema.ListNestedAttribute{ + CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, + expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/list_nested_block_test.go b/provider/schema/list_nested_block_test.go index d8ad26e00..f7042840e 100644 --- a/provider/schema/list_nested_block_test.go +++ b/provider/schema/list_nested_block_test.go @@ -467,12 +467,12 @@ func TestListNestedBlockType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.ListNestedBlock{ - // CustomType: testtypes.ListType{}, - // }, - // expected: testtypes.ListType{}, - // }, + "custom-type": { + block: schema.ListNestedBlock{ + CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, + expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/map_attribute.go b/provider/schema/map_attribute.go index 079535e77..77dc2b61d 100644 --- a/provider/schema/map_attribute.go +++ b/provider/schema/map_attribute.go @@ -23,7 +23,7 @@ var ( _ fwxschema.AttributeWithMapValidators = MapAttribute{} ) -// MapAttribute represents a schema attribute that is a list with a single +// MapAttribute represents a schema attribute that is a map with a single // element type. When retrieving the value for this attribute, use types.Map // as the value type unless the CustomType field is set. The ElementType field // must be set. @@ -32,7 +32,7 @@ var ( // require definition beyond type information. // // Terraform configurations configure this attribute using expressions that -// return a list or directly via curly brace syntax. +// return a map or directly via curly brace syntax. // // # map of strings // example_attribute = { diff --git a/provider/schema/map_attribute_test.go b/provider/schema/map_attribute_test.go index d16e728c2..0bbef5f25 100644 --- a/provider/schema/map_attribute_test.go +++ b/provider/schema/map_attribute_test.go @@ -239,12 +239,12 @@ func TestMapAttributeGetType(t *testing.T) { attribute: schema.MapAttribute{ElementType: types.StringType}, expected: types.MapType{ElemType: types.StringType}, }, - // "custom-type": { - // attribute: schema.MapAttribute{ - // CustomType: testtypes.MapType{}, - // }, - // expected: testtypes.MapType{}, - // }, + "custom-type": { + attribute: schema.MapAttribute{ + CustomType: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, + expected: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/map_nested_attribute.go b/provider/schema/map_nested_attribute.go index 0cdc9b5e0..2eed2fa08 100644 --- a/provider/schema/map_nested_attribute.go +++ b/provider/schema/map_nested_attribute.go @@ -24,7 +24,7 @@ var ( _ fwxschema.AttributeWithMapValidators = MapNestedAttribute{} ) -// MapNestedAttribute represents an attribute that is a set of objects where +// MapNestedAttribute represents an attribute that is a map of objects where // the object attributes can be fully defined, including further nested // attributes. When retrieving the value for this attribute, use types.Map // as the value type unless the CustomType field is set. The NestedObject field @@ -34,7 +34,7 @@ var ( // not require definition beyond type information. // // Terraform configurations configure this attribute using expressions that -// return a set of objects or directly via curly brace syntax. +// return a map of objects or directly via curly brace syntax. // // # map of objects // example_attribute = { @@ -187,7 +187,7 @@ func (a MapNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject { return a.NestedObject } -// GetNestingMode always returns NestingModeList. +// GetNestingMode always returns NestingModeMap. func (a MapNestedAttribute) GetNestingMode() fwschema.NestingMode { return fwschema.NestingModeMap } diff --git a/provider/schema/map_nested_attribute_test.go b/provider/schema/map_nested_attribute_test.go index ec0598bf0..193960869 100644 --- a/provider/schema/map_nested_attribute_test.go +++ b/provider/schema/map_nested_attribute_test.go @@ -386,12 +386,12 @@ func TestMapNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: schema.MapNestedAttribute{ - // CustomType: testtypes.MapType{}, - // }, - // expected: testtypes.MapType{}, - // }, + "custom-type": { + attribute: schema.MapNestedAttribute{ + CustomType: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, + expected: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/nested_attribute_object_test.go b/provider/schema/nested_attribute_object_test.go index b1728c532..968d071d0 100644 --- a/provider/schema/nested_attribute_object_test.go +++ b/provider/schema/nested_attribute_object_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" @@ -255,12 +256,12 @@ func TestNestedAttributeObjectType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.NestedAttributeObject{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + object: schema.NestedAttributeObject{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/nested_block_object_test.go b/provider/schema/nested_block_object_test.go index 4c310eace..5fa2a9c7e 100644 --- a/provider/schema/nested_block_object_test.go +++ b/provider/schema/nested_block_object_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" @@ -341,12 +342,12 @@ func TestNestedBlockObjectType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.NestedBlockObject{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + object: schema.NestedBlockObject{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/object_attribute_test.go b/provider/schema/object_attribute_test.go index 4fd9c9d9a..01f65b864 100644 --- a/provider/schema/object_attribute_test.go +++ b/provider/schema/object_attribute_test.go @@ -245,12 +245,12 @@ func TestObjectAttributeGetType(t *testing.T) { attribute: schema.ObjectAttribute{AttributeTypes: map[string]attr.Type{"testattr": types.StringType}}, expected: types.ObjectType{AttrTypes: map[string]attr.Type{"testattr": types.StringType}}, }, - // "custom-type": { - // attribute: schema.ObjectAttribute{ - // CustomType: testtypes.ObjectType{}, - // }, - // expected: testtypes.ObjectType{}, - // }, + "custom-type": { + attribute: schema.ObjectAttribute{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/set_attribute_test.go b/provider/schema/set_attribute_test.go index b62366ed9..862b2d8dd 100644 --- a/provider/schema/set_attribute_test.go +++ b/provider/schema/set_attribute_test.go @@ -239,12 +239,12 @@ func TestSetAttributeGetType(t *testing.T) { attribute: schema.SetAttribute{ElementType: types.StringType}, expected: types.SetType{ElemType: types.StringType}, }, - // "custom-type": { - // attribute: schema.SetAttribute{ - // CustomType: testtypes.SetType{}, - // }, - // expected: testtypes.SetType{}, - // }, + "custom-type": { + attribute: schema.SetAttribute{ + CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, + expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/set_nested_attribute.go b/provider/schema/set_nested_attribute.go index 64fed1ea2..7a2fb6060 100644 --- a/provider/schema/set_nested_attribute.go +++ b/provider/schema/set_nested_attribute.go @@ -183,7 +183,7 @@ func (a SetNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject { return a.NestedObject } -// GetNestingMode always returns NestingModeList. +// GetNestingMode always returns NestingModeSet. func (a SetNestedAttribute) GetNestingMode() fwschema.NestingMode { return fwschema.NestingModeSet } diff --git a/provider/schema/set_nested_attribute_test.go b/provider/schema/set_nested_attribute_test.go index 32c6b810b..163604a9c 100644 --- a/provider/schema/set_nested_attribute_test.go +++ b/provider/schema/set_nested_attribute_test.go @@ -386,12 +386,12 @@ func TestSetNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: schema.SetNestedAttribute{ - // CustomType: testtypes.SetType{}, - // }, - // expected: testtypes.SetType{}, - // }, + "custom-type": { + attribute: schema.SetNestedAttribute{ + CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, + expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/set_nested_block_test.go b/provider/schema/set_nested_block_test.go index ab0481f14..d8a680009 100644 --- a/provider/schema/set_nested_block_test.go +++ b/provider/schema/set_nested_block_test.go @@ -467,12 +467,12 @@ func TestSetNestedBlockType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.SetNestedBlock{ - // CustomType: testtypes.SetType{}, - // }, - // expected: testtypes.SetType{}, - // }, + "custom-type": { + block: schema.SetNestedBlock{ + CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, + expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/single_nested_attribute.go b/provider/schema/single_nested_attribute.go index aac9875af..4aa669bf1 100644 --- a/provider/schema/single_nested_attribute.go +++ b/provider/schema/single_nested_attribute.go @@ -191,7 +191,7 @@ func (a SingleNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject } } -// GetNestingMode always returns NestingModeList. +// GetNestingMode always returns NestingModeSingle. func (a SingleNestedAttribute) GetNestingMode() fwschema.NestingMode { return fwschema.NestingModeSingle } diff --git a/provider/schema/single_nested_attribute_test.go b/provider/schema/single_nested_attribute_test.go index 1fba1ce40..a471cbc20 100644 --- a/provider/schema/single_nested_attribute_test.go +++ b/provider/schema/single_nested_attribute_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" @@ -354,12 +355,12 @@ func TestSingleNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: schema.SingleNestedAttribute{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + attribute: schema.SingleNestedAttribute{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/provider/schema/single_nested_block_test.go b/provider/schema/single_nested_block_test.go index 9a313bcea..802f41be6 100644 --- a/provider/schema/single_nested_block_test.go +++ b/provider/schema/single_nested_block_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" @@ -461,12 +462,12 @@ func TestSingleNestedBlockType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.SingleNestedBlock{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + block: schema.SingleNestedBlock{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/attribute.go b/resource/schema/attribute.go index 4a0feceec..67294bfc6 100644 --- a/resource/schema/attribute.go +++ b/resource/schema/attribute.go @@ -10,7 +10,10 @@ import ( // Attribute define a value field inside the Schema. Implementations in this // package include: // - BoolAttribute +// - DynamicAttribute +// - Float32Attribute // - Float64Attribute +// - Int32Attribute // - Int64Attribute // - ListAttribute // - MapAttribute diff --git a/resource/schema/float32_attribute_test.go b/resource/schema/float32_attribute_test.go index 0b211351b..75f1a9637 100644 --- a/resource/schema/float32_attribute_test.go +++ b/resource/schema/float32_attribute_test.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults" @@ -352,12 +353,12 @@ func TestFloat32AttributeGetType(t *testing.T) { attribute: schema.Float32Attribute{}, expected: types.Float32Type, }, - // "custom-type": { - // attribute: schema.Float32Attribute{ - // CustomType: testtypes.Float32Type{}, - // }, - // expected: testtypes.Float32Type{}, - // }, + "custom-type": { + attribute: schema.Float32Attribute{ + CustomType: testtypes.Float32Type{}, + }, + expected: testtypes.Float32Type{}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/float64_attribute_test.go b/resource/schema/float64_attribute_test.go index d30f34b0e..a7d155c9f 100644 --- a/resource/schema/float64_attribute_test.go +++ b/resource/schema/float64_attribute_test.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults" @@ -352,12 +353,12 @@ func TestFloat64AttributeGetType(t *testing.T) { attribute: schema.Float64Attribute{}, expected: types.Float64Type, }, - // "custom-type": { - // attribute: schema.Float64Attribute{ - // CustomType: testtypes.Float64Type{}, - // }, - // expected: testtypes.Float64Type{}, - // }, + "custom-type": { + attribute: schema.Float64Attribute{ + CustomType: testtypes.Float64Type{}, + }, + expected: testtypes.Float64Type{}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/int64_attribute_test.go b/resource/schema/int64_attribute_test.go index f52c11928..a961c1fb8 100644 --- a/resource/schema/int64_attribute_test.go +++ b/resource/schema/int64_attribute_test.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults" @@ -237,12 +238,12 @@ func TestInt64AttributeGetType(t *testing.T) { attribute: schema.Int64Attribute{}, expected: types.Int64Type, }, - // "custom-type": { - // attribute: schema.Int64Attribute{ - // CustomType: testtypes.Int64Type{}, - // }, - // expected: testtypes.Int64Type{}, - // }, + "custom-type": { + attribute: schema.Int64Attribute{ + CustomType: testtypes.Int64Type{}, + }, + expected: testtypes.Int64Type{}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/list_attribute_test.go b/resource/schema/list_attribute_test.go index 5c15849cc..784ec70d6 100644 --- a/resource/schema/list_attribute_test.go +++ b/resource/schema/list_attribute_test.go @@ -244,12 +244,12 @@ func TestListAttributeGetType(t *testing.T) { attribute: schema.ListAttribute{ElementType: types.StringType}, expected: types.ListType{ElemType: types.StringType}, }, - // "custom-type": { - // attribute: schema.ListAttribute{ - // CustomType: testtypes.ListType{}, - // }, - // expected: testtypes.ListType{}, - // }, + "custom-type": { + attribute: schema.ListAttribute{ + CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, + expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/list_nested_attribute_test.go b/resource/schema/list_nested_attribute_test.go index 1662109aa..a73c7a843 100644 --- a/resource/schema/list_nested_attribute_test.go +++ b/resource/schema/list_nested_attribute_test.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testdefaults" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults" @@ -390,12 +391,12 @@ func TestListNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: schema.ListNestedAttribute{ - // CustomType: testtypes.ListType{}, - // }, - // expected: testtypes.ListType{}, - // }, + "custom-type": { + attribute: schema.ListNestedAttribute{ + CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, + expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/list_nested_block_test.go b/resource/schema/list_nested_block_test.go index 332a7ad19..c58551a04 100644 --- a/resource/schema/list_nested_block_test.go +++ b/resource/schema/list_nested_block_test.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" @@ -507,12 +508,12 @@ func TestListNestedBlockType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.ListNestedBlock{ - // CustomType: testtypes.ListType{}, - // }, - // expected: testtypes.ListType{}, - // }, + "custom-type": { + block: schema.ListNestedBlock{ + CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, + expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/map_attribute.go b/resource/schema/map_attribute.go index ea08fa7b2..ac50f63f8 100644 --- a/resource/schema/map_attribute.go +++ b/resource/schema/map_attribute.go @@ -28,7 +28,7 @@ var ( _ fwxschema.AttributeWithMapValidators = MapAttribute{} ) -// MapAttribute represents a schema attribute that is a list with a single +// MapAttribute represents a schema attribute that is a map with a single // element type. When retrieving the value for this attribute, use types.Map // as the value type unless the CustomType field is set. The ElementType field // must be set. @@ -37,7 +37,7 @@ var ( // require definition beyond type information. // // Terraform configurations configure this attribute using expressions that -// return a list or directly via curly brace syntax. +// return a map or directly via curly brace syntax. // // # map of strings // example_attribute = { diff --git a/resource/schema/map_attribute_test.go b/resource/schema/map_attribute_test.go index e4ff058f0..4f56036d5 100644 --- a/resource/schema/map_attribute_test.go +++ b/resource/schema/map_attribute_test.go @@ -244,12 +244,12 @@ func TestMapAttributeGetType(t *testing.T) { attribute: schema.MapAttribute{ElementType: types.StringType}, expected: types.MapType{ElemType: types.StringType}, }, - // "custom-type": { - // attribute: schema.MapAttribute{ - // CustomType: testtypes.MapType{}, - // }, - // expected: testtypes.MapType{}, - // }, + "custom-type": { + attribute: schema.MapAttribute{ + CustomType: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, + expected: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/map_nested_attribute.go b/resource/schema/map_nested_attribute.go index faa1f3276..ab2230b3b 100644 --- a/resource/schema/map_nested_attribute.go +++ b/resource/schema/map_nested_attribute.go @@ -29,7 +29,7 @@ var ( _ fwxschema.AttributeWithMapValidators = MapNestedAttribute{} ) -// MapNestedAttribute represents an attribute that is a set of objects where +// MapNestedAttribute represents an attribute that is a map of objects where // the object attributes can be fully defined, including further nested // attributes. When retrieving the value for this attribute, use types.Map // as the value type unless the CustomType field is set. The NestedObject field @@ -39,7 +39,7 @@ var ( // not require definition beyond type information. // // Terraform configurations configure this attribute using expressions that -// return a set of objects or directly via curly brace syntax. +// return a map of objects or directly via curly brace syntax. // // # map of objects // example_attribute = { @@ -224,7 +224,7 @@ func (a MapNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject { return a.NestedObject } -// GetNestingMode always returns NestingModeList. +// GetNestingMode always returns NestingModeMap. func (a MapNestedAttribute) GetNestingMode() fwschema.NestingMode { return fwschema.NestingModeMap } diff --git a/resource/schema/map_nested_attribute_test.go b/resource/schema/map_nested_attribute_test.go index ba3e1cdd7..1fd1a7624 100644 --- a/resource/schema/map_nested_attribute_test.go +++ b/resource/schema/map_nested_attribute_test.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testdefaults" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults" @@ -390,12 +391,12 @@ func TestMapNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: schema.MapNestedAttribute{ - // CustomType: testtypes.MapType{}, - // }, - // expected: testtypes.MapType{}, - // }, + "custom-type": { + attribute: schema.MapNestedAttribute{ + CustomType: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, + expected: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/nested_attribute_object_test.go b/resource/schema/nested_attribute_object_test.go index af2156cbb..7b325bbb8 100644 --- a/resource/schema/nested_attribute_object_test.go +++ b/resource/schema/nested_attribute_object_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" @@ -293,12 +294,12 @@ func TestNestedAttributeObjectType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.NestedAttributeObject{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + object: schema.NestedAttributeObject{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/nested_block_object_test.go b/resource/schema/nested_block_object_test.go index 830a9d3f8..95ff4613a 100644 --- a/resource/schema/nested_block_object_test.go +++ b/resource/schema/nested_block_object_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" @@ -380,12 +381,12 @@ func TestNestedBlockObjectType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.NestedBlockObject{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + object: schema.NestedBlockObject{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/object_attribute_test.go b/resource/schema/object_attribute_test.go index ddc014742..071e2293c 100644 --- a/resource/schema/object_attribute_test.go +++ b/resource/schema/object_attribute_test.go @@ -250,12 +250,12 @@ func TestObjectAttributeGetType(t *testing.T) { attribute: schema.ObjectAttribute{AttributeTypes: map[string]attr.Type{"testattr": types.StringType}}, expected: types.ObjectType{AttrTypes: map[string]attr.Type{"testattr": types.StringType}}, }, - // "custom-type": { - // attribute: schema.ObjectAttribute{ - // CustomType: testtypes.ObjectType{}, - // }, - // expected: testtypes.ObjectType{}, - // }, + "custom-type": { + attribute: schema.ObjectAttribute{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/set_attribute_test.go b/resource/schema/set_attribute_test.go index c5675e820..98483f724 100644 --- a/resource/schema/set_attribute_test.go +++ b/resource/schema/set_attribute_test.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testdefaults" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults" @@ -243,12 +244,12 @@ func TestSetAttributeGetType(t *testing.T) { attribute: schema.SetAttribute{ElementType: types.StringType}, expected: types.SetType{ElemType: types.StringType}, }, - // "custom-type": { - // attribute: schema.SetAttribute{ - // CustomType: testtypes.SetType{}, - // }, - // expected: testtypes.SetType{}, - // }, + "custom-type": { + attribute: schema.SetAttribute{ + CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, + expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/set_nested_attribute.go b/resource/schema/set_nested_attribute.go index 3f2b3d1bb..dee37b591 100644 --- a/resource/schema/set_nested_attribute.go +++ b/resource/schema/set_nested_attribute.go @@ -219,7 +219,7 @@ func (a SetNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject { return a.NestedObject } -// GetNestingMode always returns NestingModeList. +// GetNestingMode always returns NestingModeSet. func (a SetNestedAttribute) GetNestingMode() fwschema.NestingMode { return fwschema.NestingModeSet } diff --git a/resource/schema/set_nested_attribute_test.go b/resource/schema/set_nested_attribute_test.go index 109921d00..d148db457 100644 --- a/resource/schema/set_nested_attribute_test.go +++ b/resource/schema/set_nested_attribute_test.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testdefaults" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults" @@ -390,12 +391,12 @@ func TestSetNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: schema.SetNestedAttribute{ - // CustomType: testtypes.SetType{}, - // }, - // expected: testtypes.SetType{}, - // }, + "custom-type": { + attribute: schema.SetNestedAttribute{ + CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, + expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/set_nested_block_test.go b/resource/schema/set_nested_block_test.go index f90edb279..45d054366 100644 --- a/resource/schema/set_nested_block_test.go +++ b/resource/schema/set_nested_block_test.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" @@ -507,12 +508,12 @@ func TestSetNestedBlockType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.SetNestedBlock{ - // CustomType: testtypes.SetType{}, - // }, - // expected: testtypes.SetType{}, - // }, + "custom-type": { + block: schema.SetNestedBlock{ + CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, + expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/single_nested_attribute.go b/resource/schema/single_nested_attribute.go index a47ef6541..3dbda942a 100644 --- a/resource/schema/single_nested_attribute.go +++ b/resource/schema/single_nested_attribute.go @@ -229,7 +229,7 @@ func (a SingleNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject } } -// GetNestingMode always returns NestingModeList. +// GetNestingMode always returns NestingModeSingle. func (a SingleNestedAttribute) GetNestingMode() fwschema.NestingMode { return fwschema.NestingModeSingle } diff --git a/resource/schema/single_nested_attribute_test.go b/resource/schema/single_nested_attribute_test.go index ba9fb1309..1f20b65b3 100644 --- a/resource/schema/single_nested_attribute_test.go +++ b/resource/schema/single_nested_attribute_test.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testdefaults" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults" @@ -362,12 +363,12 @@ func TestSingleNestedAttributeGetType(t *testing.T) { }, }, }, - // "custom-type": { - // attribute: schema.SingleNestedAttribute{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + attribute: schema.SingleNestedAttribute{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases { diff --git a/resource/schema/single_nested_block_test.go b/resource/schema/single_nested_block_test.go index 7a18414f9..8216ca180 100644 --- a/resource/schema/single_nested_block_test.go +++ b/resource/schema/single_nested_block_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/internal/fwschema" "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema" + "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" @@ -500,12 +501,12 @@ func TestSingleNestedBlockType(t *testing.T) { }, }, }, - // "custom-type": { - // block: schema.SingleNestedBlock{ - // CustomType: testtypes.SingleType{}, - // }, - // expected: testtypes.SingleType{}, - // }, + "custom-type": { + block: schema.SingleNestedBlock{ + CustomType: testtypes.ObjectType{}, + }, + expected: testtypes.ObjectType{}, + }, } for name, testCase := range testCases {