Skip to content

Commit 7076cca

Browse files
austinvallehashicorp-tsccr[bot]SBGoodsdependabot[bot]hc-github-team-tf-provider-devex
authored
docs: Miscellaneous doc fixes in attribute + unit tests (#1027)
* fix and uncomment custom type tests * fix comments on nested attributes * add new attribute types to package docs * fix map docs * fix linting errors * SEC-090: Automated trusted workflow pinning (2024-08-19) (#1028) * Result of tsccr-helper -log-level=info gha update -latest . * Resolve linter errors and warnings --------- Co-authored-by: hashicorp-tsccr[bot] <hashicorp-tsccr[bot]@users.noreply.github.com> Co-authored-by: Selena Goods <[email protected]> * build(deps): Bump hashicorp/setup-terraform from 3.1.1 to 3.1.2 (#1029) Bumps [hashicorp/setup-terraform](https://github.com/hashicorp/setup-terraform) from 3.1.1 to 3.1.2. - [Release notes](https://github.com/hashicorp/setup-terraform/releases) - [Changelog](https://github.com/hashicorp/setup-terraform/blob/main/CHANGELOG.md) - [Commits](hashicorp/setup-terraform@651471c...b9cd54a) --- updated-dependencies: - dependency-name: hashicorp/setup-terraform dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Result of tsccr-helper -log-level=info gha update -latest . (#1034) Co-authored-by: hashicorp-tsccr[bot] <hashicorp-tsccr[bot]@users.noreply.github.com> * all: Bump minimum Go module version to 1.22 (#1033) * all: Bump minimum Go module version to 1.22.7 * add changelog * back to 1.22.0 * [CI] Update lock workflow file * [CI] Update issue comment triage workflow file * [CI] terraform-devex-repos automation * [CI] terraform-devex-repos automation * [CI] terraform-devex-repos automation --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: hashicorp-tsccr[bot] <129506189+hashicorp-tsccr[bot]@users.noreply.github.com> Co-authored-by: hashicorp-tsccr[bot] <hashicorp-tsccr[bot]@users.noreply.github.com> Co-authored-by: Selena Goods <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Service Account - Terraform Provider DevEx <100357958+hc-github-team-tf-provider-devex@users.noreply.github.com>
1 parent 91cc780 commit 7076cca

File tree

78 files changed

+425
-382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+425
-382
lines changed

datasource/schema/attribute.go

+3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import (
1010
// Attribute define a value field inside the Schema. Implementations in this
1111
// package include:
1212
// - BoolAttribute
13+
// - DynamicAttribute
14+
// - Float32Attribute
1315
// - Float64Attribute
16+
// - Int32Attribute
1417
// - Int64Attribute
1518
// - ListAttribute
1619
// - MapAttribute

datasource/schema/float64_attribute_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
1414
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
1515
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema"
16+
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes"
1617
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1718
"github.com/hashicorp/terraform-plugin-framework/types"
1819
"github.com/hashicorp/terraform-plugin-go/tftypes"
@@ -264,12 +265,12 @@ func TestFloat64AttributeGetType(t *testing.T) {
264265
attribute: schema.Float64Attribute{},
265266
expected: types.Float64Type,
266267
},
267-
// "custom-type": {
268-
// attribute: schema.Float64Attribute{
269-
// CustomType: testtypes.Float64Type{},
270-
// },
271-
// expected: testtypes.Float64Type{},
272-
// },
268+
"custom-type": {
269+
attribute: schema.Float64Attribute{
270+
CustomType: testtypes.Float64Type{},
271+
},
272+
expected: testtypes.Float64Type{},
273+
},
273274
}
274275

275276
for name, testCase := range testCases {

datasource/schema/int32_attribute_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
1616
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
1717
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema"
18+
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes"
1819
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1920
"github.com/hashicorp/terraform-plugin-framework/types"
2021
)
@@ -231,12 +232,12 @@ func TestInt32AttributeGetType(t *testing.T) {
231232
attribute: schema.Int32Attribute{},
232233
expected: types.Int32Type,
233234
},
234-
// "custom-type": {
235-
// attribute: schema.Int32Attribute{
236-
// CustomType: testtypes.Int32Type{},
237-
// },
238-
// expected: testtypes.Int32Type{},
239-
// },
235+
"custom-type": {
236+
attribute: schema.Int32Attribute{
237+
CustomType: testtypes.Int32Type{},
238+
},
239+
expected: testtypes.Int32Type{},
240+
},
240241
}
241242

242243
for name, testCase := range testCases {

datasource/schema/int64_attribute_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
1414
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
1515
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema"
16+
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes"
1617
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1718
"github.com/hashicorp/terraform-plugin-framework/types"
1819
"github.com/hashicorp/terraform-plugin-go/tftypes"
@@ -230,12 +231,12 @@ func TestInt64AttributeGetType(t *testing.T) {
230231
attribute: schema.Int64Attribute{},
231232
expected: types.Int64Type,
232233
},
233-
// "custom-type": {
234-
// attribute: schema.Int64Attribute{
235-
// CustomType: testtypes.Int64Type{},
236-
// },
237-
// expected: testtypes.Int64Type{},
238-
// },
234+
"custom-type": {
235+
attribute: schema.Int64Attribute{
236+
CustomType: testtypes.Int64Type{},
237+
},
238+
expected: testtypes.Int64Type{},
239+
},
239240
}
240241

241242
for name, testCase := range testCases {

datasource/schema/list_attribute_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ func TestListAttributeGetType(t *testing.T) {
239239
attribute: schema.ListAttribute{ElementType: types.StringType},
240240
expected: types.ListType{ElemType: types.StringType},
241241
},
242-
// "custom-type": {
243-
// attribute: schema.ListAttribute{
244-
// CustomType: testtypes.ListType{},
245-
// },
246-
// expected: testtypes.ListType{},
247-
// },
242+
"custom-type": {
243+
attribute: schema.ListAttribute{
244+
CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}},
245+
},
246+
expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}},
247+
},
248248
}
249249

