Skip to content

Commit

Permalink
docs: Miscellaneous doc fixes in attribute + unit tests (#1027)
Browse files Browse the repository at this point in the history
* 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 <github@simplebox.anonaddy.com>

* 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] <support@github.com>
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] <support@github.com>
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 <github@simplebox.anonaddy.com>
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>
  • Loading branch information
6 people authored Sep 17, 2024
1 parent 91cc780 commit 7076cca
Show file tree
Hide file tree
Showing 78 changed files with 425 additions and 382 deletions.
3 changes: 3 additions & 0 deletions datasource/schema/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions datasource/schema/float64_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 7 additions & 6 deletions datasource/schema/int32_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 7 additions & 6 deletions datasource/schema/int64_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/list_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/list_nested_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/list_nested_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions datasource/schema/map_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 = {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/map_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions datasource/schema/map_nested_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = {
Expand Down Expand Up @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/map_nested_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 7 additions & 6 deletions datasource/schema/nested_attribute_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 7 additions & 6 deletions datasource/schema/nested_block_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/object_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/set_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion datasource/schema/set_nested_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/set_nested_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/set_nested_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion datasource/schema/single_nested_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading

0 comments on commit 7076cca

Please sign in to comment.