dikhan / terraform-provider-openapi

OpenAPI Terraform Provider that configures itself at runtime with the resources exposed by the service provider (defined in a swagger file)
Apache License 2.0
275 stars 48 forks source link

Add extension to ignore the ordering of elements in an array #228

Closed lillchan closed 4 years ago

lillchan commented 4 years ago

Is your feature request related to a problem?

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.

Checklist (for admin only)

Don't forget to go through the checklist to make sure the issue is created properly: