Skip to content

Commit

Permalink
check size of local list and remote before going through the list elems
Browse files Browse the repository at this point in the history
  • Loading branch information
dikhan committed Oct 5, 2019
1 parent c9efbae commit 378839a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions openapi/resource_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,12 @@ func (r resourceFactory) validateImmutableProperty(property *specSchemaDefinitio
if property.Immutable || isImmutableObjectProperty { // isImmutableObjectProperty covers the recursive call from objects that are immutable which also make all its properties immutable
switch property.Type {
case typeList:
localList := localData.([]interface{})
remoteList := remoteData.([]interface{})
if len(localList) != len(remoteList) {
return fmt.Errorf("immutable list property '%s' size updated: [input: %d; remote: %d]", property.Name, len(localList), len(remoteList))
}
if isListOfPrimitives, _ := property.isTerraformListOfSimpleValues(); isListOfPrimitives {
localList := localData.([]interface{})
remoteList := remoteData.([]interface{})
for idx, elem := range localList {
if elem != remoteList[idx] {
return fmt.Errorf("immutable list property '%s' elements updated: [input: %+v; remote: %+v]", property.Name, localList, remoteList)
Expand Down

0 comments on commit 378839a

Please sign in to comment.