validate planned set sizes using refinements

This commit is contained in:
James Bardin 2023-06-15 10:09:55 -04:00
parent 3c8a163583
commit f6c536e436
2 changed files with 4 additions and 8 deletions

View File

@ -447,14 +447,10 @@ func assertPlannedObjectValid(schema *configschema.Object, prior, config, planne
}
case configschema.NestingSet:
if !planned.IsKnown() || !config.IsKnown() {
// if either is unknown we cannot check the lengths
return errs
}
plannedL := planned.Length()
configL := config.Length()
plannedL := planned.LengthInt()
configL := config.LengthInt()
if plannedL != configL {
if ok := plannedL.Range().Includes(configL); ok.IsKnown() && ok.False() {
errs = append(errs, path.NewErrorf("count in plan (%#v) disagrees with count in config (%#v)", plannedL, configL))
return errs
}

View File

@ -1700,7 +1700,7 @@ func TestAssertPlanValid(t *testing.T) {
&configschema.Block{
Attributes: map[string]*configschema.Attribute{
"set": {
//Computed: true,
Computed: true,
Optional: true,
NestedType: &configschema.Object{
Nesting: configschema.NestingSet,