250250
for name, testCase := range testCases {

datasource/schema/list_nested_attribute_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,12 @@ func TestListNestedAttributeGetType(t *testing.T) {
386386
},
387387
},
388388
},
389-
// "custom-type": {
390-
// attribute: schema.ListNestedAttribute{
391-
// CustomType: testtypes.ListType{},
392-
// },
393-
// expected: testtypes.ListType{},
394-
// },
389+
"custom-type": {
390+
attribute: schema.ListNestedAttribute{
391+
CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}},
392+
},
393+
expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}},
394+
},
395395
}
396396

397397
for name, testCase := range testCases {

datasource/schema/list_nested_block_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,12 @@ func TestListNestedBlockType(t *testing.T) {
467467
},
468468
},
469469
},
470-
// "custom-type": {
471-
// block: schema.ListNestedBlock{
472-
// CustomType: testtypes.ListType{},
473-
// },
474-
// expected: testtypes.ListType{},
475-
// },
470+
"custom-type": {
471+
block: schema.ListNestedBlock{
472+
CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}},
473+
},
474+
expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}},
475+
},
476476
}
477477

478478
for name, testCase := range testCases {

datasource/schema/map_attribute.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var (
2323
_ fwxschema.AttributeWithMapValidators = MapAttribute{}
2424
)
2525

26-
// MapAttribute represents a schema attribute that is a list with a single
26+
// MapAttribute represents a schema attribute that is a map with a single
2727
// element type. When retrieving the value for this attribute, use types.Map
2828
// as the value type unless the CustomType field is set. The ElementType field
2929
// must be set.
@@ -32,7 +32,7 @@ var (
3232
// require definition beyond type information.
3333
//
3434
// Terraform configurations configure this attribute using expressions that
35-
// return a list or directly via curly brace syntax.
35+
// return a map or directly via curly brace syntax.
3636
//
3737
// # map of strings
3838
// example_attribute = {

datasource/schema/map_attribute_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ func TestMapAttributeGetType(t *testing.T) {
239239
attribute: schema.MapAttribute{ElementType: types.StringType},
240240
expected: types.MapType{ElemType: types.StringType},
241241
},
242-
// "custom-type": {
243-
// attribute: schema.MapAttribute{
244-
// CustomType: testtypes.MapType{},
245-
// },
246-
// expected: testtypes.MapType{},
247-
// },
242+
"custom-type": {
243+
attribute: schema.MapAttribute{
244+
CustomType: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}},
245+
},
246+
expected: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}},
247+
},
248248
}
249249

