As a OpenAPI Terraform Service Provider
I want the OpenAPI plugin to dismiss the ordering of elements in an array (considering the property in the swagger file is marked with some extension that enables this special behaviour)
So that terraform plans don't result into diffs even though the elems in the array are the same (just not in the same order)
Describe the solution you'd like
To be able to specify an extension (eg: x-terraform-ignore-order) on a resource property so that when the plugin is updating the state for the property it will inspect the items of the list received from remote and compare with the local values and if the lists are the same but unordered the state will keep the users input.
Acceptance criteria
Given the following terraform snippet where the members values are in certain desired order and assuming that the members property is of type 'list' AND has the x-terraform-ignore-order extension set to true in the OpenAPI document for the group_v1 resource definition:
resource "openapi_group_v1" "my_iam_group_v1" {
members = ["user1", "user2", "user3"]
}
The following behaviour is applied depending on the different scenarios when processing the response received by the API and saving the state of the property.
Use case 0: If the remote value for the property members contained the same items in the same order (eg: {"members":["user1", "user2", "user3"]}) as the tf input then the state saved for the property would match the input values. That is: members = ["user1", "user2", "user3"]
Use case 1: If the remote value for the property members contained the same items as the tf input BUT the order of the elements is different (eg: {"members":["user3", "user2", "user1"]}) then state saved for the property would match the input values. That is: members = ["user1", "user2", "user3"]
Use case 2: If the remote value for the property members contained the same items as the tf input in different order PLUS new ones (eg: {"members":["user2", "user1", "user3", "user4"]}) then state saved for the property would match the input values and also add to the end of the list the new elements received from the API. That is: members = ["user1", "user2", "user3", "user4"]
Use case 3: If the remote value for the property members contained a shorter list than items in the tf input (eg: {"members":["user3", "user1"}) then state saved for the property would contain only the matching elements between the input and remote. That is: members = ["user1", "user3"]
Use case 4: If the remote value for the property members contained the same list size as the items in the tf input but some elements inside where updated (eg: {"members":["user1", "user5", "user9"]}) then state saved for the property would contain the matching elements between the input and output and also keep the remote values. That is: members = ["user1", "user5", "user9"]
Checklist (for admin only)
Don't forget to go through the checklist to make sure the issue is created properly:
[x] I have added a corresponding label (feature request) to the issue (right side menu)
[x] I have added this issue to the 'API Terraform Provider' GitHub project (right side menu)
Is your feature request related to a problem?
Describe the solution you'd like
To be able to specify an extension (eg: x-terraform-ignore-order) on a resource property so that when the plugin is updating the state for the property it will inspect the items of the list received from remote and compare with the local values and if the lists are the same but unordered the state will keep the users input.
Acceptance criteria
Given the following terraform snippet where the members values are in certain desired order and assuming that the members property is of type 'list' AND has the
x-terraform-ignore-order
extension set to true in the OpenAPI document for thegroup_v1
resource definition:The following behaviour is applied depending on the different scenarios when processing the response received by the API and saving the state of the property.
members
contained the same items in the same order (eg:{"members":["user1", "user2", "user3"]}
) as the tf input then the state saved for the property would match the input values. That is:members = ["user1", "user2", "user3"]
members
contained the same items as the tf input BUT the order of the elements is different (eg:{"members":["user3", "user2", "user1"]}
) then state saved for the property would match the input values. That is:members = ["user1", "user2", "user3"]
members
contained the same items as the tf input in different order PLUS new ones (eg:{"members":["user2", "user1", "user3", "user4"]}
) then state saved for the property would match the input values and also add to the end of the list the new elements received from the API. That is:members = ["user1", "user2", "user3", "user4"]
members
contained a shorter list than items in the tf input (eg:{"members":["user3", "user1"}
) then state saved for the property would contain only the matching elements between the input and remote. That is:members = ["user1", "user3"]
members
contained the same list size as the items in the tf input but some elements inside where updated (eg:{"members":["user1", "user5", "user9"]}
) then state saved for the property would contain the matching elements between the input and output and also keep the remote values. That is:members = ["user1", "user5", "user9"]
Checklist (for admin only)
Don't forget to go through the checklist to make sure the issue is created properly: