diff --git a/internal/command/jsonprovider/attribute.go b/internal/command/jsonprovider/attribute.go index 803e4e5f0..9425cd9e5 100644 --- a/internal/command/jsonprovider/attribute.go +++ b/internal/command/jsonprovider/attribute.go @@ -22,8 +22,6 @@ type attribute struct { type nestedType struct { Attributes map[string]*attribute `json:"attributes,omitempty"` NestingMode string `json:"nesting_mode,omitempty"` - MinItems uint64 `json:"min_items,omitempty"` - MaxItems uint64 `json:"max_items,omitempty"` } func marshalStringKind(sk configschema.StringKind) string { @@ -55,8 +53,6 @@ func marshalAttribute(attr *configschema.Attribute) *attribute { if attr.NestedType != nil { nestedTy := nestedType{ - MinItems: uint64(attr.NestedType.MinItems), - MaxItems: uint64(attr.NestedType.MaxItems), NestingMode: nestingModeString(attr.NestedType.Nesting), } attrs := make(map[string]*attribute, len(attr.NestedType.Attributes)) diff --git a/internal/configs/configschema/decoder_spec.go b/internal/configs/configschema/decoder_spec.go index d127ccd6f..d2d6616dd 100644 --- a/internal/configs/configschema/decoder_spec.go +++ b/internal/configs/configschema/decoder_spec.go @@ -187,17 +187,13 @@ func (a *Attribute) decoderSpec(name string) hcldec.Spec { } if a.NestedType != nil { - // FIXME: a panic() is a bad UX. InternalValidate() can check Attribute - // schemas as well so a fix might be to call it when we get the schema - // from the provider in Context(). Since this could be a breaking - // change, we'd need to communicate well before adding that call. if a.Type != cty.NilType { panic("Invalid attribute schema: NestedType and Type cannot both be set. This is a bug in the provider.") } ty := a.NestedType.specType() ret.Type = ty - ret.Required = a.Required || a.NestedType.MinItems > 0 + ret.Required = a.Required return ret } diff --git a/internal/configs/configschema/internal_validate.go b/internal/configs/configschema/internal_validate.go index 2afa724e1..8876672d7 100644 --- a/internal/configs/configschema/internal_validate.go +++ b/internal/configs/configschema/internal_validate.go @@ -131,17 +131,9 @@ func (a *Attribute) internalValidate(name, prefix string) error { if a.NestedType != nil { switch a.NestedType.Nesting { - case NestingSingle: - switch { - case a.NestedType.MinItems != a.NestedType.MaxItems: - err = multierror.Append(err, fmt.Errorf("%s%s: MinItems and MaxItems must match in NestingSingle mode", prefix, name)) - case a.NestedType.MinItems < 0 || a.NestedType.MinItems > 1: - err = multierror.Append(err, fmt.Errorf("%s%s: MinItems and MaxItems must be set to either 0 or 1 in NestingSingle mode", prefix, name)) - } + case NestingSingle, NestingMap: + // no validations to perform case NestingList, NestingSet: - if a.NestedType.MinItems > a.NestedType.MaxItems && a.NestedType.MaxItems != 0 { - err = multierror.Append(err, fmt.Errorf("%s%s: MinItems must be less than or equal to MaxItems in %s mode", prefix, name, a.NestedType.Nesting)) - } if a.NestedType.Nesting == NestingSet { ety := a.NestedType.ImpliedType() if ety.HasDynamicTypes() { @@ -151,10 +143,6 @@ func (a *Attribute) internalValidate(name, prefix string) error { err = multierror.Append(err, fmt.Errorf("%s%s: NestingSet blocks may not contain attributes of cty.DynamicPseudoType", prefix, name)) } } - case NestingMap: - if a.NestedType.MinItems != 0 || a.NestedType.MaxItems != 0 { - err = multierror.Append(err, fmt.Errorf("%s%s: MinItems and MaxItems must both be 0 in NestingMap mode", prefix, name)) - } default: err = multierror.Append(err, fmt.Errorf("%s%s: invalid nesting mode %s", prefix, name, a.NestedType.Nesting)) } diff --git a/internal/configs/configschema/internal_validate_test.go b/internal/configs/configschema/internal_validate_test.go index dc70a5fa8..3be461d44 100644 --- a/internal/configs/configschema/internal_validate_test.go +++ b/internal/configs/configschema/internal_validate_test.go @@ -143,21 +143,6 @@ func TestBlockInternalValidate(t *testing.T) { []string{"fooBar: name may contain only lowercase letters, digits and underscores"}, }, */ - "attribute with invalid NestedType nesting": { - &Block{ - Attributes: map[string]*Attribute{ - "foo": { - NestedType: &Object{ - Nesting: NestingSingle, - MinItems: 10, - MaxItems: 10, - }, - Optional: true, - }, - }, - }, - []string{"foo: MinItems and MaxItems must be set to either 0 or 1 in NestingSingle mode"}, - }, "attribute with invalid NestedType attribute": { &Block{ Attributes: map[string]*Attribute{ diff --git a/internal/configs/configschema/schema.go b/internal/configs/configschema/schema.go index 581bead8b..9ecc71e54 100644 --- a/internal/configs/configschema/schema.go +++ b/internal/configs/configschema/schema.go @@ -87,13 +87,6 @@ type Object struct { // many instances of the Object are allowed, how many labels it expects, and // how the resulting data will be converted into a data structure. Nesting NestingMode - - // MinItems and MaxItems set, for the NestingList and NestingSet nesting - // modes, lower and upper limits on the number of child blocks allowed - // of the given type. If both are left at zero, no limit is applied. - // These fields are ignored for other nesting modes and must both be left - // at zero. - MinItems, MaxItems int } // NestedBlock represents the embedding of one block within another. diff --git a/internal/plugin6/convert/schema.go b/internal/plugin6/convert/schema.go index fa405acf1..0bdf4e284 100644 --- a/internal/plugin6/convert/schema.go +++ b/internal/plugin6/convert/schema.go @@ -199,8 +199,6 @@ func protoObjectToConfigSchema(b *proto.Schema_Object) *configschema.Object { object := &configschema.Object{ Attributes: make(map[string]*configschema.Attribute), Nesting: nesting, - MinItems: int(b.MinItems), - MaxItems: int(b.MaxItems), } for _, a := range b.Attributes { @@ -295,7 +293,5 @@ func configschemaObjectToProto(b *configschema.Object) *proto.Schema_Object { return &proto.Schema_Object{ Attributes: attributes, Nesting: nesting, - MinItems: int64(b.MinItems), - MaxItems: int64(b.MaxItems), } } diff --git a/internal/plugin6/convert/schema_test.go b/internal/plugin6/convert/schema_test.go index a94e812f1..9befe4c5a 100644 --- a/internal/plugin6/convert/schema_test.go +++ b/internal/plugin6/convert/schema_test.go @@ -126,7 +126,6 @@ func TestConvertSchemaBlocks(t *testing.T) { Computed: true, }, }, - MinItems: 3, }, Required: true, }, @@ -246,7 +245,6 @@ func TestConvertSchemaBlocks(t *testing.T) { Computed: true, }, }, - MinItems: 3, }, Required: true, },