250250
for name, testCase := range testCases {

datasource/schema/map_nested_attribute.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var (
2525
_ fwxschema.AttributeWithMapValidators = MapNestedAttribute{}
2626
)
2727

28-
// MapNestedAttribute represents an attribute that is a set of objects where
28+
// MapNestedAttribute represents an attribute that is a map of objects where
2929
// the object attributes can be fully defined, including further nested
3030
// attributes. When retrieving the value for this attribute, use types.Map
3131
// as the value type unless the CustomType field is set. The NestedObject field
@@ -35,7 +35,7 @@ var (
3535
// not require definition beyond type information.
3636
//
3737
// Terraform configurations configure this attribute using expressions that
38-
// return a set of objects or directly via curly brace syntax.
38+
// return a map of objects or directly via curly brace syntax.
3939
//
4040
// # map of objects
4141
// example_attribute = {
@@ -195,7 +195,7 @@ func (a MapNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject {
195195
return a.NestedObject
196196
}
197197

198-
// GetNestingMode always returns NestingModeList.
198+
// GetNestingMode always returns NestingModeMap.
199199
func (a MapNestedAttribute) GetNestingMode() fwschema.NestingMode {
200200
return fwschema.NestingModeMap
201201
}

datasource/schema/map_nested_attribute_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,12 @@ func TestMapNestedAttributeGetType(t *testing.T) {
386386
},
387387
},
388388
},
389-
// "custom-type": {
390-
// attribute: schema.MapNestedAttribute{
391-
// CustomType: testtypes.MapType{},
392-
// },
393-
// expected: testtypes.MapType{},
394-
// },
389+
"custom-type": {
390+
attribute: schema.MapNestedAttribute{
391+
CustomType: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}},
392+
},
393+
expected: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}},
394+
},
395395
}
396396

397397
for name, testCase := range testCases {

datasource/schema/nested_attribute_object_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/hashicorp/terraform-plugin-framework/attr"
1313
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
1414
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
15+
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes"
1516
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1617
"github.com/hashicorp/terraform-plugin-framework/types"
1718
"github.com/hashicorp/terraform-plugin-go/tftypes"
@@ -255,12 +256,12 @@ func TestNestedAttributeObjectType(t *testing.T) {
255256
},
256257
},
257258
},
258-
// "custom-type": {
259-
// block: schema.NestedAttributeObject{
260-
// CustomType: testtypes.SingleType{},
261-
// },
262-
// expected: testtypes.SingleType{},
263-
// },
259+
"custom-type": {
260+
object: schema.NestedAttributeObject{
261+
CustomType: testtypes.ObjectType{},
262+
},
263+
expected: testtypes.ObjectType{},
264+
},
264265
}
265266

