From 7e408a5cd663b9bad0c739085324acde02200fdf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Jan 2022 14:31:02 -0500 Subject: [PATCH] Bump github.com/hashicorp/terraform-plugin-go from 0.6.0 to 0.7.0 (#249) * Bump github.com/hashicorp/terraform-plugin-go from 0.6.0 to 0.7.0 Bumps [github.com/hashicorp/terraform-plugin-go](https://github.com/hashicorp/terraform-plugin-go) from 0.6.0 to 0.7.0. - [Release notes](https://github.com/hashicorp/terraform-plugin-go/releases) - [Changelog](https://github.com/hashicorp/terraform-plugin-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/terraform-plugin-go/compare/v0.6.0...v0.7.0) --- updated-dependencies: - dependency-name: github.com/hashicorp/terraform-plugin-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * tfsdk: Remove `ListNestedAttributesOptions`, `MapNestedAttributeOptions`, and `SetNestedAttributeOptions` type `MaxItems` and `MinItems` fields Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Brian Flad --- .changelog/249.txt | 3 + go.mod | 2 +- go.sum | 4 +- tfsdk/attribute.go | 5 +- tfsdk/attribute_test.go | 250 ------------------------------------- tfsdk/nested_attributes.go | 79 +----------- 6 files changed, 10 insertions(+), 333 deletions(-) create mode 100644 .changelog/249.txt diff --git a/.changelog/249.txt b/.changelog/249.txt new file mode 100644 index 000000000..985d4a701 --- /dev/null +++ b/.changelog/249.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +tfsdk: The `ListNestedAttributesOptions`, `MapNestedAttributeOptions`, and `SetNestedAttributeOptions` type `MaxItems` and `MinItems` fields have been removed since the protocol and framework never supported this type of nested attribute validation. Use attribute validators instead. +``` diff --git a/go.mod b/go.mod index 4ecf9c4aa..1d86bcbf2 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( github.com/google/go-cmp v0.5.6 - github.com/hashicorp/terraform-plugin-go v0.6.0 + github.com/hashicorp/terraform-plugin-go v0.7.0 github.com/hashicorp/terraform-plugin-log v0.2.1 ) diff --git a/go.sum b/go.sum index 74f43c6ba..11c2de4ca 100644 --- a/go.sum +++ b/go.sum @@ -61,8 +61,8 @@ github.com/hashicorp/go-plugin v1.4.3/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ3 github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/terraform-plugin-go v0.6.0 h1:EmeULv7+/eMsQpb1iJpuVCcbxNmY5C0lo5cEX712Zhc= -github.com/hashicorp/terraform-plugin-go v0.6.0/go.mod h1:p+L2cRtja1Rr5A/S9flPLAzHyt2544MhIpAfwqnK7U0= +github.com/hashicorp/terraform-plugin-go v0.7.0 h1:djd0aLO1uRr/VHaR12wryEFAPEFoHNIvRfCGkOrQqQI= +github.com/hashicorp/terraform-plugin-go v0.7.0/go.mod h1:p+L2cRtja1Rr5A/S9flPLAzHyt2544MhIpAfwqnK7U0= github.com/hashicorp/terraform-plugin-log v0.2.1 h1:hl0G6ctSx7DRTE62VNsPWrq7d+JWy1kjk9ApOFrCq3I= github.com/hashicorp/terraform-plugin-log v0.2.1/go.mod h1:RW/n0x4dyITmenuirZ1ViPQGP5JQdPTZ4Wwc0rLKi94= github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 h1:1FGtlkJw87UsTMg5s8jrekrHmUPUJaMcu6ELiVhQrNw= diff --git a/tfsdk/attribute.go b/tfsdk/attribute.go index 90e0b943a..637560d0b 100644 --- a/tfsdk/attribute.go +++ b/tfsdk/attribute.go @@ -211,10 +211,7 @@ func (a Attribute) tfprotov6SchemaAttribute(ctx context.Context, name string, pa return schemaAttribute, nil } - object := &tfprotov6.SchemaObject{ - MinItems: a.Attributes.GetMinItems(), - MaxItems: a.Attributes.GetMaxItems(), - } + object := &tfprotov6.SchemaObject{} nm := a.Attributes.GetNestingMode() switch nm { case NestingModeSingle: diff --git a/tfsdk/attribute_test.go b/tfsdk/attribute_test.go index af43c2329..4fc8f11a8 100644 --- a/tfsdk/attribute_test.go +++ b/tfsdk/attribute_test.go @@ -334,131 +334,6 @@ func TestAttributeTfprotov6SchemaAttribute(t *testing.T) { }, }, }, - "nested-attr-list-min": { - name: "list_nested", - attr: Attribute{ - Attributes: ListNestedAttributes(map[string]Attribute{ - "string": { - Type: types.StringType, - Optional: true, - }, - "computed": { - Type: types.NumberType, - Computed: true, - Sensitive: true, - }, - }, ListNestedAttributesOptions{ - MinItems: 1, - }), - Optional: true, - }, - path: tftypes.NewAttributePath(), - expected: &tfprotov6.SchemaAttribute{ - Name: "list_nested", - Optional: true, - NestedType: &tfprotov6.SchemaObject{ - Nesting: tfprotov6.SchemaObjectNestingModeList, - Attributes: []*tfprotov6.SchemaAttribute{ - { - Name: "computed", - Computed: true, - Sensitive: true, - Type: tftypes.Number, - }, - { - Name: "string", - Optional: true, - Type: tftypes.String, - }, - }, - MinItems: 1, - }, - }, - }, - "nested-attr-list-max": { - name: "list_nested", - attr: Attribute{ - Attributes: ListNestedAttributes(map[string]Attribute{ - "string": { - Type: types.StringType, - Optional: true, - }, - "computed": { - Type: types.NumberType, - Computed: true, - Sensitive: true, - }, - }, ListNestedAttributesOptions{ - MaxItems: 1, - }), - Optional: true, - }, - path: tftypes.NewAttributePath(), - expected: &tfprotov6.SchemaAttribute{ - Name: "list_nested", - Optional: true, - NestedType: &tfprotov6.SchemaObject{ - Nesting: tfprotov6.SchemaObjectNestingModeList, - Attributes: []*tfprotov6.SchemaAttribute{ - { - Name: "computed", - Computed: true, - Sensitive: true, - Type: tftypes.Number, - }, - { - Name: "string", - Optional: true, - Type: tftypes.String, - }, - }, - MaxItems: 1, - }, - }, - }, - "nested-attr-list-minmax": { - name: "list_nested", - attr: Attribute{ - Attributes: ListNestedAttributes(map[string]Attribute{ - "string": { - Type: types.StringType, - Optional: true, - }, - "computed": { - Type: types.NumberType, - Computed: true, - Sensitive: true, - }, - }, ListNestedAttributesOptions{ - MinItems: 1, - MaxItems: 10, - }), - Optional: true, - }, - path: tftypes.NewAttributePath(), - expected: &tfprotov6.SchemaAttribute{ - Name: "list_nested", - Optional: true, - NestedType: &tfprotov6.SchemaObject{ - Nesting: tfprotov6.SchemaObjectNestingModeList, - Attributes: []*tfprotov6.SchemaAttribute{ - { - Name: "computed", - Computed: true, - Sensitive: true, - Type: tftypes.Number, - }, - { - Name: "string", - Optional: true, - Type: tftypes.String, - }, - }, - MinItems: 1, - MaxItems: 10, - }, - }, - }, "nested-attr-set": { name: "set_nested", attr: Attribute{ @@ -497,131 +372,6 @@ func TestAttributeTfprotov6SchemaAttribute(t *testing.T) { }, }, }, - "nested-attr-set-min": { - name: "set_nested", - attr: Attribute{ - Attributes: SetNestedAttributes(map[string]Attribute{ - "string": { - Type: types.StringType, - Optional: true, - }, - "computed": { - Type: types.NumberType, - Computed: true, - Sensitive: true, - }, - }, SetNestedAttributesOptions{ - MinItems: 1, - }), - Optional: true, - }, - path: tftypes.NewAttributePath(), - expected: &tfprotov6.SchemaAttribute{ - Name: "set_nested", - Optional: true, - NestedType: &tfprotov6.SchemaObject{ - Nesting: tfprotov6.SchemaObjectNestingModeSet, - Attributes: []*tfprotov6.SchemaAttribute{ - { - Name: "computed", - Computed: true, - Sensitive: true, - Type: tftypes.Number, - }, - { - Name: "string", - Optional: true, - Type: tftypes.String, - }, - }, - MinItems: 1, - }, - }, - }, - "nested-attr-set-max": { - name: "set_nested", - attr: Attribute{ - Attributes: SetNestedAttributes(map[string]Attribute{ - "string": { - Type: types.StringType, - Optional: true, - }, - "computed": { - Type: types.NumberType, - Computed: true, - Sensitive: true, - }, - }, SetNestedAttributesOptions{ - MaxItems: 1, - }), - Optional: true, - }, - path: tftypes.NewAttributePath(), - expected: &tfprotov6.SchemaAttribute{ - Name: "set_nested", - Optional: true, - NestedType: &tfprotov6.SchemaObject{ - Nesting: tfprotov6.SchemaObjectNestingModeSet, - Attributes: []*tfprotov6.SchemaAttribute{ - { - Name: "computed", - Computed: true, - Sensitive: true, - Type: tftypes.Number, - }, - { - Name: "string", - Optional: true, - Type: tftypes.String, - }, - }, - MaxItems: 1, - }, - }, - }, - "nested-attr-set-minmax": { - name: "set_nested", - attr: Attribute{ - Attributes: SetNestedAttributes(map[string]Attribute{ - "string": { - Type: types.StringType, - Optional: true, - }, - "computed": { - Type: types.NumberType, - Computed: true, - Sensitive: true, - }, - }, SetNestedAttributesOptions{ - MinItems: 1, - MaxItems: 10, - }), - Optional: true, - }, - path: tftypes.NewAttributePath(), - expected: &tfprotov6.SchemaAttribute{ - Name: "set_nested", - Optional: true, - NestedType: &tfprotov6.SchemaObject{ - Nesting: tfprotov6.SchemaObjectNestingModeSet, - Attributes: []*tfprotov6.SchemaAttribute{ - { - Name: "computed", - Computed: true, - Sensitive: true, - Type: tftypes.Number, - }, - { - Name: "string", - Optional: true, - Type: tftypes.String, - }, - }, - MinItems: 1, - MaxItems: 10, - }, - }, - }, "attr-and-nested-attr-set": { name: "whoops", attr: Attribute{ diff --git a/tfsdk/nested_attributes.go b/tfsdk/nested_attributes.go index 77edd13a9..a09662971 100644 --- a/tfsdk/nested_attributes.go +++ b/tfsdk/nested_attributes.go @@ -66,8 +66,6 @@ type NestedAttributes interface { AttributeType() attr.Type GetNestingMode() NestingMode GetAttributes() map[string]Attribute - GetMinItems() int64 - GetMaxItems() int64 Equal(NestedAttributes) bool unimplementable() } @@ -125,14 +123,6 @@ func (s singleNestedAttributes) GetNestingMode() NestingMode { return NestingModeSingle } -func (s singleNestedAttributes) GetMinItems() int64 { - return 0 -} - -func (s singleNestedAttributes) GetMaxItems() int64 { - return 0 -} - func (s singleNestedAttributes) Equal(o NestedAttributes) bool { other, ok := o.(singleNestedAttributes) if !ok { @@ -160,36 +150,21 @@ func (s singleNestedAttributes) Equal(o NestedAttributes) bool { func ListNestedAttributes(attributes map[string]Attribute, opts ListNestedAttributesOptions) NestedAttributes { return listNestedAttributes{ nestedAttributes: nestedAttributes(attributes), - min: opts.MinItems, - max: opts.MaxItems, } } type listNestedAttributes struct { nestedAttributes - - min, max int } // ListNestedAttributesOptions captures additional, optional parameters for // ListNestedAttributes. -type ListNestedAttributesOptions struct { - MinItems int - MaxItems int -} +type ListNestedAttributesOptions struct{} func (l listNestedAttributes) GetNestingMode() NestingMode { return NestingModeList } -func (l listNestedAttributes) GetMinItems() int64 { - return int64(l.min) -} - -func (l listNestedAttributes) GetMaxItems() int64 { - return int64(l.max) -} - // AttributeType returns an attr.Type corresponding to the nested attributes. func (l listNestedAttributes) AttributeType() attr.Type { return types.ListType{ @@ -210,12 +185,6 @@ func (l listNestedAttributes) Equal(o NestedAttributes) bool { if !ok { return false } - if l.min != other.min { - return false - } - if l.max != other.max { - return false - } if len(other.nestedAttributes) != len(l.nestedAttributes) { return false } @@ -239,36 +208,21 @@ func (l listNestedAttributes) Equal(o NestedAttributes) bool { func SetNestedAttributes(attributes map[string]Attribute, opts SetNestedAttributesOptions) NestedAttributes { return setNestedAttributes{ nestedAttributes: nestedAttributes(attributes), - min: opts.MinItems, - max: opts.MaxItems, } } type setNestedAttributes struct { nestedAttributes - - min, max int } // SetNestedAttributesOptions captures additional, optional parameters for // SetNestedAttributes. -type SetNestedAttributesOptions struct { - MinItems int - MaxItems int -} +type SetNestedAttributesOptions struct{} func (s setNestedAttributes) GetNestingMode() NestingMode { return NestingModeSet } -func (s setNestedAttributes) GetMinItems() int64 { - return int64(s.min) -} - -func (s setNestedAttributes) GetMaxItems() int64 { - return int64(s.max) -} - // AttributeType returns an attr.Type corresponding to the nested attributes. func (s setNestedAttributes) AttributeType() attr.Type { return types.SetType{ @@ -289,12 +243,6 @@ func (s setNestedAttributes) Equal(o NestedAttributes) bool { if !ok { return false } - if s.min != other.min { - return false - } - if s.max != other.max { - return false - } if len(other.nestedAttributes) != len(s.nestedAttributes) { return false } @@ -318,36 +266,21 @@ func (s setNestedAttributes) Equal(o NestedAttributes) bool { func MapNestedAttributes(attributes map[string]Attribute, opts MapNestedAttributesOptions) NestedAttributes { return mapNestedAttributes{ nestedAttributes: nestedAttributes(attributes), - min: opts.MinItems, - max: opts.MaxItems, } } type mapNestedAttributes struct { nestedAttributes - - min, max int } // MapNestedAttributesOptions captures additional, optional parameters for // MapNestedAttributes. -type MapNestedAttributesOptions struct { - MinItems int - MaxItems int -} +type MapNestedAttributesOptions struct{} func (m mapNestedAttributes) GetNestingMode() NestingMode { return NestingModeMap } -func (m mapNestedAttributes) GetMinItems() int64 { - return int64(m.min) -} - -func (m mapNestedAttributes) GetMaxItems() int64 { - return int64(m.max) -} - // AttributeType returns an attr.Type corresponding to the nested attributes. func (m mapNestedAttributes) AttributeType() attr.Type { return types.MapType{ @@ -368,12 +301,6 @@ func (m mapNestedAttributes) Equal(o NestedAttributes) bool { if !ok { return false } - if m.min != other.min { - return false - } - if m.max != other.max { - return false - } if len(other.nestedAttributes) != len(m.nestedAttributes) { return false }