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

Issues with x-terraform-ignore-order #346

Open arjunrajinstaclustr opened 2 years ago

arjunrajinstaclustr commented 2 years ago

Describe the bug

After using the terraform-provider-openapi plugin fairly extensively, several issues have been identified with the behaviour of the plugin when using with the x-terraform-ignore-order flag -

  1. The plugin throws an NPE when the API response does not contain an optional property.
  2. The plugin does not correctly deal with camelCase vs terraform_compliant_name on property names.
  3. The plugin doesn't correctly handle cases where Terraform sets default values even for optional properties but the API does not return the optional property. (Example - in the local state, arrays become [], maps become {}, strings become "", integers become 0, booleans become false)
  4. The plugin does not correctly deal with integers returned from the API when comparing against the local state, because the API response is mapped to a float64 value but the local state is an integer.

To Reproduce

A clear and concise description on how does it work now and what's the current behaviour.

Steps to reproduce the behavior:

  1. Update TestAccCDN_CreateResourceWithIgnoreListOrderExtension with the following - https://github.com/instaclustr/terraform-provider-openapi/blob/b287aa636768f0b7d2fc4a30b14deb528165225a/tests/e2e/gray_box_cdns_test.go#L429-L663
  2. Run the test

Expected behaviour

The test passes, and the x-terraform-ignore-order flag correctly handles all of the aforementioned issues.

Additional context

Add any other context about the problem here.

Checklist (for admin only)

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