266267
for name, testCase := range testCases {

datasource/schema/nested_block_object_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/hashicorp/terraform-plugin-framework/attr"
1313
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
1414
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
15+
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes"
1516
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1617
"github.com/hashicorp/terraform-plugin-framework/types"
1718
"github.com/hashicorp/terraform-plugin-go/tftypes"
@@ -341,12 +342,12 @@ func TestNestedBlockObjectType(t *testing.T) {
341342
},
342343
},
343344
},
344-
// "custom-type": {
345-
// block: schema.NestedBlockObject{
346-
// CustomType: testtypes.SingleType{},
347-
// },
348-
// expected: testtypes.SingleType{},
349-
// },
345+
"custom-type": {
346+
object: schema.NestedBlockObject{
347+
CustomType: testtypes.ObjectType{},
348+
},
349+
expected: testtypes.ObjectType{},
350+
},
350351
}
351352

352353
for name, testCase := range testCases {

datasource/schema/object_attribute_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,12 @@ func TestObjectAttributeGetType(t *testing.T) {
245245
attribute: schema.ObjectAttribute{AttributeTypes: map[string]attr.Type{"testattr": types.StringType}},
246246
expected: types.ObjectType{AttrTypes: map[string]attr.Type{"testattr": types.StringType}},
247247
},
248-
// "custom-type": {
249-
// attribute: schema.ObjectAttribute{
250-
// CustomType: testtypes.ObjectType{},
251-
// },
252-
// expected: testtypes.ObjectType{},
253-
// },
248+
"custom-type": {
249+
attribute: schema.ObjectAttribute{
250+
CustomType: testtypes.ObjectType{},
251+
},
252+
expected: testtypes.ObjectType{},
253+
},
254254
}
255255

256256
for name, testCase := range testCases {

datasource/schema/set_attribute_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ func TestSetAttributeGetType(t *testing.T) {
239239
attribute: schema.SetAttribute{ElementType: types.StringType},
240240
expected: types.SetType{ElemType: types.StringType},
241241
},
242-
// "custom-type": {
243-
// attribute: schema.SetAttribute{
244-
// CustomType: testtypes.SetType{},
245-
// },
246-
// expected: testtypes.SetType{},
247-
// },
242+
"custom-type": {
243+
attribute: schema.SetAttribute{
244+
CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}},
245+
},
246+
expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}},
247+
},
248248
}
249249

250250
for name, testCase := range testCases {

datasource/schema/set_nested_attribute.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (a SetNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject {
190190
return a.NestedObject
191191
}
192192

193-
// GetNestingMode always returns NestingModeList.
193+
// GetNestingMode always returns NestingModeSet.
194194
func (a SetNestedAttribute) GetNestingMode() fwschema.NestingMode {
195195
return fwschema.NestingModeSet
196196
}

datasource/schema/set_nested_attribute_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,12 @@ func TestSetNestedAttributeGetType(t *testing.T) {
386386
},
387387
},
388388
},
389-
// "custom-type": {
390-
// attribute: schema.SetNestedAttribute{
391-
// CustomType: testtypes.SetType{},
392-
// },
393-
// expected: testtypes.SetType{},
394-
// },
389+
"custom-type": {
390+
attribute: schema.SetNestedAttribute{
391+
CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}},
392+
},
393+
expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}},
394+
},
395395
}
396396

397397
for name, testCase := range testCases {

datasource/schema/set_nested_block_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,12 @@ func TestSetNestedBlockType(t *testing.T) {
467467
},
468468
},
469469
},
470-
// "custom-type": {
471-
// block: schema.SetNestedBlock{
472-
// CustomType: testtypes.SetType{},
473-
// },
474-
// expected: testtypes.SetType{},
475-
// },
470+
"custom-type": {
471+
block: schema.SetNestedBlock{
472+
CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}},
473+
},
474+
expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}},
475+
},
476476
}
477477

478478
for name, testCase := range testCases {

datasource/schema/single_nested_attribute.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func (a SingleNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject
198198
}
199199
}
200200

201-
// GetNestingMode always returns NestingModeList.
201+
// GetNestingMode always returns NestingModeSingle.
202202
func (a SingleNestedAttribute) GetNestingMode() fwschema.NestingMode {
203203
return fwschema.NestingModeSingle
204204
}

0 commit comments

Comments
 (0)