Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

immutable properties where the value has not changed not working properly #159

Closed
2 tasks done
dikhan opened this issue Oct 7, 2019 · 0 comments
Closed
2 tasks done
Labels

Comments

@dikhan
Copy link
Owner

dikhan commented Oct 7, 2019

Describe the bug

Terraform complains for immutable property even though swagger is marked with default value

Error: property network_prefix_length is immutable and therefore can not be updated. 

To Reproduce

Given a terraform compatible resources that uses the following swagger as the resource model definition:

definitions:
  Subnet:
    required:
    - vpc_uuid
    type: object
    properties:
      network_prefix_length:
        default: 27
        type: integer
        x-terraform-immutable: true
      vpc_uuid:
        title: Vpc uuid
        type: string
        x-terraform-immutable: true

And the following corresponding terraform configuration:

resource "openapi_subnets" "my_subnet" {
  vpc_uuid = "some_vpc_uuid"
}

Steps to reproduce the behaviour:

  1. Run terraform apply
  2. The resource will be created with the right state containing the network_prefix_length and the vpc_uuid
  3. Subsequent plans will result into diffs saying that the network_prefix_length value is immutable even though the value has not changed.

Expected behaviour

No diffs should happen if the value of the immutable property has not changed.

Additional context

When comparing the state from remote API with the local changes, the structs marshalled from the API response JSON was treating all ints as floats and when the comparison with the local state value was performed, the check was detecting a diff due to type differences even though the value was the same:

Example: immutable field updated [updatedValue: %!s(int=26); actual: %!s(float64=26)]

Checklist

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

  • I have added a corresponding label (feature request/bug/etc) to the issue (right side menu)
  • I have added this issue to the 'API Terraform Provider' GitHub project (right side menu)
@dikhan dikhan added the bug label Oct 7, 2019
@dikhan dikhan mentioned this issue Oct 7, 2019
7 tasks
@dikhan dikhan closed this as completed Oct 9, 2019
dikhan added a commit that referenced this issue Oct 9, 2019
Fixed the following bugs:
#159: immutable properties where the value has not changed not working properly (#159)
#160: readonly properties inside objects are included in the payload and sent to the API when a resource is updated (#160)
#161: immutable properties within objects and lists of objects are not working as expected  (#161)
devstar0826 added a commit to devstar0826/terraform-provider-openapi that referenced this issue Oct 24, 2019
Fixed the following bugs:
#159: immutable properties where the value has not changed not working properly (dikhan/terraform-provider-openapi#159)
#160: readonly properties inside objects are included in the payload and sent to the API when a resource is updated (dikhan/terraform-provider-openapi#160)
#161: immutable properties within objects and lists of objects are not working as expected  (dikhan/terraform-provider-openapi#161)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant