Skip to content

Commit

Permalink
Merge pull request #33378 from hashicorp/jbardin/objchange-refinements
Browse files Browse the repository at this point in the history
validate planned set sizes using refinements
  • Loading branch information
jbardin committed Jun 15, 2023
2 parents 0be4a38 + f6c536e commit 1e6b2d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions internal/plans/objchange/plan_valid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/plans/objchange/plan_valid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1e6b2d0

Please sign in to comment.