diff --git a/.changes/1.12.0.md b/.changes/1.12.0.md new file mode 100644 index 000000000..249d40565 --- /dev/null +++ b/.changes/1.12.0.md @@ -0,0 +1,10 @@ +## 1.12.0 (September 18, 2024) + +NOTES: + +* all: This Go module has been updated to Go 1.22 per the [Go support policy](https://go.dev/doc/devel/release#policy). It is recommended to review the [Go 1.22 release notes](https://go.dev/doc/go1.22) before upgrading. Any consumers building on earlier Go versions may experience errors ([#1033](https://github.com/hashicorp/terraform-plugin-framework/issues/1033)) + +BUG FIXES: + +* providerserver: Fixed bug that prevented `moved` operation support between resource types for framework-only providers. ([#1039](https://github.com/hashicorp/terraform-plugin-framework/issues/1039)) + diff --git a/.github/workflows/ci-go.yml b/.github/workflows/ci-go.yml index 5817291dd..3515456ec 100644 --- a/.github/workflows/ci-go.yml +++ b/.github/workflows/ci-go.yml @@ -21,7 +21,7 @@ jobs: with: go-version-file: 'go.mod' - run: go mod download - - uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1 + - uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0 terraform-provider-corner-tfprotov5: defaults: run: @@ -37,7 +37,7 @@ jobs: - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version-file: 'go.mod' - - uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1 + - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 with: terraform_version: ${{ matrix.terraform }} terraform_wrapper: false @@ -63,7 +63,7 @@ jobs: - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version-file: 'go.mod' - - uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1 + - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 with: terraform_version: ${{ matrix.terraform }} terraform_wrapper: false @@ -79,7 +79,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: [ '1.22', '1.21' ] + go-version: [ '1.23', '1.22' ] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -88,7 +88,7 @@ jobs: - run: go mod download - run: go test -coverprofile=coverage.out ./... - run: go tool cover -html=coverage.out -o coverage.html - - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: go-${{ matrix.go-version }}-coverage path: coverage.html diff --git a/.golangci.yml b/.golangci.yml index a62a62740..429044d2c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -22,7 +22,7 @@ linters: - unconvert - unparam - unused - - vet + - govet run: # Prevent false positive timeouts in CI diff --git a/CHANGELOG.md b/CHANGELOG.md index 1920a5e6b..6816c4e29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 1.12.0 (September 18, 2024) + +NOTES: + +* all: This Go module has been updated to Go 1.22 per the [Go support policy](https://go.dev/doc/devel/release#policy). It is recommended to review the [Go 1.22 release notes](https://go.dev/doc/go1.22) before upgrading. Any consumers building on earlier Go versions may experience errors ([#1033](https://github.com/hashicorp/terraform-plugin-framework/issues/1033)) + +BUG FIXES: + +* providerserver: Fixed bug that prevented `moved` operation support between resource types for framework-only providers. ([#1039](https://github.com/hashicorp/terraform-plugin-framework/issues/1039)) + ## 1.11.0 (August 06, 2024) NOTES: diff --git a/README.md b/README.md index 6e2ba9d97..294ba5ead 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Providers built with this framework are compatible with Terraform version v0.12 This project follows the [support policy](https://golang.org/doc/devel/release.html#policy) of Go as its support policy. The two latest major releases of Go are supported by the project. -Currently, that means Go **1.21** or later must be used when including this project as a dependency. +Currently, that means Go **1.22** or later must be used when including this project as a dependency. ## Contributing 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/go.mod b/go.mod index bbe8dfada..8571a3290 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,12 @@ module github.com/hashicorp/terraform-plugin-framework -go 1.21 +go 1.22.0 -toolchain go1.21.6 +toolchain go1.22.7 require ( github.com/google/go-cmp v0.6.0 - github.com/hashicorp/terraform-plugin-go v0.23.0 + github.com/hashicorp/terraform-plugin-go v0.24.0 github.com/hashicorp/terraform-plugin-log v0.9.0 ) @@ -14,7 +14,7 @@ require ( github.com/fatih/color v1.13.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect - github.com/hashicorp/go-plugin v1.6.0 // indirect + github.com/hashicorp/go-plugin v1.6.1 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/terraform-registry-address v0.2.3 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect @@ -25,10 +25,10 @@ require ( github.com/oklog/run v1.0.0 // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/grpc v1.63.2 // indirect - google.golang.org/protobuf v1.34.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect + google.golang.org/grpc v1.66.2 // indirect + google.golang.org/protobuf v1.34.2 // indirect ) diff --git a/go.sum b/go.sum index 352a8f86a..3fe9c7360 100644 --- a/go.sum +++ b/go.sum @@ -11,12 +11,12 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= -github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= -github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= +github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI= +github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co= -github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ= +github.com/hashicorp/terraform-plugin-go v0.24.0 h1:2WpHhginCdVhFIrWHxDEg6RBn3YaWzR2o6qUeIEat2U= +github.com/hashicorp/terraform-plugin-go v0.24.0/go.mod h1:tUQ53lAsOyYSckFGEefGC5C8BAaO0ENqzFd3bQeuYQg= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= @@ -46,23 +46,23 @@ github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IU 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= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= 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-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.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= -google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= -google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= -google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= -google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= +google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/privatestate/data.go b/internal/privatestate/data.go index 3e858026a..5493a9d97 100644 --- a/internal/privatestate/data.go +++ b/internal/privatestate/data.go @@ -72,9 +72,9 @@ func (d *Data) Bytes(ctx context.Context) ([]byte, diag.Diagnostics) { if !json.Valid(v) { diags.AddError( "Error Encoding Private State", - fmt.Sprintf("An error was encountered when validating private state value."+ + "An error was encountered when validating private state value."+ fmt.Sprintf("The value associated with key %q is is not valid JSON.\n\n", k)+ - "This is always a problem with Terraform or terraform-plugin-framework. Please report this to the provider developer."), + "This is always a problem with Terraform or terraform-plugin-framework. Please report this to the provider developer.", ) tflog.Error(ctx, "error encoding private state: invalid JSON value", map[string]interface{}{"key": k, "value": v}) diff --git a/internal/proto5server/server_getmetadata_test.go b/internal/proto5server/server_getmetadata_test.go index decc62739..fffb8146f 100644 --- a/internal/proto5server/server_getmetadata_test.go +++ b/internal/proto5server/server_getmetadata_test.go @@ -65,6 +65,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -110,6 +111,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -147,6 +149,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -190,6 +193,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -235,6 +239,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -272,6 +277,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -315,6 +321,7 @@ func TestServerGetMetadata(t *testing.T) { }, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -360,6 +367,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -397,6 +405,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, diff --git a/internal/proto5server/server_getproviderschema_test.go b/internal/proto5server/server_getproviderschema_test.go index 29b33024a..59c34a40d 100644 --- a/internal/proto5server/server_getproviderschema_test.go +++ b/internal/proto5server/server_getproviderschema_test.go @@ -110,6 +110,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -176,6 +177,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -216,6 +218,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -278,6 +281,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -336,6 +340,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -376,6 +381,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -414,6 +420,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -456,6 +463,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -536,6 +544,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -602,6 +611,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -642,6 +652,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, diff --git a/internal/proto6server/server_getmetadata_test.go b/internal/proto6server/server_getmetadata_test.go index 35dc1a4c7..1029dd232 100644 --- a/internal/proto6server/server_getmetadata_test.go +++ b/internal/proto6server/server_getmetadata_test.go @@ -65,6 +65,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -110,6 +111,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -147,6 +149,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -190,6 +193,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -235,6 +239,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -272,6 +277,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -315,6 +321,7 @@ func TestServerGetMetadata(t *testing.T) { }, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -360,6 +367,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -397,6 +405,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, diff --git a/internal/proto6server/server_getproviderschema_test.go b/internal/proto6server/server_getproviderschema_test.go index fc5958f25..2a0fd9753 100644 --- a/internal/proto6server/server_getproviderschema_test.go +++ b/internal/proto6server/server_getproviderschema_test.go @@ -110,6 +110,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -176,6 +177,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -216,6 +218,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -278,6 +281,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -336,6 +340,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -376,6 +381,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -414,6 +420,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -456,6 +463,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -536,6 +544,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -602,6 +611,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -642,6 +652,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, diff --git a/internal/toproto5/server_capabilities.go b/internal/toproto5/server_capabilities.go index fd968906d..2ed77acbe 100644 --- a/internal/toproto5/server_capabilities.go +++ b/internal/toproto5/server_capabilities.go @@ -19,6 +19,7 @@ func ServerCapabilities(ctx context.Context, fw *fwserver.ServerCapabilities) *t return &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: fw.GetProviderSchemaOptional, + MoveResourceState: fw.MoveResourceState, PlanDestroy: fw.PlanDestroy, } } diff --git a/internal/toproto5/server_capabilities_test.go b/internal/toproto5/server_capabilities_test.go index 772909e56..95eac4af6 100644 --- a/internal/toproto5/server_capabilities_test.go +++ b/internal/toproto5/server_capabilities_test.go @@ -32,6 +32,14 @@ func TestServerCapabilities(t *testing.T) { GetProviderSchemaOptional: true, }, }, + "MoveResourceState": { + fw: &fwserver.ServerCapabilities{ + MoveResourceState: true, + }, + expected: &tfprotov5.ServerCapabilities{ + MoveResourceState: true, + }, + }, "PlanDestroy": { fw: &fwserver.ServerCapabilities{ PlanDestroy: true, diff --git a/internal/toproto6/server_capabilities.go b/internal/toproto6/server_capabilities.go index ef46cbf16..26c24f7c6 100644 --- a/internal/toproto6/server_capabilities.go +++ b/internal/toproto6/server_capabilities.go @@ -19,6 +19,7 @@ func ServerCapabilities(ctx context.Context, fw *fwserver.ServerCapabilities) *t return &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: fw.GetProviderSchemaOptional, + MoveResourceState: fw.MoveResourceState, PlanDestroy: fw.PlanDestroy, } } diff --git a/internal/toproto6/server_capabilities_test.go b/internal/toproto6/server_capabilities_test.go index f3a91ac03..a9e6955fe 100644 --- a/internal/toproto6/server_capabilities_test.go +++ b/internal/toproto6/server_capabilities_test.go @@ -32,6 +32,14 @@ func TestServerCapabilities(t *testing.T) { GetProviderSchemaOptional: true, }, }, + "MoveResourceState": { + fw: &fwserver.ServerCapabilities{ + MoveResourceState: true, + }, + expected: &tfprotov6.ServerCapabilities{ + MoveResourceState: true, + }, + }, "PlanDestroy": { fw: &fwserver.ServerCapabilities{ PlanDestroy: true, 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 { diff --git a/tools/go.mod b/tools/go.mod index c0b60b613..a7e6c1e36 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -1,6 +1,6 @@ module tools -go 1.21 +go 1.22.7 require github.com/hashicorp/copywrite v0.19.0 diff --git a/website/docs/plugin/framework/migrating/index.mdx b/website/docs/plugin/framework/migrating/index.mdx index 880f6c6bc..410db0ac9 100644 --- a/website/docs/plugin/framework/migrating/index.mdx +++ b/website/docs/plugin/framework/migrating/index.mdx @@ -16,7 +16,7 @@ In addition to this migration guide, we recommend referring to the main [Framewo Before you migrate your provider to the Framework, ensure it meets the following requirements: -- Go 1.21+ +- Go 1.22+ - Built on the latest version of SDKv2 - The provider is for use with Terraform >= 0.12.0